#!/bin/bash # # ELS script to build mdadm-3.1.2. # # The multi-device administrator (mdadm) is used to set up and manage # software RAID arrays on Linux systems. # # Source code is from http://www.kernel.org/pub/linux/utils/raid/mdadm/ # # # This script is public domain software and may be freely copied. # # This script is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # # Define the package name, source directory, build directory and # staging directory paths. Prefixes to directories may be overridden # by setting shell variables SRC, BUILD and STAGING. For example, # doing "export SRC=/root/foo" before calling this script will override # the default /usr/src and set SRC_DIR to /root/foo/$PKG_NAME instead. # PKG_NAME=$(basename $0) SRC_DIR=${SRC:-/usr/src}/$PKG_NAME BUILD_DIR=${BUILD:-/var/tmp/build}/$PKG_NAME STAGING_DIR=${STAGING:-/var/tmp/staging}/$PKG_NAME # Check that the source directory really exits and bail out if not. if ! [ -d $SRC_DIR ]; then echo "Cannot find source code directory $SRC_DIR." exit 1 fi # Do not overwrite existing build directory. if [ -d $BUILD_DIR ]; then echo "Build directory $BUILD_DIR already exists." exit 2 else mkdir -p $BUILD_DIR fi # Do not overwrite existing staging directory. if [ -d $STAGING_DIR ]; then echo "Staging directory $STAGING_DIR already exists." exit 4 else mkdir -p $STAGING_DIR fi # This is not one of the packages that can be configured and built # completely outside of the source tree. So in order to leave the # original source untouched, the contents of $SRC_DIR are first copied # to $BUILD_DIR. The copy in $BUILD_DIR is then modified to suit the # configuration. cp -dpR $SRC_DIR/* $BUILD_DIR cd $BUILD_DIR # Configuration is done by passing variables to make in order to over- # ride the values defined in the Makefile. The CC variable is used to # configure the use of gcc and i586 compatible code. MAILCMD is used # to select procmail instead of sendmail as the mail delivery agent. make CC="gcc -march=i586" # Check return code and bail if it looks bad. if [ $? -gt 0 ]; then echo "Build failed with error code $?" exit 16 fi # Install into the staging area. make DESTDIR=$STAGING_DIR \ CC="gcc -march=i586" \ install # Check return code and bail if it looks bad. if [ $? -gt 0 ]; then echo "Installation to staging area failed with error code $?" exit 32 fi # Remove the unused udev stuff. rm $STAGING_DIR/lib/udev/rules.d/64-md-raid.rules rmdir $STAGING_DIR/lib/udev/rules.d rmdir $STAGING_DIR/lib/udev rmdir $STAGING_DIR/lib # Keep a copy of the license document. install -D -o root -g root -m 644 $SRC_DIR/COPYING \ $STAGING_DIR/usr/share/doc/$PKG_NAME/LICENSE # Strip binaries and compress documentation to save space. strip $STAGING_DIR/sbin/* gzip -r $STAGING_DIR/usr/share/man gzip -r $STAGING_DIR/usr/share/doc # Create the package if ! [ "$PKG_COMMAND" = "" ]; then export $PKG_NAME $STAGING_DIR $PKG_COMMAND else cd $STAGING_DIR tar -zcf ../$PKG_NAME.i586.tar.gz * fi # end of blueprint