#!/bin/bash # mkinitd.SlackBuild # Heavily based on the original Slackware build scripts, # Modified by Stuart Winter # 21-Nov-2004 # # Copyright 2007, 2008, 2009 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # Record toolchain & other info for the build log: slackbuildinfo # Busy box version (will need updating): BB=1.15.3 # Paths to skeleton port's source & real Slackware source tree: export CWD=$SLACKSOURCE/$PKGSERIES/$PKGNAM export PORTCWD=$PWD # Temporary build locations: export TMPBUILD=$TMP/build-$PKGNAM export PKG=$TMP/package-$PKGNAM mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD # Determine the CFLAGS for the known architectures: case $ARCH in arm) export SLKCFLAGS="-march=armv4t" ;; *) export SLKCFLAGS="" ;; esac # Write a warning to stdout if the mkinitrd script has a different version: eval $( grep "^MKINITRD_VERSION=" $CWD/mkinitrd ) if [ "$VERSION" != "$MKINITRD_VERSION" ]; then echo "The version of this package ($VERSION) is not equal to the version of the mkinitrd script ($MKINITRD_VERSION)." sleep 5 fi ##### Build busybox ############################################# # Extract source: tar xvvf $CWD/busybox-$BB.tar.bz2 cd busybox-* || exit 1 slackhousekeeping # Fix ARM build problem: # http://osdir.com/ml/linux-kernel/2009-06/msg09557.html patch -p0 --verbose < $PORTCWD/sources/armfix.diff || exit 1 # Configure: sed -e \ 's#^CONFIG_PREFIX=.*#CONFIG_PREFIX="'$PKG'/usr/share/mkinitrd/initrd-tree"#' \ $CWD/busybox-dot-config > .config make oldconfig # Build: make $NUMJOBS || failmake mkdir -p $PKG/usr/share/mkinitrd/initrd-tree/{bin,sbin} make install || exit 1 rm -f $PKG/usr/share/mkinitrd/initrd-tree/linuxrc # Add a poor-man's reboot into the initrd. # This is because if there is a problem and your initrd can't mount # the filesystems, then 'reboot' won't work; and most terminal emulators # disconnect when you power cycle the device, which may cause you to miss # being able to interrupt the boot sequence. mkdir -vpm755 $PKG/sbin echo 'echo b > /proc/sysrq-trigger' > $PKG/sbin/freboot chmod 755 $PKG/sbin/freboot # Copying additional files: cp $CWD/mkinitrd_command_generator.sh $PKG/usr/share/mkinitrd chmod 755 $PKG/usr/share/mkinitrd/mkinitrd_command_generator.sh cp $CWD/keymaps.tar.gz $PKG/usr/share/mkinitrd # Zip up the initrd-tree: ( cd $PKG/usr/share/mkinitrd/initrd-tree tar xf $CWD/_initrd-tree.tar.gz cat $CWD/init > init # Add Slackware ARM stuff: mknod -m 644 dev/random c 1 8 mknod -m 644 dev/urandom c 1 9 # Archive it: tar czf ../initrd-tree.tar.gz . ) rm -rf $PKG/usr/share/mkinitrd/initrd-tree # Add busybox docs: mkdir -p $PKG/usr/doc/busybox-$BB cp -a AUTHORS INSTALL LICENSE README \ $PKG/usr/doc/busybox-$BB mkdir -p $PKG/sbin cat $CWD/mkinitrd > $PKG/sbin/mkinitrd chmod 755 $PKG/sbin/mkinitrd mkdir -p $PKG/usr/man/man{5,8} install -vpm644 $CWD/mkinitrd.8 $PKG/usr/man/man8/ install -vpm644 $CWD/mkinitrd.conf.5 $PKG/usr/man/man5/ mkdir -p $PKG/etc cat $CWD/mkinitrd.conf.sample > $PKG/etc/mkinitrd.conf.sample mkdir -p $PKG/usr/doc/mkinitrd-$VERSION cp -a $CWD/README.initrd $PKG/usr/doc/mkinitrd-$VERSION ( cd $PKG/usr/doc/mkinitrd-$VERSION DATE="$(date)" KERNEL_VERSION="$(uname -r)" PACKAGE_VERSION="$(uname -r | tr - _)" LILO_KERNEL_NAME="$(echo $(uname -r) | tr -d . | tr -d - )" cat README.initrd | sed -e s/@DATE@/"$DATE"/ > README.initrd1 cat README.initrd1 | sed -e s/@KERNEL_VERSION@/"$KERNEL_VERSION"/ > README.initrd2 cat README.initrd2 | sed -e s/@PACKAGE_VERSION@/"$PACKAGE_VERSION"/ > README.initrd3 cat README.initrd3 | sed -e s/@LILO_KERNEL_NAME@/"$LILO_KERNEL_NAME"/ > README.initrd4 cat README.initrd4 | sed -e s/@MKINITRD_VERSION@/"$VERSION"/ > README.initrd5 cat README.initrd5 | sed -e s/@ARCH@/"$ARCH"/ > README.initrd6 cat README.initrd6 | sed -e s/@BUILD@/"$BUILD"/ > README.initrd rm -f README.initrd{1,2,3,4,5,6} ) mkdir $PKG/boot ( cd $PKG/boot ln -sf /usr/doc/mkinitrd-$VERSION/README.initrd . ) # Replace the readme with the ARM version: install -vpm644 $PORTCWD/README.initrd.arm $PKG/usr/doc/mkinitrd-$VERSION/README.initrd ################################################################### # If necessary, start the fakeroot server so we can set file/dir ownerships: start_fakeroot # Apply generic Slackware packaging policies: cd $PKG slackstripall # strip all .a archives and all ELFs slackgzpages -i # compress man & info pages and delete usr/info/dir slackslack # chown -R root:root, chmod -R og-w, slackchown, slack644docs slackdesc # install slack-desc and doinst.sh slackmp # run makepkg -l y -c n # Perform any final checks on the package: cd $PKG slackhlinks # search for any hard links