2006-03-07 21:02:53 +01:00
#!/bin/bash
2006-03-11 00:35:41 +01:00
# $Id$
set +e
2006-03-07 21:02:53 +01:00
# 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'
declare -r DD_BORDER="${BOLD}${WHITE}==============================================================================${OFF}"
declare -r SD_BORDER="${BOLD}${WHITE}------------------------------------------------------------------------------${OFF}"
declare -r STAR_BORDER="${BOLD}${WHITE}******************************************************************************${OFF}"
# 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-03-28 01:40:44 +02:00
Options:
${BOLD} -h, --help${OFF}
print this help, then exit
2006-03-28 21:17:13 +02:00
2006-03-28 01:40:44 +02:00
${BOLD} -V, --version${OFF}
2006-03-28 21:19:22 +02:00
print version information, then exit
2006-03-28 21:17:13 +02:00
${BOLD} -B, --book VER${OFF}
checkout VER version of the book. Supported versions at this time are:
dev* | trunk | SVN aliases for Development {C,H,B}LFS
udev* aliases for the LFS udev_update branch
2006-03-28 01:40:44 +02:00
${BOLD} -D --directory DIR${OFF}
2006-03-28 21:17:13 +02:00
use DIR directory for building ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF}; all files jhalfs-X produces
will be in the directory DIR/jhalfs.
2006-03-28 01:40:44 +02:00
${BOLD} -G, --get-packages${OFF}
2006-03-28 21:17:13 +02:00
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-03-28 01:40:44 +02:00
${BOLD} -T, --testsuites N ${OFF}
Run test suites [0-3]
0 = none
1 = only chapter06 Glibc, GCC and Binutils testsuites
2006-03-28 21:17:13 +02:00
2 = all chapter06 testsuites (in BLFS, alias to 1)
2006-03-28 20:07:54 +02:00
3 = all chapter05 and chapter06 testsuites
2006-03-28 21:17:13 +02:00
In BLFS, 2 and 3 are aliases to 1
In CLFS, 3 is an alias to 2
2006-03-28 01:40:44 +02:00
${BOLD} -W, --working-copy DIR${OFF}
2006-03-28 21:19:22 +02:00
use the local working copy placed in DIR as the $(echo $PROGNAME | tr [a-z] [A-Z]) book
2006-03-28 21:17:13 +02:00
-EOF-
[[ ${PROGNAME} != "blfs" ]] &&
cat <<- -EOF-
2006-04-09 12:27:06 +02:00
${BOLD} -C, --comparasion TYPE${OFF}
do iterative comparison analysis. That will take several time due that
the final system packages wil be rebuilded the times defined in the
ITERATIONS config option.
Analisys types allowed are:
ICA = do the ICA analisys designed by Greg Schafer
farce = do the farce analisys designed by Ken Moffat
both = perfom both ICA and farce analisys
2006-04-08 14:21:34 +02:00
2006-03-28 01:40:44 +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.
2006-03-28 21:17:13 +02:00
2006-03-28 01:40:44 +02:00
${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.
2006-03-28 21:17:13 +02:00
2006-03-28 01:40:44 +02:00
${BOLD} -M, --run-make${OFF}
run make on the generated Makefile
2006-03-28 21:17:13 +02:00
${BOLD} -R --rebuild${OFF}
clean the build directory before to perfom any other task. The directory
is cleaned only if it was populated by a previous jhalfs-X run.
2006-03-28 01:40:44 +02:00
-EOF-
[[ ${PROGNAME} = "clfs" ]] &&
cat <<- -EOF-
2006-03-28 01:49:09 +02:00
2006-03-28 01:40:44 +02:00
${BOLD} -A, --arch ARCH ${OFF}
Select the TARGET architecture, valid selections are:
32bit builds
2006-03-28 20:07:54 +02:00
x86, i486, i586, ppc, mips, mipsel, sparc, sparcv8
2006-03-28 01:40:44 +02:00
64bit builds
x86_64-64, mips64-64, mipsel64-64, sparc64-64, alpha
64bit multi-lib
x86_64, mips64, mipsel64, sparc64, ppc64
2006-03-28 21:17:13 +02:00
2006-03-28 01:40:44 +02:00
${BOLD} --boot_config FILE ${OFF}
The configuration file for the bootstrap kernel if method=boot
2006-03-28 21:17:13 +02:00
${BOLD} --method BUILDMETHOD ${OFF}
Select the build method, chroot or boot
2006-03-28 01:40:44 +02:00
-EOF-
[[ ${PROGNAME} = "hlfs" ]] &&
cat <<- -EOF-
2006-03-28 01:49:09 +02:00
2006-03-28 01:40:44 +02:00
${BOLD} --model STYLE ${OFF}
Select the library model for the HLFS system
2006-03-28 20:07:54 +02:00
Valid choices are: glibc or uclibc
2006-03-28 01:40:44 +02:00
-EOF-
2006-03-07 21:02:53 +01:00
2006-03-28 01:49:09 +02:00
[[ ${PROGNAME} = "blfs" ]] &&
2006-03-07 21:02:53 +01:00
cat <<- -EOF-
2006-03-28 01:49:09 +02:00
${BOLD} --dependencies 0/1/2${OFF}
2006-03-07 21:02:53 +01:00
add dependencies of type TYPE to the build tree.
2006-03-28 02:01:50 +02:00
If not set, both required and recommended are used.
2006-03-07 21:02:53 +01:00
Possible values are:
2006-03-28 01:49:09 +02:00
0 - required only required dependecies are used
1 - recommended both required a recommended dependencies are used
2 - optional all dependencies are used
-EOF-
cat <<- -EOF-
2006-03-07 21:02:53 +01:00
${DD_BORDER}
-EOF-
exit
}
version="
2006-04-09 12:39:57 +02:00
${BOLD} \"jhalfs-X\"${OFF} builder tool (experimental) \$Rev$
2006-03-28 20:07:54 +02:00
\$Date$
${BOLD} \"${PROGNAME}\"${OFF} script module
2006-03-07 21:02:53 +01:00
2006-03-30 20:26:11 +02:00
Written by George Boudreau,
2006-03-28 20:07:54 +02:00
Manuel Canales Esparcia,
2006-03-30 20:26:11 +02:00
Jeremy Huntwork
2006-03-07 21:02:53 +01:00
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-03-28 22:11:42 +02:00
a different build directory before running jhalfs-X.
2006-03-07 21:02:53 +01: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"
no_dl_client="\
2006-03-27 20:46:32 +02:00
echo \"Could not find a way to download the ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF} sources.\" >&2
2006-03-07 21:02:53 +01:00
echo \"Attempting to continue.\" >&2"
2006-03-28 22:11:42 +02:00
HEADER="# This file is automatically generated by jhalfs-X
2006-03-07 21:02:53 +01:00
# DO NOT EDIT THIS FILE MANUALLY
#
# Generated on `date \"+%F %X %Z\"`"
#----------------------------------#
wrt_target() { #
#----------------------------------#
local i=$1
local PREV=$2
(
cat << EOF
$i: $PREV
@\$(call echo_message, Building)
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2006-03-28 22:11:42 +02:00
wrt_unpack() { # Unpack and set 'ROOT' var
2006-03-07 21:02:53 +01:00
#----------------------------------#
local FILE=$1
(
cat << EOF
@\$(call unpack,$FILE)
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
2006-03-18 04:46:54 +01:00
chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
2006-03-07 21:02:53 +01:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_unpack2() { #
#----------------------------------#
local FILE=$1
(
cat << EOF
@\$(call unpack2,$FILE)
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
EOF
) >> $MKFILE.tmp
}
#=============================#
2006-03-28 22:11:42 +02:00
wrt_unpack3() { #
2006-03-07 21:02:53 +01:00
#=============================#
local FILE=$1
(
cat << EOF
2006-03-19 12:14:42 +01:00
@\$(call unpack3,$FILE)
2006-03-07 21:02:53 +01:00
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_target_vars() { # Target vars for hlfs (cross-build method)
#----------------------------------#
(
cat << EOF
2006-03-18 04:46:54 +01:00
@echo "export target=$(uname -m)-${TARGET}" >> envars && \\
2006-03-07 21:02:53 +01:00
echo "export ldso=/lib/${LOADER}" >> envars
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2006-03-28 22:11:42 +02:00
wrt_run_as_su() { # header to log file, execute script, footer to log file
2006-03-07 21:02:53 +01:00
#----------------------------------#
local this_script=$1
local file=$2
(
cat << EOF
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_run_as_root() { #
#----------------------------------#
local this_script=$1
local file=$2
(
cat << EOF
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
EOF
) >> $MKFILE.tmp
}
#=============================#
2006-03-28 22:11:42 +02:00
wrt_run_as_root2() { # Some scripts must be run as root..
2006-03-07 21:02:53 +01:00
#=============================#
local this_script=$1
local file=$2
(
cat << EOF
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >logs/$this_script && \\
source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >>logs/$this_script
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_remove_build_dirs() { #
#----------------------------------#
local name=$1
(
cat << EOF
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
fi;
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_remove_build_dirs2() { #
#----------------------------------#
local name=$1
(
cat << EOF
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
rm -r \$(SRC)/\$\$ROOT && \\
if [ -e \$(SRC)/$name-build ]; then \\
rm -r \$(SRC)/$name-build; \\
fi;
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_run_as_chroot1() { #
#----------------------------------#
local this_script=$1
local file=$2
(
cat << EOF
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
\$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_run_as_chroot2() { #
#----------------------------------#
local this_script=$1
local file=$2
(
cat << EOF
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
\$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_copy_fstab() { #
#----------------------------------#
local i=$1
(
cat << EOF
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$i && \\
cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1 && \\
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$i
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_copy_fstab2() { #
#----------------------------------#
local i=$1
(
cat << EOF
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >logs/$i && \\
2006-03-21 17:07:34 +01:00
cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1 && \\
2006-03-07 21:02:53 +01:00
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >>logs/$i
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
wrt_export_pkgdir() { #
#----------------------------------#
(
cat << EOF
@echo "export PKGDIR=\$(SRC)/binutils-build" > envars
EOF
) >> $MKFILE.tmp
}
#----------------------------#
run_make() {
#----------------------------#
# 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
2006-03-28 22:11:42 +02:00
echo "You must be logged in as root to successfully build the system."
2006-03-07 21:02:53 +01:00
exit 1
fi
# Build the system
if [ -e $MKFILE ] ; then
2006-03-28 22:11:42 +02:00
echo -ne "Building the system...\n"
2006-04-17 13:15:36 +02:00
cd $JHALFSDIR && make
2006-03-07 21:02:53 +01:00
echo -ne "done\n"
fi
fi
}
#----------------------------#
clean_builddir() {
#----------------------------#
# 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-03-28 22:11:42 +02:00
echo "Looks like $BUILDDIR was not populated by a previous jhalfs-X run."
2006-03-07 21:02:53 +01:00
exit 1
else
# Clean the build directory
echo -ne "Cleaning $BUILDDIR...\n"
2006-03-28 04:37:33 +02:00
rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
2006-03-07 21:02:53 +01:00
echo -ne "Cleaning $JHALFSDIR...\n"
2006-03-28 04:37:33 +02:00
rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
2006-03-07 21:02:53 +01:00
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
}
#----------------------------#
get_book() {
#----------------------------#
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" ;;
blfs) svn_root="BLFS" ;;
*) echo "BOOK not defined in function <get_book>"
exit 1 ;;
esac
2006-03-28 22:11:42 +02:00
# Grab a fresh book if it's missing, otherwise, update it from the
2006-03-07 21:02:53 +01:00
# repo. If we've already extracted the commands, move on to getting the
# sources.
if [ -d ${PROGNAME}-$LFSVRS ] ; then
cd ${PROGNAME}-$LFSVRS
if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/commands && \
test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
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
2006-03-28 22:11:42 +02:00
development)
2006-03-07 21:02:53 +01:00
svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
2006-03-28 22:11:42 +02:00
alphabetical)
2006-03-07 21:02:53 +01:00
svn co $SVN/${svn_root}/branches/$LFSVRS/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
2006-03-28 22:11:42 +02:00
udev_update)
2006-03-10 21:15:31 +01:00
svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
2006-03-07 21:02:53 +01:00
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
}
#----------------------------#
build_patches_file() { # Supply a suitably formated list of patches.
#----------------------------#
2006-03-17 16:13:31 +01:00
local saveIFS=$IFS
2006-03-10 16:28:52 +01:00
local IFS
2006-03-21 00:07:53 +01:00
rm -f patches
2006-03-07 21:02:53 +01:00
LOC_add_patches_entry() {
for f in `grep "/$1-" patcheslist_.wget`; do
basename $f | sed "s|${2}|\&${1}-version;|" >> patches
done
}
2006-03-21 00:07:53 +01:00
case ${PROGNAME} in
hlfs)
2006-03-28 22:11:42 +02:00
echo -n "Creating the HLFS ${L_arrow}${BOLD}$MODEL${R_arrow} specific patches file"
2006-03-21 00:07:53 +01:00
xsltproc --nonet \
--xinclude \
--stringparam model $MODEL \
-o patcheslist_.wget \
patcheslist.xsl \
$BOOK/chapter04/patches.xml
#> /dev/null 2>&1
# .... U G L Y .... what to do with the grsecurity patch to the kernel..
for f in `grep "/grsecurity-" patcheslist_.wget`; do
basename $f >> patches
done
;;
clfs) # Pull out a list of arch specific patches
2006-03-28 22:11:42 +02:00
echo -n "Creating CLFS ${L_arrow}${BOLD}$ARCH${R_arrow} specific patches file"
2006-03-21 00:07:53 +01:00
xsltproc -xinclude \
-o patcheslist_.wget \
patcheslist.xsl \
2006-03-21 21:01:36 +01:00
$BOOK/materials/${ARCH}-chapter.xml
2006-03-21 00:07:53 +01:00
;;
*) return
esac
2006-03-07 21:02:53 +01:00
IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
for f in `cat packages`; do
2006-03-17 16:13:31 +01:00
IFS=$saveIFS # Restore the system defaults
2006-03-07 21:02:53 +01:00
LOC_add_patches_entry \
`echo $f | sed -e 's/-version//' \
-e 's/-file.*//' \
-e 's/"//g' \
-e 's/uclibc/uClibc/'`
done
2006-03-28 22:11:42 +02:00
rm -f patcheslist_.wget
2006-03-21 00:07:53 +01:00
echo " ...OK"
2006-03-07 21:02:53 +01:00
}
#----------------------------#
extract_commands() { #
#----------------------------#
2006-03-21 00:07:53 +01:00
local saveIFS=$IFS
2006-03-21 21:01:36 +01:00
2006-03-07 21:02:53 +01:00
# 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:57:04 +02:00
if [ -d ${PROGNAME}-commands ]; then
rm -rf ${PROGNAME}-commands
mkdir -v ${PROGNAME}-commands
2006-03-07 21:02:53 +01:00
fi
2006-03-10 16:28:52 +01:00
echo -n "Extracting commands for"
2006-03-07 21:02:53 +01:00
# Dump the commands in shell script form from the HLFS book.
case ${PROGNAME} in
clfs)
2006-03-21 00:07:53 +01:00
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
2006-03-22 23:52:32 +01:00
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 \
2006-03-21 17:07:34 +01:00
-o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
2006-03-07 21:02:53 +01:00
;;
hlfs)
2006-03-28 22:11:42 +02:00
echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
2006-03-19 13:44:32 +01:00
xsltproc --nonet \
--xinclude \
--stringparam model $MODEL \
--stringparam testsuite $TEST \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
2006-03-19 14:40:28 +01:00
--stringparam lang $LANG \
--stringparam lc_all $LC_ALL \
2006-03-19 13:44:32 +01:00
--stringparam keymap $KEYMAP \
--stringparam grsecurity_host $GRSECURITY_HOST \
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
2006-03-07 21:02:53 +01:00
;;
lfs)
2006-03-21 00:07:53 +01:00
echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
2006-03-07 21:02:53 +01:00
xsltproc --nonet \
--xinclude \
--stringparam testsuite $TEST \
--stringparam vim-lang $VIMLANG \
2006-03-19 13:44:32 +01:00
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
2006-03-19 14:40:28 +01:00
--stringparam lang $LANG \
2006-03-07 21:02:53 +01:00
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
;;
blfs)
2006-03-21 00:07:53 +01:00
echo -n " ${L_arrow}${BOLD}BLFS${R_arrow} build"
2006-03-07 21:02:53 +01:00
xsltproc --nonet \
--xinclude \
2006-03-16 22:18:28 +01:00
--stringparam testsuite $TEST \
--stringparam server $SERVER \
2006-03-07 21:02:53 +01:00
-o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
;;
*) exit 1
esac
2006-03-11 00:35:41 +01:00
2006-03-10 16:28:52 +01:00
echo " ...OK"
2006-03-07 21:02:53 +01:00
# Make the scripts executable.
chmod -R +x $JHALFSDIR/${PROGNAME}-commands
# Grab the patches and package names.
2006-03-21 21:01:36 +01:00
for i in patches packages ; do
2006-03-21 00:07:53 +01:00
rm -f $i
done
#
case "${PROGNAME}" in
clfs)
################################
# A LOCAL function
# xx_.wget contains arch specific files but in URL format
# Build a file with only arch specific files.. small ugly..
LOC_add_packages_entry() {
local fileMATCH aFILE
2006-03-21 02:03:35 +01:00
2006-03-23 04:28:53 +01:00
# Deal with a non-standard format
if [[ "$1" = "clfs-bootscripts" ]]; then
set -- "bootscripts-cross-lfs" $2
fi
2006-03-21 00:07:53 +01:00
fileMATCH="/$1"
2006-03-23 04:28:53 +01:00
2006-03-21 00:07:53 +01:00
# format.. Filename-Version or FilenameVersion
for aFILE in `grep ${fileMATCH}-*[[:digit:]] packageslist_.wget`; do
2006-03-21 02:03:35 +01:00
# Block vim-x.x-lang file, will add it later based on config flag
if [[ ! "${aFILE}" =~ "vim-$2-lang" ]]; then
echo "$1-version \"$2\"" >> packages
fi
2006-03-21 00:07:53 +01:00
done
}
#################################
2006-03-21 21:01:36 +01:00
2006-03-21 00:07:53 +01:00
# We only want a list arch specific files..
# Unfortunately this script produces URL's which must be converted to a std format
2006-03-28 22:11:42 +02:00
echo -n "Creating CLFS ${L_arrow}${BOLD}${ARCH}${R_arrow} specific packages file"
2006-03-21 00:07:53 +01:00
xsltproc -xinclude \
-o packageslist_.wget \
packageslist.xsl \
2006-03-21 21:01:36 +01:00
$BOOK/materials/${ARCH}-chapter.xml
2006-03-21 00:07:53 +01:00
2006-03-21 21:01:36 +01:00
# This has the correct format but contains packages from every book
2006-03-21 00:07:53 +01:00
grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
-e 's@">@"@' \
-e '/generic/d' > packages.tmp
# This variable is necessary to make sure the `cat $JHALFSDIR/packages`
# separates each iteration by lines.
# Modify the 'internal field separator' to break on 'LF' only
IFS=$'\x0A'
for f in `cat packages.tmp`; do
2006-03-21 21:01:36 +01:00
IFS=$saveIFS # Restore the system defaults
2006-03-21 00:07:53 +01:00
LOC_add_packages_entry \
`echo $f | sed -e 's/-version//' \
-e 's/-file.*//' \
-e 's/"//g'`
done
2006-03-28 22:11:42 +02:00
rm -f packageslist_.wget packages.tmp
2006-03-21 00:07:53 +01:00
echo " ...OK"
;;
2006-03-21 21:01:36 +01:00
2006-03-25 20:35:38 +01:00
hlfs)
2006-03-28 22:11:42 +02:00
echo -n "Creating <${PROGNAME}> specific packages file"
2006-03-25 20:35:38 +01:00
grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' \
-e 's@">@"@' \
-e '/generic/d' >> packages
echo " ...OK"
;;
lfs)
2006-03-28 22:11:42 +02:00
echo -n "Creating <${PROGNAME}> specific packages file"
2006-03-21 00:07:53 +01:00
grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' \
-e 's@">@"@' \
-e '/generic/d' >> packages
2006-03-25 20:35:38 +01:00
echo `grep "glibc" packages | sed 's@glibc@glibc-libidn@'` >> packages
echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
2006-03-21 14:25:20 +01:00
echo " ...OK"
2006-03-21 21:01:36 +01:00
;;
2006-03-21 00:07:53 +01:00
esac
2006-03-07 21:02:53 +01:00
# Download the vim-lang package if it must be installed
2006-03-17 21:49:18 +01:00
if [ "$VIMLANG" = "1" ] && [ ! "$PROGNAME" = "hlfs" ] ; then
2006-03-07 21:02:53 +01:00
echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
fi
2006-03-28 22:11:42 +02:00
# Create the patches file
2006-03-07 21:02:53 +01:00
case "${PROGNAME}" in
2006-03-21 00:07:53 +01:00
hlfs)
build_patches_file ;;
clfs )
build_patches_file ;;
2006-03-12 14:11:39 +01:00
lfs)
grep "^<\!ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
;;
2006-03-07 21:02:53 +01:00
blfs) ;;
*) exit 1
esac
2006-03-11 00:35:41 +01:00
2006-03-07 21:02:53 +01:00
# Done. Moving on...
get_sources
}
#----------------------------#
download() { # Download file, write name to MISSING_FILES.DMP if an error
#----------------------------#
cd $BUILDDIR/sources
2006-03-11 00:35:41 +01:00
# Hackish fix for the bash-doc, glibc-{linuxthreads,libidn}
2006-03-10 02:44:55 +01:00
# that don't conform to norms in the URL scheme.
2006-03-07 21:02:53 +01:00
DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
2006-03-15 22:50:40 +01:00
# If the file exists in the archive copy it to the $BUILDDIR/sources dir
2006-03-16 22:18:28 +01:00
# MD5SUM is assumed to be correct from previous download
2006-03-15 22:50:40 +01:00
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -f ${SRC_ARCHIVE}/$2 ]; then
cp ${SRC_ARCHIVE}/$2 .
echo "$2: -- ok"
return
fi
2006-03-07 21:02:53 +01:00
# Find the md5 sum for this package.
if [ $2 != MD5SUMS ] ; then
set +e
MD5=`grep " $2" MD5SUMS`
if [ $? -ne 0 ]; then
set -e
echo "${RED}$2 not found in MD5SUMS${OFF}"
echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP
return
fi
set -e
fi
if [ ! -f $2 ] ; then
case $DL in
2006-03-22 15:15:22 +01:00
wgetFTP ) wget --passive $FTP/$DIR/$2 ;;
wget ) wget $HTTP/$DIR/$2 ;;
2006-03-10 02:44:55 +01:00
curl ) `curl -# $FTP/$DIR/$2 -o $2` ;;
2006-03-07 21:02:53 +01:00
* ) echo "$DL not supported at this time." ;;
esac
elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
case $DL in
2006-03-22 15:15:22 +01:00
wgetFTP ) wget --passive -c $FTP/$DIR/$2 ;;
wget ) wget -c $HTTP/$DIR/$2 ;;
2006-03-10 02:44:55 +01:00
curl ) `curl -# -C - $FTP/$DIR/$2 -o $2` ;;
2006-03-07 21:02:53 +01:00
* ) echo "$DL not supported at this time." ;;
esac
fi
if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
exit 1
fi
if [ $2 != MD5SUMS ] ; then
echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
fi
2006-03-15 22:50:40 +01:00
# If we make it this far we should copy the freshly downloaded file
2006-03-16 22:18:28 +01:00
# to the source archive.
2006-03-15 22:50:40 +01:00
if [ ! -z ${SRC_ARCHIVE} ] &&
[ -d ${SRC_ARCHIVE} ] &&
[ -w ${SRC_ARCHIVE} ] &&
[ $2 != MD5SUMS ]; then
echo "Store file:<$2> in package archive"
cp -v $2 ${SRC_ARCHIVE}
fi
2006-03-07 21:02:53 +01:00
}
#----------------------------#
get_sources() {
#----------------------------#
# Test if the packages must be downloaded
if [ "$HPKG" = "1" ] ; then
# This variable is necessary to make sure the `cat $JHALFSDIR/packages`
2006-03-15 04:04:04 +01:00
# separates each iteration by lines.
# Modify the 'internal field separator' to break on 'LF' only
IFS=$'\x0A'
2006-03-07 21:02:53 +01:00
if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
cd $BUILDDIR/sources
if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
2006-03-14 22:16:52 +01:00
if [ -f MISSING_FILES.DMP ] ; then rm MISSING_FILES.DMP ; fi
2006-03-07 21:02:53 +01:00
download "" MD5SUMS
# Iterate through each package and grab it, along with any patches it needs.
for i in `cat $JHALFSDIR/packages` ; do
PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'`
# There are some entities that aren't valid packages.
2006-03-10 02:44:55 +01:00
if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
2006-03-07 21:02:53 +01:00
VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
2006-03-11 00:35:41 +01:00
case $PKG in
2006-03-28 22:11:42 +02:00
tcl) FILE="$PKG$VRS-src.tar.bz2" ;;
2006-03-07 21:02:53 +01:00
vim-lang) PKG="vim"
FILE="vim-$VRS-lang.tar.bz2" ;;
2006-03-28 22:11:42 +02:00
udev-config) PKG="udev"
2006-03-07 21:02:53 +01:00
FILE="$VRS" ;;
2006-03-28 22:11:42 +02:00
*) FILE="$PKG-$VRS.tar.bz2" ;;
2006-03-07 21:02:53 +01:00
esac
download $PKG $FILE
# Download any associated patches
for patch in `grep "&$PKG-version" $JHALFSDIR/patches` ; do
PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
download $PKG $PATCH
done
done
2006-03-27 23:07:08 +02:00
if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
echo -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n\n"
fi
2006-03-07 21:02:53 +01:00
fi
}