2006-11-11 20:06:46 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
get_book() { #
|
|
|
|
#----------------------------#
|
|
|
|
cd $JHALFSDIR
|
|
|
|
|
2022-03-30 14:26:41 +02:00
|
|
|
if [ -z "$WORKING_COPY" ] ; then
|
2017-04-01 13:05:15 +02:00
|
|
|
# Check for Subversion or git instead of just letting the script fail.
|
2021-04-30 14:21:44 +02:00
|
|
|
test `type -p git` || eval "echo \"This feature requires Git.\"
|
|
|
|
exit 1"
|
2017-04-01 13:05:15 +02:00
|
|
|
|
2022-03-30 14:26:41 +02:00
|
|
|
echo -n "Downloading the lfs document, $COMMIT commit... "
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
# 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.
|
2022-03-30 14:26:41 +02:00
|
|
|
if [ ! -d "$BOOK"/.git ]; then
|
|
|
|
git clone "$REPO" "$BOOK" >>"$LOGDIR/$LOG" 2>&1
|
|
|
|
if [ "$COMMIT" != trunk ]; then
|
|
|
|
pushd "$BOOK" >/dev/null
|
|
|
|
echo "Checking out $COMMIT at $PWD"
|
|
|
|
git checkout "$COMMIT" >>"$LOGDIR/$LOG" 2>&1
|
|
|
|
popd >/dev/null
|
2013-09-14 12:13:04 +02:00
|
|
|
fi
|
2013-04-04 23:13:02 +02:00
|
|
|
else
|
2022-03-30 14:26:41 +02:00
|
|
|
cd "$BOOK"
|
2021-04-30 14:21:44 +02:00
|
|
|
# If the repo is in "detached head" state, git pull fails, so get
|
2022-03-30 14:26:41 +02:00
|
|
|
# back first to trunk:
|
|
|
|
git checkout trunk >>"$LOGDIR/$LOG" 2>&1
|
|
|
|
git pull >>"$LOGDIR/$LOG" 2>&1
|
|
|
|
if [ "$COMMIT" != "trunk" ]; then
|
|
|
|
git checkout "$COMMIT" >>"$LOGDIR/$LOG" 2>&1
|
2021-04-30 14:21:44 +02:00
|
|
|
fi
|
2006-11-11 20:06:46 +01:00
|
|
|
fi
|
2013-04-04 23:13:02 +02:00
|
|
|
echo -ne "done\n"
|
2006-11-11 20:06:46 +01:00
|
|
|
|
2017-04-01 13:05:15 +02:00
|
|
|
else # Working copy
|
2006-11-11 20:06:46 +01:00
|
|
|
echo -ne "Using $BOOK as book's sources ...\n"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
extract_commands() { #
|
|
|
|
#----------------------------#
|
|
|
|
|
|
|
|
cd $JHALFSDIR
|
2014-01-12 22:40:20 +01:00
|
|
|
# Clean
|
|
|
|
rm -rf ${PROGNAME}-commands
|
2006-11-11 20:06:46 +01:00
|
|
|
|
2014-01-12 22:40:20 +01:00
|
|
|
# Extract the commands
|
|
|
|
echo -n "Extracting commands for"
|
2006-11-11 20:06:46 +01:00
|
|
|
case ${PROGNAME} in
|
|
|
|
|
|
|
|
lfs)
|
2007-03-21 03:34:14 +01:00
|
|
|
echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
|
2020-06-20 19:16:22 +02:00
|
|
|
# The scripts pages are xincluded by the book, so must
|
|
|
|
# be generated for running xsltproc
|
2012-02-21 09:58:49 +01:00
|
|
|
pushd $BOOK > /dev/null
|
2013-03-03 13:33:25 +01:00
|
|
|
if [ -f process-scripts.sh ]; then
|
2013-03-02 15:10:45 +01:00
|
|
|
bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
|
|
|
|
fi
|
2021-08-03 14:33:11 +02:00
|
|
|
# Recent git versions need version.ent to be generated
|
|
|
|
if [ -f git-version.sh ]; then
|
2021-10-14 10:23:24 +02:00
|
|
|
bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
|
2021-08-03 14:33:11 +02:00
|
|
|
fi
|
2012-02-21 09:58:49 +01:00
|
|
|
popd > /dev/null
|
2016-05-28 12:00:30 +02:00
|
|
|
|
2020-06-20 19:16:22 +02:00
|
|
|
# First profile the book, for revision and arch. Note that
|
|
|
|
# MULTIBLIB is set to "default" if pure 64 bit book. In this
|
|
|
|
# profiling on arch is useless, but does not hurt either.
|
2017-06-29 16:10:30 +02:00
|
|
|
xsltproc --nonet \
|
|
|
|
--xinclude \
|
2020-06-20 19:16:22 +02:00
|
|
|
--stringparam profile.revision "$INITSYS" \
|
|
|
|
--stringparam profile.arch "$MULTILIB" \
|
|
|
|
--output prbook.xml \
|
|
|
|
$BOOK/stylesheets/lfs-xsl/profile.xsl \
|
|
|
|
$BOOK/index.xml >> $LOGDIR/$LOG 2>&1
|
|
|
|
|
|
|
|
# Use the profiled book for generating the scriptlets
|
|
|
|
xsltproc --nonet \
|
2017-06-29 16:10:30 +02:00
|
|
|
--stringparam testsuite "$TEST" \
|
|
|
|
--stringparam bomb-testsuite "$BOMB_TEST" \
|
2019-09-05 19:22:04 +02:00
|
|
|
--stringparam ncurses5 "$NCURSES5" \
|
2018-01-12 20:04:19 +01:00
|
|
|
--stringparam strip "$STRIP" \
|
|
|
|
--stringparam del-la-files "$DEL_LA_FILES" \
|
2017-06-29 16:10:30 +02:00
|
|
|
--stringparam full-locale "$FULL_LOCALE" \
|
|
|
|
--stringparam timezone "$TIMEZONE" \
|
|
|
|
--stringparam page "$PAGE" \
|
|
|
|
--stringparam lang "$LANG" \
|
|
|
|
--stringparam pkgmngt "$PKGMNGT" \
|
|
|
|
--stringparam wrap-install "$WRAP_INSTALL" \
|
|
|
|
--stringparam hostname "$HOSTNAME" \
|
|
|
|
--stringparam interface "$INTERFACE" \
|
|
|
|
--stringparam ip "$IP_ADDR" \
|
|
|
|
--stringparam gateway "$GATEWAY" \
|
|
|
|
--stringparam prefix "$PREFIX" \
|
|
|
|
--stringparam broadcast "$BROADCAST" \
|
|
|
|
--stringparam domain "$DOMAIN" \
|
|
|
|
--stringparam nameserver1 "$DNS1" \
|
|
|
|
--stringparam nameserver2 "$DNS2" \
|
2019-03-09 09:11:37 +01:00
|
|
|
--stringparam font "$FONT" \
|
|
|
|
--stringparam fontmap "$FONTMAP" \
|
|
|
|
--stringparam unicode "$UNICODE" \
|
|
|
|
--stringparam keymap "$KEYMAP" \
|
|
|
|
--stringparam local "$LOCAL" \
|
|
|
|
--stringparam log-level "$LOG_LEVEL" \
|
2019-04-11 09:40:50 +02:00
|
|
|
--stringparam script-root "$SCRIPT_ROOT" \
|
2017-06-29 16:10:30 +02:00
|
|
|
--output ./${PROGNAME}-commands/ \
|
|
|
|
$XSL \
|
2020-06-20 19:16:22 +02:00
|
|
|
prbook.xml >> $LOGDIR/$LOG 2>&1
|
2019-01-02 21:57:01 +01:00
|
|
|
# Remove flags requesting user action in some cases. Much easier here than
|
|
|
|
# in the stylesheet...
|
2020-06-10 22:01:17 +02:00
|
|
|
sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
|
2006-11-11 20:06:46 +01:00
|
|
|
;;
|
2014-01-12 22:40:20 +01:00
|
|
|
*) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
|
2006-11-11 20:06:46 +01:00
|
|
|
exit 1 ;;
|
|
|
|
esac
|
|
|
|
|
2007-03-21 03:34:14 +01:00
|
|
|
echo "done"
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
# Make the scripts executable.
|
|
|
|
chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
|
|
|
|
|
|
|
# Create the packages file. We need it for proper Makefile creation
|
2021-09-16 06:30:58 +02:00
|
|
|
# lfs does not use this anymore, but this is taken care in the
|
|
|
|
# function body
|
2006-11-11 20:06:46 +01:00
|
|
|
create_package_list
|
2020-06-20 19:01:23 +02:00
|
|
|
# On the other hand, lfs needs two auxiliary files
|
2019-03-13 07:31:55 +01:00
|
|
|
if [ "${PROGNAME}" = lfs ]; then
|
|
|
|
create_chroot_scripts
|
|
|
|
create_kernfs_scripts
|
|
|
|
fi
|
2006-11-11 20:06:46 +01:00
|
|
|
|
2021-09-16 06:30:58 +02:00
|
|
|
# we create the VERSION variable here. Should maybe go into its own
|
|
|
|
# function. But at this point we can use the profiled xml to get
|
|
|
|
# version from lfs-release in the lfs case.
|
|
|
|
case $PROGNAME in
|
|
|
|
lfs)
|
|
|
|
VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
VERSION=$(xmllint --noent $BOOK/prologue/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
|
|
|
|
esac
|
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
# Done. Moving on...
|
|
|
|
get_sources
|
|
|
|
}
|
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
create_package_list() { #
|
|
|
|
#----------------------------#
|
|
|
|
|
|
|
|
# Create the packages file. We need it for proper Makefile creation
|
|
|
|
rm -f pkg_tarball_list
|
2007-03-21 03:34:14 +01:00
|
|
|
echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
|
2020-06-20 19:01:23 +02:00
|
|
|
if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
|
2007-03-21 03:34:14 +01:00
|
|
|
echo -n "... "
|
2006-11-11 20:06:46 +01:00
|
|
|
case ${PROGNAME} in
|
|
|
|
lfs)
|
2020-06-20 19:01:23 +02:00
|
|
|
# lfs does not use the package list anymore
|
2006-11-11 20:06:46 +01:00
|
|
|
;;
|
2013-09-14 12:13:04 +02:00
|
|
|
*)
|
2006-11-11 20:06:46 +01:00
|
|
|
esac
|
|
|
|
|
2007-03-21 03:34:14 +01:00
|
|
|
echo "done"
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-01-12 22:40:20 +01:00
|
|
|
#----------------------------#
|
2019-03-13 07:31:55 +01:00
|
|
|
create_chroot_scripts() { #
|
2014-01-12 22:40:20 +01:00
|
|
|
#----------------------------#
|
|
|
|
|
2019-03-13 07:31:55 +01:00
|
|
|
rm -rf chroot-scripts
|
2014-01-12 22:40:20 +01:00
|
|
|
echo -n "Creating chroot commands scripts from $BOOK"
|
|
|
|
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
|
|
|
echo -n "... "
|
|
|
|
case ${PROGNAME} in
|
|
|
|
lfs)
|
|
|
|
xsltproc --nonet --xinclude \
|
|
|
|
-o chroot-scripts/ chroot.xsl \
|
2020-03-29 19:19:25 +02:00
|
|
|
$BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
|
2014-01-12 22:40:20 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
esac
|
|
|
|
echo "done"
|
|
|
|
|
|
|
|
}
|
2019-03-13 07:31:55 +01:00
|
|
|
|
|
|
|
#----------------------------#
|
|
|
|
create_kernfs_scripts() { #
|
|
|
|
#----------------------------#
|
|
|
|
|
|
|
|
rm -rf kernfs-scripts
|
|
|
|
mkdir kernfs-scripts
|
|
|
|
echo -n "Creating virtual kernel FS commands scripts from $BOOK"
|
|
|
|
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
|
|
|
|
echo -n "... "
|
|
|
|
case ${PROGNAME} in
|
|
|
|
lfs)
|
|
|
|
xsltproc --nonet \
|
|
|
|
-o kernfs-scripts/devices.sh kernfs.xsl \
|
2020-03-29 19:19:25 +02:00
|
|
|
$BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
|
2019-03-13 07:31:55 +01:00
|
|
|
xsltproc --nonet \
|
|
|
|
-o kernfs-scripts/teardown.sh kernfs.xsl \
|
2020-06-10 22:01:17 +02:00
|
|
|
$BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
|
2019-03-13 07:31:55 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
esac
|
|
|
|
echo "done"
|
|
|
|
|
|
|
|
}
|