2006-03-07 21:02:53 +01:00
#!/bin/bash
2006-03-11 00:35:41 +01:00
# $Id$
2006-08-26 15:00:37 +02:00
set -e
2006-03-07 21:02:53 +01:00
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
}
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\"`"
2006-08-30 04:01:04 +02:00
#------------------------------------------------------#
# NEW Makefile scripting functions #
#------------------------------------------------------#
2006-03-07 21:02:53 +01:00
2006-08-30 04:01:04 +02:00
unset get_package_tarball_name
2006-07-26 20:42:01 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
get_package_tarball_name() { #
2006-07-26 20:42:01 +02:00
#----------------------------------#
local script_name=$1
# The use of 'head' is necessary to limit the return value to the FIRST match..
# hopefully this will not cause problems.
#
case $script_name in
2006-08-04 22:06:15 +02:00
tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
linux-headers) echo $(grep "^linux-headers.*.bz2" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
*) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
2006-07-26 20:42:01 +02:00
esac
}
2006-08-11 05:34:10 +02:00
2006-08-30 04:01:04 +02:00
unset wrt_RunaAsRoot
2006-06-02 19:53:17 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
wrt_RunAsRoot() { # Some scripts must be run as root..
2006-06-02 19:53:17 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
local ENV_MOUNT
local this_script=$1
local file=$2
2006-08-11 05:34:10 +02:00
2006-08-30 04:01:04 +02:00
case ${PROGNAME} in
lfs ) MOUNT_ENV="LFS" ;;
blfs ) MOUNT_ENV="BLFS" ;;
clfs ) MOUNT_ENV="CLFS" ;;
clfs2 ) MOUNT_ENV="CLFS" ;;
hlfs ) MOUNT_ENV="HLFS" ;;
2006-09-16 19:45:58 +02:00
*) echo "undefined progname $PROGNAME"; exit 1 ;;
2006-08-30 04:01:04 +02:00
esac
2006-09-11 14:17:09 +02:00
2006-08-11 05:34:10 +02:00
(
2006-08-30 04:01:04 +02:00
cat << EOF
@( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
\$(PRT_DU_CR) >>logs/\$@
2006-08-11 05:34:10 +02:00
EOF
) >> $MKFILE.tmp
}
2006-08-30 04:01:04 +02:00
#------------------------------------------------------#
#------------------------------------------------------#
2006-09-02 05:04:03 +02:00
#----------------------------------#
2006-09-11 14:17:09 +02:00
ROOT_RunAsRoot() { #
2006-09-02 05:04:03 +02:00
#----------------------------------#
local file=$1
(
cat << EOF
@( time { source envars && \$(CMDSDIR)/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
\$(PRT_DU_CR) >>logs/$this_script
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
ROOT_Unpack() { # An alias, for clairity
#----------------------------------#
local FILE=$1
local optSAVE_PREVIOUS=$2
if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
(
cat << EOF
@\$(call remove_existing_dirs,$FILE)
EOF
) >> $MKFILE.tmp
fi
(
cat << EOF
@\$(call unpack,$FILE)
@\$(call get_pkg_root_LUSER)
EOF
) >> $MKFILE.tmp
}
#------------------------------------------------------#
#------------------------------------------------------#
2006-08-30 04:01:04 +02:00
2006-08-11 05:34:10 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
LUSER_wrt_target() { # Create target and initialize log file
2006-08-11 05:34:10 +02:00
#----------------------------------#
local i=$1
2006-08-30 04:01:04 +02:00
local PREV=$2
2006-08-11 05:34:10 +02:00
(
2006-08-30 04:01:04 +02:00
cat << EOF
$i: $PREV
@\$(call echo_message, Building)
@./progress_bar.sh \$@ \$\$PPID &
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) \$(MOUNT_PT)\`\n" >logs/\$@
2006-06-02 19:53:17 +02:00
EOF
) >> $MKFILE.tmp
}
2006-08-11 05:34:10 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file
2006-08-11 05:34:10 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
local file=$1
2006-08-11 05:34:10 +02:00
(
cat << EOF
2006-08-30 04:01:04 +02:00
@( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\
\$(PRT_DU) >> logs/\$@
2006-08-11 05:34:10 +02:00
EOF
) >> $MKFILE.tmp
}
2006-08-30 04:01:04 +02:00
2006-03-07 21:02:53 +01:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
2006-03-07 21:02:53 +01:00
#----------------------------------#
local FILE=$1
2006-06-02 19:53:17 +02:00
local optSAVE_PREVIOUS=$2
2006-08-11 05:34:10 +02:00
if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
(
cat << EOF
@\$(call remove_existing_dirs,$FILE)
EOF
) >> $MKFILE.tmp
2006-06-02 19:53:17 +02:00
fi
2006-08-11 05:34:10 +02:00
2006-03-07 21:02:53 +01:00
(
cat << EOF
@\$(call unpack,$FILE)
2006-08-30 04:01:04 +02:00
@\$(call get_pkg_root_LUSER)
2006-07-26 20:42:01 +02:00
EOF
) >> $MKFILE.tmp
2006-08-11 05:34:10 +02:00
}
2006-07-26 20:42:01 +02:00
2006-08-30 04:01:04 +02:00
2006-03-07 21:02:53 +01:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
LUSER_wrt_CopyFstab() { #
2006-03-07 21:02:53 +01:00
#----------------------------------#
2006-08-11 05:34:10 +02:00
(
cat << EOF
2006-08-30 04:01:04 +02:00
@( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
2006-03-07 21:02:53 +01:00
EOF
) >> $MKFILE.tmp
}
2006-08-30 04:01:04 +02:00
2006-05-03 21:35:01 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
LUSER_wrt_test_log() { # Initialize testsuite log file
2006-05-03 21:35:01 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
local TESTLOGFILE=$1
2006-03-07 21:02:53 +01:00
(
cat << EOF
2006-08-30 04:01:04 +02:00
@echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE
2006-03-07 21:02:53 +01:00
EOF
) >> $MKFILE.tmp
}
2006-08-11 05:34:10 +02:00
2006-06-04 19:59:02 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
LUSER_RemoveBuildDirs() { #
2006-06-04 19:59:02 +02:00
#----------------------------------#
2006-08-11 05:34:10 +02:00
local name=$1
2006-06-04 19:59:02 +02:00
(
2006-08-11 05:34:10 +02:00
cat << EOF
@\$(call remove_build_dirs,$name)
2006-06-04 19:59:02 +02:00
EOF
) >> $MKFILE.tmp
}
2006-08-30 04:01:04 +02:00
#-----------------------------------------------------------------#
#-----------------------------------------------------------------#
2006-06-04 19:59:02 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
CHROOT_wrt_target() { # Create target and initialize log file
2006-06-04 19:59:02 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
local i=$1
local PREV=$2
case $i in
iteration* ) local LOGFILE="${this_script}.log" ;;
* ) local LOGFILE="${this_script}" ;;
esac
2006-06-04 19:59:02 +02:00
(
2006-08-11 05:34:10 +02:00
cat << EOF
2006-08-30 04:01:04 +02:00
$i: $PREV
@\$(call echo_message, Building)
@./progress_bar.sh \$@ \$\$PPID &
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) / \`\n" >logs/$LOGFILE
2006-06-04 19:59:02 +02:00
EOF
) >> $MKFILE.tmp
}
2006-08-11 05:34:10 +02:00
2006-03-07 21:02:53 +01:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
CHROOT_Unpack() { #
2006-03-07 21:02:53 +01:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
local FILE=$1
local optSAVE_PREVIOUS=$2
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
2006-03-07 21:02:53 +01:00
(
2006-08-11 05:34:10 +02:00
cat << EOF
2006-08-30 04:01:04 +02:00
@\$(call remove_existing_dirs2,$FILE)
2006-03-07 21:02:53 +01:00
EOF
) >> $MKFILE.tmp
2006-08-30 04:01:04 +02:00
fi
2006-03-07 21:02:53 +01:00
(
2006-08-30 04:01:04 +02:00
cat << EOF
@\$(call unpack3,$FILE)
@\$(call get_pkg_root2)
2006-03-07 21:02:53 +01:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2006-08-30 04:01:04 +02:00
CHROOT_wrt_test_log() { #
2006-03-07 21:02:53 +01:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
local TESTLOGFILE=$1
2006-07-26 20:42:01 +02:00
(
2006-08-30 04:01:04 +02:00
cat << EOF
@echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\
echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE
2006-07-26 20:42:01 +02:00
EOF
) >> $MKFILE.tmp
}
2006-08-30 04:01:04 +02:00
2006-05-03 21:35:01 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
CHROOT_wrt_RunAsRoot() { #
2006-05-03 21:35:01 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
local file=$1
2006-03-07 21:02:53 +01:00
(
cat << EOF
2006-08-30 04:01:04 +02:00
@( time { source envars && \$(crCMDSDIR)/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
\$(PRT_DU_CR) >>logs/$this_script
2006-03-07 21:02:53 +01:00
EOF
) >> $MKFILE.tmp
2006-08-30 04:01:04 +02:00
2006-03-07 21:02:53 +01:00
}
#----------------------------------#
2006-08-30 04:01:04 +02:00
CHROOT_wrt_CopyFstab() { #
2006-03-07 21:02:53 +01:00
#----------------------------------#
(
2006-08-11 05:34:10 +02:00
cat << EOF
2006-08-30 04:01:04 +02:00
@( time { cp -v /sources/fstab /etc/fstab >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
2006-03-07 21:02:53 +01:00
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
2006-08-30 04:01:04 +02:00
CHROOT_wrt_RemoveBuildDirs() { #
2006-03-07 21:02:53 +01:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
local name=$1
2006-04-24 18:41:29 +02:00
(
cat << EOF
2006-08-30 04:01:04 +02:00
@\$(call remove_build_dirs2,$name)
2006-06-10 18:48:25 +02:00
EOF
) >> $MKFILE.tmp
}
2006-08-30 04:01:04 +02:00
unset wrt_touch
2006-04-26 22:24:58 +02:00
#----------------------------------#
2006-08-30 04:01:04 +02:00
wrt_touch() { #
2006-04-26 22:24:58 +02:00
#----------------------------------#
(
cat << EOF
2006-08-30 04:01:04 +02:00
@\$(call housekeeping)
2006-04-26 22:24:58 +02:00
EOF
) >> $MKFILE.tmp
}
2006-08-30 04:01:04 +02:00
#------------------------------------------------------#
# END Makefile scripting functions #
#------------------------------------------------------#
2006-04-26 22:24:58 +02:00
2006-08-11 05:34:10 +02:00
2006-03-07 21:02:53 +01:00
#----------------------------#
2006-05-03 21:35:01 +02:00
run_make() { #
2006-03-07 21:02:53 +01:00
#----------------------------#
# Test if make must be run.
2006-08-12 21:59:11 +02:00
if [ "$RUNMAKE" = "y" ] ; then
2006-03-07 21:02:53 +01:00
# Test to make sure we're running the build as root
2006-09-16 19:45:58 +02:00
if [ "$UID" = "0" ] ; then
2006-09-13 22:04:46 +02:00
echo "You must not be logged in as root to 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
}
#----------------------------#
2006-05-03 21:35:01 +02:00
clean_builddir() { #
2006-03-07 21:02:53 +01:00
#----------------------------#
# Test if the clean must be done.
2006-08-12 21:59:11 +02:00
if [ "${CLEAN}" = "y" ]; then
2006-03-07 21:02:53 +01:00
# 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-07-26 20:42:01 +02:00
rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,*logs,Makefile,*.xsl,makefile-functions,pkg_tarball_list,*.config,*.sh}
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
}
#----------------------------#
2006-05-03 21:35:01 +02:00
get_book() { #
2006-03-07 21:02:53 +01:00
#----------------------------#
cd $JHALFSDIR
2006-08-26 21:18:15 +02:00
if [ -z $WORKING_COPY ] ; then
2006-03-07 21:02:53 +01:00
# 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" ;;
2006-07-26 20:42:01 +02:00
clfs2) svn_root="cross-lfs" ;;
2006-03-07 21:02:53 +01:00
*) 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
2006-07-26 20:42:01 +02:00
if LC_ALL=C svn up | grep -q At && \
test -d $JHALFSDIR/${PROGNAME}-commands && \
test -f $JHALFSDIR/pkg_tarball_list ; then
2006-03-07 21:02:53 +01:00
# Set the canonical book version
2006-07-26 20:42:01 +02:00
echo -ne "done\n"
2006-03-07 21:02:53 +01:00
cd $JHALFSDIR
2006-07-26 20:42:01 +02:00
case $PROGNAME in
clfs | clfs2)
VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
*)
VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
esac
2006-03-07 21:02:53 +01:00
get_sources
else
echo -ne "done\n"
extract_commands
fi
else
2006-07-26 20:42:01 +02:00
svn co $SVN/${svn_root}/${TREE} ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
2006-03-07 21:02:53 +01:00
echo -ne "done\n"
extract_commands
fi
2006-07-26 20:42:01 +02:00
2006-03-07 21:02:53 +01:00
else
echo -ne "Using $BOOK as book's sources ...\n"
extract_commands
fi
2006-07-26 20:42:01 +02:00
echo -ne " Document version ${L_arrow}${BOLD}${VERSION}${R_arrow}\n"
2006-03-07 21:02:53 +01:00
}
#----------------------------#
extract_commands() { #
#----------------------------#
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
2006-07-26 20:42:01 +02:00
case $PROGNAME in
clfs | clfs2 )
VERSION=$(xmllint --noent $BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
*)
VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
esac
2006-03-07 21:02:53 +01:00
# 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 \
2006-08-05 17:42:52 +02:00
--stringparam bomb-testsuite $BOMB_TEST \
2006-03-22 23:52:32 +01:00
--stringparam vim-lang $VIMLANG \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
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
;;
2006-07-26 20:42:01 +02:00
clfs2)
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
xsltproc --nonet \
--xinclude \
--stringparam vim-lang $VIMLANG \
--stringparam timezone $TIMEZONE \
--stringparam page $PAGE \
--stringparam lang $LANG \
-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 \
2006-08-05 17:42:52 +02:00
--stringparam bomb-testsuite $BOMB_TEST \
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 \
--stringparam lc_all $LC_ALL \
2006-03-19 13:44:32 +01:00
--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 \
2006-08-05 17:42:52 +02:00
--stringparam bomb-testsuite $BOMB_TEST \
2006-03-07 21:02:53 +01:00
--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
;;
2006-05-01 13:10:53 +02:00
*) exit 1 ;;
2006-03-07 21:02:53 +01:00
esac
2006-03-11 00:35:41 +01:00
2006-08-28 23:41:49 +02:00
[[ "${BLFS_TOOL}" = "y" ]] && copy_blfs_deps_scripts
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
2006-05-01 13:10:53 +02:00
# Create the packages file. We need it for proper Makefile creation
2006-07-26 20:42:01 +02:00
create_package_list
2006-03-07 21:02:53 +01:00
# Done. Moving on...
get_sources
2006-08-30 04:01:04 +02:00
2006-03-07 21:02:53 +01:00
}
2006-07-26 20:42:01 +02:00
#----------------------------#
create_package_list() { #
#----------------------------#
# Create the packages file. We need it for proper Makefile creation
rm -f pkg_tarball_list
echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK $ARCH"
case ${PROGNAME} in
clfs | clfs2)
xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
$BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
;;
hlfs)
xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
$BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
;;
lfs)
xsltproc --nonet --xinclude -o pkg_tarball_list packages.xsl \
$BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
;;
esac
2006-08-28 21:16:58 +02:00
if [[ "${BLFS_TOOL}" = "y" ]] ; then
(
cat << EOF
2006-08-28 22:19:23 +02:00
$LIBXML_PKG
$LIBXSLT_PKG
2006-09-17 13:40:37 +02:00
$TIDY_PKG
$UNZIP_PKG
$DBXML_PKG
2006-08-28 22:19:23 +02:00
$DBXSL_PKG
$LINKS_PKG
$SUDO_PKG
$WGET_PKG
$SVN_PKG
$GPM_PKG
2006-08-28 21:16:58 +02:00
EOF
) >> pkg_tarball_list
fi
2006-07-26 20:42:01 +02:00
echo " ...OK"
}
2006-03-07 21:02:53 +01:00
#----------------------------#
2006-05-01 13:10:53 +02:00
get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
2006-03-07 21:02:53 +01:00
#----------------------------#
2006-05-01 13:10:53 +02:00
local saveIFS=$IFS
2006-05-06 22:04:45 +02:00
local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
2006-05-03 21:35:01 +02:00
# Test if the packages must be downloaded
2006-08-12 21:59:11 +02:00
[ ! "$GETPKG" = "y" ] && return
2006-05-03 21:35:01 +02:00
gs_wrt_message(){
echo "${RED}$1${OFF}"
echo "$1" >> MISSING_FILES.DMP
}
# 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
2006-08-17 10:19:41 +02:00
2006-05-01 13:10:53 +02:00
# Generate URLs file
2006-05-03 21:35:01 +02:00
create_urls
2006-05-01 13:10:53 +02:00
2006-05-03 21:35:01 +02:00
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
2006-05-01 13:10:53 +02:00
# Skip some packages if they aren't needed
2006-05-03 21:35:01 +02:00
case $line in
2006-05-01 13:10:53 +02:00
*/tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
[[ "$TEST" = "0" ]] && continue
;;
*/vim-*-lang* )
[[ "$VIMLANG" = "0" ]] && continue
;;
2006-05-16 20:27:02 +02:00
*linux/linux-* )
2006-05-27 20:45:16 +02:00
[[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
2006-08-12 21:59:11 +02:00
[[ "$GETKERNEL" = "n" ]] && continue
2006-05-16 20:27:02 +02:00
;;
2006-05-03 21:35:01 +02:00
esac
2006-05-01 13:10:53 +02:00
2006-05-03 21:35:01 +02:00
# Locations
URL1=`echo $line | cut -d" " -f2` # Preferred URL
URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
2006-05-06 22:04:45 +02:00
FILE=`basename $URL1` # File name
BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
2006-05-16 20:27:02 +02:00
# Validation pair
MD5="$BOOKMD5 $FILE"
HAVEMD5=1
2006-03-07 21:02:53 +01:00
2006-05-03 21:35:01 +02:00
set -e
# If the file exists in the archive copy it to the
# $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-16 20:27:02 +02:00
# If the file does not exist yet in /sources download a fresh one
2006-05-01 13:10:53 +02:00
if [ ! -f $FILE ] ; then
2006-05-03 21:35:01 +02:00
if ! wget $URL1 && ! wget $URL2 ; then
gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
continue
fi
2006-05-01 13:10:53 +02:00
fi
2006-05-03 21:35:01 +02:00
fi
2006-03-07 21:02:53 +01:00
2006-05-16 20:27:02 +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-01 13:10:53 +02:00
fi
2006-05-03 21:35:01 +02:00
fi
2006-03-15 22:50:40 +01:00
2006-05-03 21:35:01 +02:00
# Validate the MD5SUM one last time
2006-05-16 20:27:02 +02:00
if ! echo "$MD5" | md5sum -c - >/dev/null ; then
2006-05-03 21:35:01 +02:00
gs_wrt_message "$FILE does not match MD5SUMS value"
2006-05-09 22:22:28 +02:00
# Force generation of MD5SUM
HAVEMD5=0
2006-05-03 21:35:01 +02:00
fi
2006-05-01 13:10:53 +02:00
2006-05-03 21:35:01 +02:00
# Generate a fresh MD5SUM for this file
if [[ "$HAVEMD5" = "0" ]] ; then
echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
2006-05-16 20:27:02 +02:00
echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
2006-05-01 13:10:53 +02:00
fi
2006-03-15 22:50:40 +01:00
2006-05-03 21:35:01 +02:00
# Good or bad we write the original md5sum to a file
2006-05-16 20:27:02 +02:00
echo "$MD5" >> MD5SUMS
2006-05-03 21:35:01 +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
2006-07-26 20:42:01 +02:00
echo -e "\n\n${tab_}${RED} One or more files were not retrieved or have bad MD5SUMS.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n"
# Do not allow the automatic execution of the Makefile.
2006-05-03 21:35:01 +02:00
echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
2006-08-12 21:59:11 +02:00
RUNMAKE="n"
2006-05-01 13:10:53 +02:00
fi
2006-03-07 21:02:53 +01:00
}
#----------------------------#
2006-05-01 13:10:53 +02:00
create_urls() { #
2006-03-07 21:02:53 +01:00
#----------------------------#
2006-05-01 13:10:53 +02:00
cd $JHALFSDIR
2006-03-07 21:02:53 +01:00
2006-05-01 13:10:53 +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"
;;
2006-07-26 20:42:01 +02:00
clfs2)
echo -n "Creating CLFS2 <${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"
;;
2006-05-01 13:10:53 +02:00
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-03-07 21:02:53 +01:00
2006-05-01 13:10:53 +02:00
cd $BUILDDIR/sources
2006-08-28 20:32:08 +02:00
2006-08-30 01:36:40 +02:00
if [[ "${BLFS_TOOL}" = "y" ]]; then
2006-09-11 14:17:09 +02:00
add_blfs_deps_urls
2006-08-30 01:36:40 +02:00
fi
2006-08-30 04:01:04 +02:00
2006-08-28 20:32:08 +02:00
}
#----------------------------# Hardcoded URLs and MD5.
add_blfs_deps_urls() { # No easy way to extract it.
#----------------------------# Some FTP mirrors may not work
local BLFS_SERVER="${SERVER}/pub/blfs/conglomeration/"
if [[ "${DEP_LIBXML}" = "y" ]] ; then
2006-08-28 22:19:23 +02:00
echo "${LIBXML_URL} ${BLFS_SERVER}libxml2/${LIBXML_PKG} ${LIBXML_MD5}" >> urls.lst
2006-08-28 20:32:08 +02:00
fi
if [[ "${DEP_LIBXSLT}" = "y" ]] ; then
2006-08-28 22:19:23 +02:00
echo "${LIBXSLT_URL} ${BLFS_SERVER}libxslt/${LIBXSLT_PKG} ${LIBXSLT_MD5}" >> urls.lst
2006-08-28 20:32:08 +02:00
fi
2006-09-17 13:40:37 +02:00
if [[ "${DEP_TIDY}" = "y" ]] ; then
echo "${TIDY_URL} ${BLFS_SERVER}tidy/${TIDY_PKG} ${TIDY_MD5}" >> urls.lst
echo "${TIDY_PATCH_URL} ${BLFS_SERVER}tidy/${TIDY_PATCH} ${TIDY_PATCH_MD5}" >> urls.lst
fi
if [[ "${DEP_UNZIP}" = "y" ]] ; then
echo "${UNZIP_URL} ${BLFS_SERVER}unzip/${UNZIP_PKG} ${UNZIP_MD5}" >> urls.lst
fi
if [[ "${DEP_DBXML}" = "y" ]] ; then
2006-09-17 14:12:27 +02:00
echo "${DBXML_URL} ${BLFS_SERVER}docbook-xml/${DBXML_PKG} ${DBXML_MD5}" >> urls.lst
2006-09-17 13:40:37 +02:00
fi
2006-08-28 20:32:08 +02:00
if [[ "${DEP_DBXSL}" = "y" ]] ; then
2006-08-28 22:19:23 +02:00
echo "${DBXSL_URL} ${BLFS_SERVER}docbook-xsl/${DBXSL_PKG} ${DBXSL_MD5}" >> urls.lst
2006-08-28 20:32:08 +02:00
fi
2006-08-28 22:19:23 +02:00
if [[ "${DEP_LINKS}" = "y" ]] ; then
echo "${LINKS_URL} ${BLFS_SERVER}links/${LINKS_PKG} ${LINKS_MD5}" >> urls.lst
2006-08-28 20:32:08 +02:00
fi
if [[ "${DEP_SUDO}" = "y" ]] ; then
2006-08-28 22:19:23 +02:00
echo "${SUDO_URL} ${BLFS_SERVER}sudo/${SUDO_PKG} ${SUDO_MD5}" >> urls.lst
2006-08-28 23:41:49 +02:00
echo "${SUDO_PATCH_URL} ${BLFS_SERVER}sudo/${SUDO_PATCH} ${SUDO_PATCH_MD5}" >> urls.lst
2006-08-28 20:32:08 +02:00
fi
if [[ "${DEP_WGET}" = "y" ]] ; then
2006-08-28 22:19:23 +02:00
echo "${WGET_URL} ${BLFS_SERVER}wget/${WGET_PKG} ${WGET_MD5}" >> urls.lst
2006-08-28 20:32:08 +02:00
fi
if [[ "${DEP_SVN}" = "y" ]] ; then
2006-08-28 22:19:23 +02:00
echo "${SVN_URL} ${BLFS_SERVER}subversion/${SVN_PKG} ${SVN_MD5}" >> urls.lst
2006-08-28 20:32:08 +02:00
fi
if [[ "${DEP_GPM}" = "y" ]] ; then
2006-08-28 22:19:23 +02:00
echo "${GPM_URL} ${BLFS_SERVER}gpm/${GPM_PKG} ${GPM_MD5}" >> urls.lst
2006-08-28 23:41:49 +02:00
echo "${GPM_PATCH_1_URL} ${BLFS_SERVER}gpm/${GPM_PATCH_1} ${GPM_PATCH_1_MD5}" >> urls.lst
echo "${GPM_PATCH_2_URL} ${BLFS_SERVER}gpm/${GPM_PATCH_2} ${GPM_PATCH_2_MD5}" >> urls.lst
2006-08-28 20:32:08 +02:00
fi
2006-03-07 21:02:53 +01:00
}
2006-08-28 23:41:49 +02:00
#----------------------------# Maybe there is a better way to do this, but this
copy_blfs_deps_scripts() { # method avoid to place the test on all
#----------------------------# $PROGNAME/master.sh scripts.
mkdir -p ${PROGNAME}-commands/blfs-tool-deps
if [[ "${DEP_LIBXML}" = "y" ]] ; then
mv blfs-tool-deps/901-libxml2 ${PROGNAME}-commands/blfs-tool-deps
fi
if [[ "${DEP_LIBXSLT}" = "y" ]] ; then
mv blfs-tool-deps/902-libxslt ${PROGNAME}-commands/blfs-tool-deps
fi
2006-09-17 14:12:27 +02:00
if [[ "${DEP_TIDY}" = "y" ]] ; then
mv blfs-tool-deps/903-tidy ${PROGNAME}-commands/blfs-tool-deps
fi
if [[ "${DEP_UNZIP}" = "y" ]] ; then
mv blfs-tool-deps/904-unzip ${PROGNAME}-commands/blfs-tool-deps
fi
if [[ "${DEP_DBXML}" = "y" ]] ; then
mv blfs-tool-deps/905-docbook-xml ${PROGNAME}-commands/blfs-tool-deps
fi
2006-08-28 23:41:49 +02:00
if [[ "${DEP_DBXSL}" = "y" ]] ; then
2006-09-17 13:40:37 +02:00
mv blfs-tool-deps/906-docbook-xsl ${PROGNAME}-commands/blfs-tool-deps
2006-08-28 23:41:49 +02:00
fi
if [[ "${DEP_LINKS}" = "y" ]] ; then
2006-09-17 13:40:37 +02:00
mv blfs-tool-deps/908-links ${PROGNAME}-commands/blfs-tool-deps
2006-08-28 23:41:49 +02:00
fi
if [[ "${DEP_SUDO}" = "y" ]] ; then
2006-09-17 13:40:37 +02:00
mv blfs-tool-deps/909-sudo ${PROGNAME}-commands/blfs-tool-deps
2006-08-28 23:41:49 +02:00
fi
if [[ "${DEP_WGET}" = "y" ]] ; then
2006-09-17 13:40:37 +02:00
mv blfs-tool-deps/910-wget ${PROGNAME}-commands/blfs-tool-deps
2006-08-28 23:41:49 +02:00
fi
if [[ "${DEP_SVN}" = "y" ]] ; then
2006-09-17 13:40:37 +02:00
mv blfs-tool-deps/911-subversion ${PROGNAME}-commands/blfs-tool-deps
2006-08-28 23:41:49 +02:00
fi
if [[ "${DEP_GPM}" = "y" ]] ; then
2006-09-17 13:40:37 +02:00
mv blfs-tool-deps/907-gpm ${PROGNAME}-commands/blfs-tool-deps
2006-08-28 23:41:49 +02:00
fi
rm -rf blfs-tool-deps
2006-08-28 23:48:58 +02:00
}