2006-04-06 21:35:22 +02:00
#!/bin/bash
# $Id$
set +e
# VT100 colors
declare -r BLACK=$'\e[1;30m'
declare -r DK_GRAY=$'\e[0;30m'
declare -r RED=$'\e[31m'
declare -r GREEN=$'\e[32m'
declare -r YELLOW=$'\e[33m'
declare -r BLUE=$'\e[34m'
declare -r MAGENTA=$'\e[35m'
declare -r CYAN=$'\e[36m'
declare -r WHITE=$'\e[37m'
declare -r OFF=$'\e[0m'
declare -r BOLD=$'\e[1m'
declare -r REVERSE=$'\e[7m'
declare -r HIDDEN=$'\e[8m'
declare -r tab_=$'\t'
declare -r nl_=$'\n'
2006-05-02 23:46:27 +02:00
declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
2006-04-06 21:35:22 +02:00
# bold yellow > < pair
declare -r R_arrow=$'\e[1;33m>\e[0m'
declare -r L_arrow=$'\e[1;33m<\e[0m'
usage() {
cat <<- -EOF-
${DD_BORDER}
${BOLD}
Usage: $0 ${BOLD}[OPTION]
2006-05-04 20:46:28 +02:00
${RED}IMPORTANT:${OFF} Only supported command line switches are listed here.
2006-05-04 20:54:12 +02:00
For more fine-grained setups you must edit the relevant
2006-05-04 20:46:28 +02:00
configuration files placed under ${BOLD}common/${OFF} and ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])/${OFF}
2006-04-06 21:35:22 +02:00
Options:
${BOLD} -h, --help${OFF}
print this help, then exit
${BOLD} -V, --version${OFF}
print version information, then exit
${BOLD} -B, --book VER${OFF}
2006-05-04 20:43:55 +02:00
use VER version of the book as the system to build.
Supported versions are: dev*, trunk, SVN
2006-05-18 20:40:22 +02:00
These are aliases for the Development version of {C,H}LFS
2006-04-06 21:35:22 +02:00
${BOLD} -D --directory DIR${OFF}
2006-04-09 12:38:40 +02:00
use DIR directory for building ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF}; all files jhalfs produces
2006-06-01 22:49:41 +02:00
will be in the directory DIR/${SCRIPT_ROOT}.
2006-05-03 03:42:16 +02:00
The current setting for BUILDDIR is "$BUILDDIR"
2006-04-06 21:35:22 +02:00
${BOLD} -G, --get-packages${OFF}
download the packages and patches. This assumes that the server declared
in the configuration file has the proper packages and patches for the
book version being processed.
2006-05-11 22:21:14 +02:00
${BOLD} -O, --optimize${OFF}
Optimize [0-2]
0 = no optimization
2006-05-18 20:40:22 +02:00
1 = optimize final system only
2 = optimize both temporary tools and final system
2006-05-11 22:21:14 +02:00
Edit common/opt_config{,.d/*} and common/opt_override as desired.
2006-04-06 21:35:22 +02:00
${BOLD} -T, --testsuites N ${OFF}
Run test suites [0-3]
0 = none
2006-05-04 21:04:01 +02:00
1 = only final system Glibc, GCC and Binutils testsuites
2 = all final system testsuites
2006-05-05 00:23:22 +02:00
3 = all temporary tools and final system testsuites
2006-04-06 21:35:22 +02:00
In CLFS, 3 is an alias to 2
${BOLD} -W, --working-copy DIR${OFF}
use the local working copy placed in DIR as the $(echo $PROGNAME | tr [a-z] [A-Z]) book
2006-04-29 16:44:29 +02:00
${BOLD} -C, --comparasion TYPE${OFF}
2006-05-04 20:43:55 +02:00
do iterative comparison analysis. This extends the total build time
considerably because the entire final system will rebuild itself
the number of times specified by ITERATIONS in common/config.
2006-05-04 20:45:06 +02:00
Types allowed are:
2006-05-04 20:43:55 +02:00
ICA = do ICA as designed by Greg Schafer
2006-04-29 17:08:13 +02:00
farce = do the farce analysis designed by Ken Moffat
both = perfom both ICA and farce analysis
2006-04-29 16:44:29 +02:00
2006-04-06 21:35:22 +02:00
${BOLD} -F, --fstab FILE${OFF}
use FILE as the /etc/fstab file for the ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF} system. If not specified,
a default /etc/fstab file with dummy values is created.
${BOLD} -K, --kernel-config FILE${OFF}
use the kernel configuration file specified in FILE to build the kernel.
if the file is not found, or if not specified, the kernel build is skipped.
${BOLD} -M, --run-make${OFF}
run make on the generated Makefile
${BOLD} -R --rebuild${OFF}
2006-05-04 20:43:55 +02:00
clean the build directory before perfoming any other task. The directory
2006-04-09 12:38:40 +02:00
is cleaned only if it was populated by a previous jhalfs run.
2006-04-06 21:35:22 +02:00
-EOF-
[[ ${PROGNAME} = "clfs" ]] &&
cat <<- -EOF-
${BOLD} -A, --arch ARCH ${OFF}
Select the TARGET architecture, valid selections are:
32bit builds
2006-04-13 20:24:34 +02:00
x86, i486, i586, ppc, mips, mipsel, sparc
2006-04-06 21:35:22 +02:00
64bit builds
x86_64-64, mips64-64, mipsel64-64, sparc64-64, alpha
64bit multi-lib
x86_64, mips64, mipsel64, sparc64, ppc64
2006-04-29 16:08:43 +02:00
${BOLD} --boot-config FILE ${OFF}
2006-04-06 21:35:22 +02:00
The configuration file for the bootstrap kernel if method=boot
${BOLD} --method BUILDMETHOD ${OFF}
Select the build method, chroot or boot
-EOF-
[[ ${PROGNAME} = "hlfs" ]] &&
cat <<- -EOF-
${BOLD} --model STYLE ${OFF}
Select the library model for the HLFS system
Valid choices are: glibc or uclibc
-EOF-
cat <<- -EOF-
${DD_BORDER}
-EOF-
exit
}
version="
2006-04-09 12:38:40 +02:00
${BOLD} \"jhalfs\"${OFF} builder tool (development) \$Rev$
2006-04-06 21:35:22 +02:00
\$Date$
${BOLD} \"${PROGNAME}\"${OFF} script module
Written by George Boudreau,
Manuel Canales Esparcia,
Jeremy Huntwork
This program is published under the ${BOLD}Gnu General Public License, Version 2.${OFF}
"
no_empty_builddir() {
'clear'
cat <<- -EOF-
${DD_BORDER}
${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
Looks like the \$BUILDDIR directory contains subdirectories
from a previous HLFS build.
Please format the partition mounted on \$BUILDDIR or set
2006-04-09 12:38:40 +02:00
a different build directory before running jhalfs.
2006-04-06 21:35:22 +02:00
${OFF}
${DD_BORDER}
-EOF-
exit
}
help="${nl_}Try '$0 --help' for more information."
exit_missing_arg="\
echo \"Option '\$1' requires an argument\" >&2
echo \"\$help\" >&2
exit 1"
2006-04-09 12:38:40 +02:00
HEADER="# This file is automatically generated by jhalfs
2006-04-06 21:35:22 +02:00
# DO NOT EDIT THIS FILE MANUALLY
#
# Generated on `date \"+%F %X %Z\"`"
#----------------------------------#
2006-04-24 18:36:08 +02:00
wrt_target() { # Create target and initialize log file
2006-04-06 21:35:22 +02:00
#----------------------------------#
local i=$1
local PREV=$2
2006-05-04 20:26:42 +02:00
case $i in
iteration* ) local LOGFILE=$this_script.log ;;
* ) local LOGFILE=$this_script ;;
esac
2006-04-06 21:35:22 +02:00
(
cat << EOF
$i: $PREV
@\$(call echo_message, Building)
2006-06-01 23:54:18 +02:00
@./progress_bar.sh \$@ &
2006-06-01 22:49:41 +02:00
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >logs/$LOGFILE
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
2006-06-01 04:34:38 +02:00
#----------------------------------#
wrt_remove_existing_dirs() { #
#----------------------------------#
local PKG_NAME=$1
(
cat << EOF
2006-06-01 21:52:44 +02:00
@PKG_PATH=\`ls -t \$(MOUNT_PT)\$(SRC)/${PKG_NAME} | head -n1\` && \\
ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
2006-06-01 04:34:38 +02:00
[[ -n \$\$ROOT ]] && \\
rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
2006-06-09 04:31:22 +02:00
if [ -e \$(MOUNT_PT)\$(SRC)/${PKG_NAME%-*}-build ]; then \\
rm -rf \$(MOUNT_PT)\$(SRC)/${PKG_NAME%-*}-build; \\
2006-06-01 04:34:38 +02:00
fi;
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_remove_existing_dirs2() { #
#----------------------------------#
local PKG_NAME=$1
(
cat << EOF
2006-06-01 21:52:44 +02:00
@PKG_PATH=\`ls -t \$(SRC)/${PKG_NAME} | head -n1\` && \\
ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\
2006-06-01 04:34:38 +02:00
[[ -n \$\$ROOT ]] && \\
rm -rf \$(SRC)/\$\$ROOT && \\
2006-06-09 04:31:22 +02:00
if [ -e \$(SRC)/${PKG_NAME%-*}-build ]; then \\
rm -rf \$(SRC)/${PKG_NAME%-*}-build; \\
2006-06-01 04:34:38 +02:00
fi;
EOF
) >> $MKFILE.tmp
}
2006-04-06 21:35:22 +02:00
#----------------------------------#
wrt_unpack() { # Unpack and set 'ROOT' var
#----------------------------------#
local FILE=$1
2006-06-01 04:34:38 +02:00
local optSAVE_PREVIOUS=$2
2006-06-01 20:42:08 +02:00
2006-06-01 04:34:38 +02:00
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
wrt_remove_existing_dirs "$FILE"
fi
2006-04-06 21:35:22 +02:00
(
cat << EOF
@\$(call unpack,$FILE)
2006-06-01 20:42:08 +02:00
@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
2006-04-06 21:35:22 +02:00
echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
2006-04-28 18:53:14 +02:00
chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_unpack2() { #
#----------------------------------#
local FILE=$1
2006-06-01 04:34:38 +02:00
local optSAVE_PREVIOUS=$2
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
wrt_remove_existing_dirs "$FILE"
fi
2006-04-06 21:35:22 +02:00
(
cat << EOF
@\$(call unpack2,$FILE)
2006-06-04 19:56:01 +02:00
@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
2006-04-06 21:35:22 +02:00
echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
EOF
) >> $MKFILE.tmp
}
2006-05-03 11:34:13 +02:00
#----------------------------------#
wrt_unpack3() { #
#----------------------------------#
2006-04-06 21:35:22 +02:00
local FILE=$1
2006-06-01 04:34:38 +02:00
local optSAVE_PREVIOUS=$2
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
wrt_remove_existing_dirs2 "$FILE"
fi
2006-04-06 21:35:22 +02:00
(
cat << EOF
@\$(call unpack3,$FILE)
2006-06-01 20:42:08 +02:00
@ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
2006-04-06 21:35:22 +02:00
echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
EOF
) >> $MKFILE.tmp
}
2006-06-04 19:56:01 +02:00
#----------------------------------#
wrt_test_log() { # Initialize testsuite log file
#----------------------------------#
local TESTLOGFILE=$1
(
cat << EOF
@echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
su - lfs -c "echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE"
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_test_log2() { #
#----------------------------------#
local TESTLOGFILE=$1
(
cat << EOF
@echo "export TEST_LOG=/$SCRIPT_ROOT/test-logs/$TESTLOGFILE" >> envars && \\
echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE
EOF
) >> $MKFILE.tmp
}
2006-04-06 21:35:22 +02:00
#----------------------------------#
wrt_target_vars() { # Target vars for hlfs (cross-build method)
#----------------------------------#
(
cat << EOF
@echo "export target=$(uname -m)-${TARGET}" >> envars && \\
echo "export ldso=/lib/${LOADER}" >> envars
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2006-04-24 18:36:08 +02:00
wrt_run_as_su() { # Execute script inside time { }, footer to log file
2006-04-06 21:35:22 +02:00
#----------------------------------#
local this_script=$1
local file=$2
(
cat << EOF
2006-04-24 18:36:08 +02:00
@( time { su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
2006-06-01 22:49:41 +02:00
echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2006-04-24 18:36:08 +02:00
wrt_run_as_root() { # Some scripts must be run as root..
2006-04-06 21:35:22 +02:00
#----------------------------------#
local this_script=$1
local file=$2
(
cat << EOF
2006-04-24 18:36:08 +02:00
@( time { export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
2006-06-01 22:49:41 +02:00
echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
2006-05-03 11:34:13 +02:00
#----------------------------------#
wrt_run_as_root2() { #
#----------------------------------#
2006-04-06 21:35:22 +02:00
local this_script=$1
local file=$2
(
cat << EOF
2006-04-24 18:36:08 +02:00
@( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
2006-06-01 22:49:41 +02:00
echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/$this_script
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_run_as_chroot1() { #
#----------------------------------#
local this_script=$1
local file=$2
(
cat << EOF
2006-06-01 22:49:41 +02:00
@( time { \$(CHROOT1) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/${this_script}
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_run_as_chroot2() { #
#----------------------------------#
local this_script=$1
local file=$2
(
cat << EOF
2006-06-01 22:49:41 +02:00
@( time { \$(CHROOT2) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/${this_script}
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_copy_fstab() { #
#----------------------------------#
local i=$1
(
cat << EOF
2006-04-24 18:36:08 +02:00
@cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2006-04-24 18:36:08 +02:00
wrt_copy_fstab2() { #
2006-04-06 21:35:22 +02:00
#----------------------------------#
local i=$1
(
cat << EOF
2006-04-24 18:36:08 +02:00
@cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2006-04-23 12:43:05 +02:00
wrt_remove_build_dirs() { #
2006-04-06 21:35:22 +02:00
#----------------------------------#
2006-04-23 12:43:05 +02:00
local name=$1
2006-04-06 21:35:22 +02:00
(
2006-04-23 12:43:05 +02:00
cat << EOF
2006-06-01 20:42:08 +02:00
@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
2006-05-28 00:51:06 +02:00
rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
2006-04-23 12:43:05 +02:00
rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
fi;
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_remove_build_dirs2() { #
#----------------------------------#
local name=$1
(
cat << EOF
2006-06-01 20:42:08 +02:00
@ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
2006-05-28 00:51:06 +02:00
rm -r \$(SRC)/\$\$ROOT && \\
if [ -e \$(SRC)/$name-build ]; then \\
2006-04-23 12:43:05 +02:00
rm -r \$(SRC)/$name-build; \\
fi;
2006-04-06 21:35:22 +02:00
EOF
) >> $MKFILE.tmp
}
2006-04-26 21:59:19 +02:00
#----------------------------------#
2006-05-03 11:34:13 +02:00
wrt_report() { #
2006-04-26 21:59:19 +02:00
#----------------------------------#
(
cat << EOF
create-sbu_du-report: $PREV
@\$(call echo_message, Building)
2006-04-27 22:15:07 +02:00
@./create-sbu_du-report.sh logs $VERSION
2006-04-26 21:59:19 +02:00
@\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
@touch \$@
EOF
) >> $MKFILE.tmp
chapter789="$chapter789 create-sbu_du-report"
}
2006-04-06 21:35:22 +02:00
#----------------------------#
2006-05-03 11:34:13 +02:00
run_make() { #
2006-04-06 21:35:22 +02:00
#----------------------------#
# Test if make must be run.
if [ "$RUNMAKE" = "1" ] ; then
# Test to make sure we're running the build as root
if [ "$UID" != "0" ] ; then
echo "You must be logged in as root to successfully build the system."
exit 1
fi
# Build the system
if [ -e $MKFILE ] ; then
echo -ne "Building the system...\n"
2006-04-17 13:15:24 +02:00
cd $JHALFSDIR && make
2006-04-06 21:35:22 +02:00
echo -ne "done\n"
fi
fi
}
#----------------------------#
2006-05-03 11:34:13 +02:00
clean_builddir() { #
2006-04-06 21:35:22 +02:00
#----------------------------#
# Test if the clean must be done.
if [ "$CLEAN" = "1" ] ; then
# Test to make sure we're running the clean as root
if [ "$UID" != "0" ] ; then
echo "You must be logged in as root to clean the build directory."
exit 1
fi
# Test to make sure that the build directory was populated by jhalfs
if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
2006-04-09 12:38:40 +02:00
echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
2006-04-06 21:35:22 +02:00
exit 1
else
# Clean the build directory
echo -ne "Cleaning $BUILDDIR...\n"
rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
echo -ne "Cleaning $JHALFSDIR...\n"
rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
echo -ne "done\n"
fi
fi
}
#----------------------------#
2006-05-03 11:34:13 +02:00
get_book() { #
2006-04-06 21:35:22 +02:00
#----------------------------#
cd $JHALFSDIR
if [ -z $WC ] ; then
# 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"
echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
case $PROGNAME in
lfs) svn_root="LFS" ;;
hlfs) svn_root="HLFS" ;;
clfs) svn_root="cross-lfs" ;;
*) echo "BOOK not defined in function <get_book>"
exit 1 ;;
esac
# Grab a fresh book if it's missing, otherwise, update it from the
# repo. If we've already extracted the commands, move on to getting the
# sources.
if [ -d ${PROGNAME}-$LFSVRS ] ; then
cd ${PROGNAME}-$LFSVRS
2006-05-01 23:20:29 +02:00
if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/${PROGNAME}-commands && \
test -f $JHALFSDIR/packages ; then
2006-04-06 21:35:22 +02:00
echo -ne "done\n"
# Set the canonical book version
cd $JHALFSDIR
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
get_sources
else
echo -ne "done\n"
# Set the canonical book version
cd $JHALFSDIR
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
extract_commands
fi
else
case $LFSVRS in
development)
svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
esac
echo -ne "done\n"
# Set the canonical book version
cd $JHALFSDIR
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
extract_commands
fi
else
echo -ne "Using $BOOK as book's sources ...\n"
# Set the canonical book version
cd $JHALFSDIR
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;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 $JHALFSDIR
VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
# Start clean
2006-04-14 12:56:04 +02:00
if [ -d ${PROGNAME}-commands ]; then
rm -rf ${PROGNAME}-commands
mkdir -v ${PROGNAME}-commands
2006-04-06 21:35:22 +02:00
fi
echo -n "Extracting commands for"
# Dump the commands in shell script form from the HLFS book.
case ${PROGNAME} in
clfs)
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
xsltproc --nonet \
--xinclude \
--stringparam method $METHOD \
--stringparam testsuite $TEST \
--stringparam vim-lang $VIMLANG \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
--stringparam keymap $KEYMAP \
-o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
;;
hlfs)
echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
xsltproc --nonet \
--xinclude \
--stringparam model $MODEL \
--stringparam testsuite $TEST \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
--stringparam lc_all $LC_ALL \
--stringparam keymap $KEYMAP \
--stringparam grsecurity_host $GRSECURITY_HOST \
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
;;
lfs)
echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
xsltproc --nonet \
--xinclude \
--stringparam testsuite $TEST \
--stringparam vim-lang $VIMLANG \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
;;
2006-04-30 21:42:10 +02:00
*) exit 1 ;;
2006-04-06 21:35:22 +02:00
esac
echo " ...OK"
# Make the scripts executable.
chmod -R +x $JHALFSDIR/${PROGNAME}-commands
2006-04-30 21:42:10 +02:00
# Create the packages file. We need it for proper Makefile creation
rm -f packages
2006-05-18 20:40:22 +02:00
echo -n "Creating <${PROGNAME}> specific packages file"
grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
-e 's@">@"@' > packages
echo " ...OK"
2006-04-06 21:35:22 +02:00
# Done. Moving on...
get_sources
}
#----------------------------#
2006-04-30 21:42:10 +02:00
get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
2006-05-03 02:25:38 +02:00
#----------------------------#
local saveIFS=$IFS
2006-05-06 22:03:02 +02:00
local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
2006-05-03 02:25:38 +02:00
# Test if the packages must be downloaded
[ ! "$GETPKG" = "1" ] && return
gs_wrt_message(){
echo "${RED}$1${OFF}"
2006-05-03 21:17:30 +02:00
echo "$1" >> MISSING_FILES.DMP
}
2006-05-03 02:25:38 +02:00
# Housekeeping
[[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
cd $BUILDDIR/sources
[[ -f MD5SUMS ]] && rm MD5SUMS
[[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
[[ -f urls.lst ]] && rm urls.lst
# Generate URLs file
create_urls
IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
for line in `cat urls.lst`; do
IFS=$saveIFS # Restore the system defaults
# Skip some packages if they aren't needed
case $line in
*/tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
[[ "$TEST" = "0" ]] && continue
;;
*/vim-*-lang* )
[[ "$VIMLANG" = "0" ]] && continue
;;
2006-05-15 20:57:10 +02:00
*linux/linux-* )
2006-05-27 20:40:01 +02:00
[[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
[[ "$GETKERNEL" = "0" ]] && continue
2006-05-15 20:57:10 +02:00
;;
2006-05-03 02:25:38 +02:00
esac
# Locations
2006-05-03 05:30:52 +02:00
URL1=`echo $line | cut -d" " -f2` # Preferred URL
URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
2006-05-06 22:03:02 +02:00
FILE=`basename $URL1` # File name
BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
2006-05-13 13:26:19 +02:00
# Validation pair
MD5="$BOOKMD5 $FILE"
HAVEMD5=1
2006-05-03 02:25:38 +02:00
set -e
2006-05-03 21:17:30 +02:00
# If the file exists in the archive copy it to the
2006-05-03 02:25:38 +02:00
# $BUILDDIR/sources dir. MD5SUM will be validated later.
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -f ${SRC_ARCHIVE}/$FILE ]; then
cp ${SRC_ARCHIVE}/$FILE .
echo "$FILE: -- copied from $SRC_ARCHIVE"
fromARCHIVE=1
else
echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
fromARCHIVE=0
2006-05-13 13:26:19 +02:00
# If the file does not exist yet in /sources download a fresh one
2006-05-03 02:25:38 +02:00
if [ ! -f $FILE ] ; then
if ! wget $URL1 && ! wget $URL2 ; then
2006-05-03 21:17:30 +02:00
gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
continue
2006-05-03 02:25:38 +02:00
fi
fi
fi
2006-05-13 13:26:19 +02:00
# IF the md5sum does not match the existing files
if ! echo "$MD5" | md5sum -c - >/dev/null ; then
[[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
[[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
# Remove the old file and download a new one
rm -fv $FILE
# Force storage in SRC_ARCHIVE
fromARCHIVE=0;
# Try to retrieve again the file. Servers in reverse order.
if ! wget $URL2 && ! wget $URL1 ; then
gs_wrt_message "$FILE not found on the servers.. SKIPPING"
continue
2006-05-03 02:25:38 +02:00
fi
fi
# Validate the MD5SUM one last time
2006-05-13 13:26:19 +02:00
if ! echo "$MD5" | md5sum -c - >/dev/null ; then
2006-05-03 02:25:38 +02:00
gs_wrt_message "$FILE does not match MD5SUMS value"
2006-05-09 22:20:25 +02:00
# Force generation of MD5SUM
HAVEMD5=0
2006-05-03 02:25:38 +02:00
fi
# Generate a fresh MD5SUM for this file
if [[ "$HAVEMD5" = "0" ]] ; then
echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
2006-05-13 13:26:19 +02:00
echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
2006-05-03 02:25:38 +02:00
fi
# Good or bad we write the original md5sum to a file
2006-05-13 13:26:19 +02:00
echo "$MD5" >> MD5SUMS
2006-05-03 02:25:38 +02:00
# Copy the freshly downloaded file
# to the source archive.
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -w ${SRC_ARCHIVE} ] &&
[ "$fromARCHIVE" = "0" ] ; then
echo "Storing file:<$FILE> in the package archive"
cp -f $FILE ${SRC_ARCHIVE}
fi
done
if [[ -s MISSING_FILES.DMP ]]; then
echo -e "\n\n${tab_}${RED} One or more files were not retrieved or have a bad MD5SUMS chechsum.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n"
# Do not allow the automatic exection of the Makefile.
2006-05-03 11:34:13 +02:00
echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
2006-05-03 02:25:38 +02:00
RUNMAKE=0
fi
}
2006-04-06 21:35:22 +02:00
#----------------------------#
2006-04-30 21:42:10 +02:00
create_urls() { #
2006-04-06 21:35:22 +02:00
#----------------------------#
2006-04-30 21:42:10 +02:00
cd $JHALFSDIR
2006-04-06 21:35:22 +02:00
2006-04-30 21:42:10 +02:00
case ${PROGNAME} in
clfs)
echo -n "Creating CLFS <${ARCH}> specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
-o $BUILDDIR/sources/urls.lst urls.xsl \
$BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
hlfs)
echo -n "Creating HLFS <${MODEL}> specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
--stringparam model $MODEL \
-o $BUILDDIR/sources/urls.lst urls.xsl \
$BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
lfs)
echo -n "Creating LFS specific URLs file"
xsltproc --nonet --xinclude \
--stringparam server $SERVER \
-o ../sources/urls.lst urls.xsl \
$BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
echo " ...OK"
;;
esac
2006-04-06 21:35:22 +02:00
2006-04-30 21:42:10 +02:00
cd $BUILDDIR/sources
2006-04-06 21:35:22 +02:00
}