#!/bin/sh # # Load the configuration file # source jhablfs.conf version=" jhablfs development \$Date: 2005-12-04 13:24:26 +0100 (dom, 04 dic 2005) $ Written by Jeremy Huntwork and Manuel Canales Esparcia. This program is published under the \ Gnu General Public License, Version 2. " usage="\ Usage: $0 [OPTION] Options: -h, --help print this help, then exit -V, --version print version number, then exit -B, --BLFS-version VER checkout VER version of the BLFS book. If not set, the development version is used. Supported versions at this time are: dev* | trunk | SVN aliases for Development BLFS -W, --working-copy DIR use the local working copy placed in DIR as the BLFS book -D, --dependencies TYPE add dependencies of type TYPE to the build tree. If not set, both required a recommended are used. Possible values are: required only required dependecies are used recommended both required a recommended dependencies are used optional all dependencies are used -S, --server SERVER set the FTP/HTTP server used as fallback to download the packages. If not specified, the one set in jhablfs.conf is used. -T, --testsuites add support to run the optional testsuites " help="\ Try '$0 --help' for more information." exit_missing_arg="\ echo \"Option '\$1' requires an argument\" >&2 echo \"\$help\" >&2 exit 1" HEADER="# This file is automatically generated by jhablfs # EDIT THIS FILE MANUALLY TO SUIT YOUR NEEDS # # Generated on `date \"+%F %X %Z\"`" ################################### ### FUNCTIONS ### ################################### #----------------------------# get_book() { #----------------------------# # Check for Subversion instead of just letting the script hit 'svn' and fail. test `type -p svn` || eval "echo \"This feature requires Subversion.\" exit 1" cd $JHABLFSDIR if [ -z $WC ] ; then echo -n "Downloading the BLFS Book, version $BLFSVRS... " # Grab the BLFS book fresh if it's missing, otherwise, update it from the # repo. If we've already extracted the commands, move on. if [ -d blfs-$BLFSVRS ] ; then cd blfs-$BLFSVRS if LC_ALL=C svn up | grep -q At && test -d $JHABLFSDIR/commands ; then echo -ne "done\n" # Set the canonical book version cd $JHABLFSDIR VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` else echo -ne "done\n" # Set the canonical book version cd $JHABLFSDIR VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` extract_commands fi else case $BLFSVRS in development) svn co $SVN/BLFS/trunk/BOOK blfs-$BLFSVRS >>$LOGDIR/$LOG 2>&1 ;; esac echo -ne "done\n" # Set the canonical book version cd $JHABLFSDIR VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` extract_commands fi else echo -ne "Using $BOOK as book's sources ...\n" # Set the canonical book version cd $JHABLFSDIR VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@@@'` extract_commands fi } #----------------------------# extract_commands() { #----------------------------# # Check for libxslt instead of just letting the script hit 'xsltproc' and fail. test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\" exit 1" cd $JHABLFSDIR # Start clean if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands echo -n "Extracting commands... " # Dump the commands in shell script form from the BLFS book. xsltproc --nonet --xinclude --stringparam testsuite $TEST \ --stringparam server $SERVER -o ./commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1 # Make the scripts executable. chmod -R +x $JHABLFSDIR/commands # Done. Moving on... echo -ne "done\n" } #----------------------------# build_Makefile() { #----------------------------# echo -n "Creating Makefile... " cd $JHABLFSDIR/commands # Start with a clean Makefile file >$MKFILE # Add a header, some variables and include the function file # to the top of the real Makefile. ( cat << EOF $HEADER include functions EOF ) > $MKFILE # Drop in a dummy target 'all:'. ( cat << EOF all: @echo -e "\nThere is no default target predefined" @echo -e "You must to tell what package(s) you want to install" @echo -e "or edit the \"all\" Makefile target to create your own" @echo -e "defualt target.\n" @exit EOF ) >> $MKFILE # Bring over the build targets. for file in */* ; do # Keep the script file name case $file in gnome/config ) i=config-gnome ;; gnome/pre-install-config ) i=pre-intall-config-gnome ;; kde/config ) i=config-kde ;; kde/pre-install-config ) i=pre-intall-config-kde ;; * ) i=`basename $file` ;; esac # Dump the package dependencies. REQUIRED=`grep "REQUIRED" $file | sed 's/# REQUIRED://' | tr -d '\n'` if [ "$DEPEND" != "0" ] ; then RECOMMENDED=`grep "RECOMMENDED" $file | sed 's/# RECOMMENDED://' | tr -d '\n'` fi if [ "$DEPEND" = "2" ] ; then OPTIONAL=`grep "OPTIONAL" $file | sed 's/# OPTIONAL://' | tr -d '\n'` fi # Drop in the name of the target on a new line plus its dependencies # and call the echo_message function. ( cat << EOF $i: $REQUIRED $RECOMMENDED $OPTIONAL @\$(call echo_message, Building) EOF ) >> $MKFILE # Insert date and disk usage at the top of the log file, the script run # and date and disk usage again at the bottom of the log file. ( cat << EOF @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >logs/$i && \\ $JHABLFSDIR/commands/$file >>logs/$i 2>&1 && \\ echo -e "\n\`date\`\n\nKB: \`du -sk --exclude=logs/* /\`\n" >>logs/$i EOF ) >> $MKFILE # Include a touch of the target name so make can check # if it's already been made. ( cat << EOF @touch \$@ EOF ) >> $MKFILE done echo -ne "done\n" } ################################### ### MAIN ### ################################### # Evaluate any command line switches while test $# -gt 0 ; do case $1 in --version | -V ) echo "$version" exit 0 ;; --help | -h ) echo "$usage" exit 0 ;; --BLFS-version | -B ) test $# = 1 && eval "$exit_missing_arg" shift case $1 in dev* | SVN | trunk ) BLFSVRS=development ;; * ) echo "$1 is an unsupported version at this time." exit 1 ;; esac ;; --working-copy | -W ) test $# = 1 && eval "$exit_missing_arg" shift if [ -f $1/use-unzip.xml ] ; then WC=1 BOOK=$1 else echo -e "\nLook like $1 isn't a proper BLFS working copy." echo -e "Verify your selection and the command line.\n" exit 1 fi ;; --dependencies | -D ) test $# = 1 && eval "$exit_missing_arg" shift case $1 in required ) DEPEND=0 ;; recommended ) DEPEND=1 ;; optional ) DEPEND=2 ;; * ) echo "$1 is not a proper dependencies type." exit 1 ;; esac ;; --testsuites | -T ) TEST=1 ;; --server | -S ) test $# = 1 && eval "$exit_missing_arg" shift case $1 in *conglomeration ) SERVER=$1 ;; * ) echo "$1 is not a proper HTTP/FTP path to the BLFS packages." exit 1 ;; esac ;; * ) echo "$usage" exit 1 ;; esac shift done if [ -z $BOOK ] ; then BOOK=blfs-$BLFSVRS fi [[ ! -d $JHABLFSDIR ]] && mkdir -pv $JHABLFSDIR [[ "$PWD" != "$JHABLFSDIR" ]] && cp -v $FILES $JHABLFSDIR [[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR >$LOGDIR/$LOG get_book build_Makefile