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-04-01 10:13:55 +02:00
|
|
|
echo -n "Downloading the lfs document, branch/tag/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
|
2022-03-30 14:49:43 +02:00
|
|
|
rm -rf "$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"
|
2022-03-30 17:45:35 +02:00
|
|
|
echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build... "
|
|
|
|
# The scripts pages are xincluded by the book, so must
|
|
|
|
# be generated for running xsltproc
|
|
|
|
pushd $BOOK > /dev/null
|
|
|
|
if [ -f process-scripts.sh ]; then
|
|
|
|
bash process-scripts.sh >> $LOGDIR/$LOG 2>&1
|
|
|
|
fi
|
|
|
|
# Recent git versions need version.ent to be generated
|
|
|
|
if [ -f git-version.sh ]; then
|
|
|
|
bash git-version.sh "$INITSYS" >> $LOGDIR/$LOG 2>&1
|
|
|
|
fi
|
|
|
|
popd > /dev/null
|
|
|
|
|
2023-11-15 18:10:07 +01:00
|
|
|
if [ "$ALL_CORES" = "y" ]; then
|
|
|
|
JOBS="\$(nproc)"
|
|
|
|
else
|
|
|
|
JOBS="$N_PARALLEL"
|
2023-09-11 08:38:15 +02:00
|
|
|
|
2023-11-15 18:10:07 +01:00
|
|
|
fi
|
2022-03-30 17:45:35 +02:00
|
|
|
# First profile the book, for revision and arch. Note that
|
|
|
|
# MULTIBLIB is set to "default" if pure 64 bit book. In this case,
|
|
|
|
# profiling on arch is useless, but does not hurt either.
|
|
|
|
xsltproc --nonet \
|
|
|
|
--xinclude \
|
|
|
|
--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 \
|
|
|
|
--stringparam testsuite "$TEST" \
|
|
|
|
--stringparam ncurses5 "$NCURSES5" \
|
|
|
|
--stringparam strip "$STRIP" \
|
|
|
|
--stringparam del-la-files "$DEL_LA_FILES" \
|
|
|
|
--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" \
|
|
|
|
--stringparam font "$FONT" \
|
|
|
|
--stringparam fontmap "$FONTMAP" \
|
|
|
|
--stringparam unicode "$UNICODE" \
|
|
|
|
--stringparam keymap "$KEYMAP" \
|
|
|
|
--stringparam local "$LOCAL" \
|
|
|
|
--stringparam log-level "$LOG_LEVEL" \
|
|
|
|
--stringparam script-root "$SCRIPT_ROOT" \
|
2023-11-15 18:10:07 +01:00
|
|
|
--stringparam jobs "$JOBS" \
|
2022-03-30 17:45:35 +02:00
|
|
|
--output "./${COMMANDS}/" \
|
|
|
|
$XSL \
|
|
|
|
prbook.xml >> $LOGDIR/$LOG 2>&1
|
|
|
|
# Remove flags requesting user action in some cases. Much easier here than
|
|
|
|
# in the stylesheet...
|
|
|
|
sed -i 's/-iv /-v /' "./${COMMANDS}/"chapter??/*kernel*
|
2022-06-12 22:54:14 +02:00
|
|
|
# If doing a destdir install (PM without wrap), the gcc instructions
|
|
|
|
# fail for two reasons: a missing dir, and gcc -dumpmachine returns a
|
|
|
|
# wrong string.
|
|
|
|
if [ "$PKGMNGT" = y ] && [ "$WRAP_INSTALL" = n ]; then
|
|
|
|
sed -e 's|(gcc|&/xgcc|' \
|
|
|
|
-e '/lto_plug/imkdir -pv $PKG_DEST/usr/lib/bfd-plugins' \
|
|
|
|
-i ./${COMMANDS}/chapter08/*gcc
|
|
|
|
fi
|
2007-03-21 03:34:14 +01:00
|
|
|
echo "done"
|
2006-11-11 20:06:46 +01:00
|
|
|
|
|
|
|
# Make the scripts executable.
|
2022-03-30 14:49:43 +02:00
|
|
|
chmod -R +x "$JHALFSDIR/${COMMANDS}"
|
2022-03-30 17:45:35 +02:00
|
|
|
create_chroot_scripts
|
|
|
|
create_kernfs_scripts
|
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.
|
2022-03-30 17:45:35 +02:00
|
|
|
VERSION=$(grep 'echo.*lfs-release' prbook.xml | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
|
2021-09-16 06:30:58 +02:00
|
|
|
|
2006-11-11 20:06:46 +01:00
|
|
|
# Done. Moving on...
|
|
|
|
get_sources
|
|
|
|
}
|
|
|
|
|
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 "... "
|
2022-03-30 17:45:35 +02:00
|
|
|
xsltproc --nonet --xinclude \
|
2023-09-11 08:38:15 +02:00
|
|
|
--stringparam jobs_2 "$JOBS_2" \
|
|
|
|
-o chroot-scripts/ chroot.xsl \
|
2022-03-30 17:45:35 +02:00
|
|
|
$BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
|
2014-01-12 22:40:20 +01:00
|
|
|
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 "... "
|
2022-03-30 17:45:35 +02:00
|
|
|
xsltproc --nonet \
|
|
|
|
-o kernfs-scripts/devices.sh kernfs.xsl \
|
|
|
|
$BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
|
2022-10-06 10:20:34 +02:00
|
|
|
chmod +x kernfs-scripts/devices.sh
|
2022-03-30 17:45:35 +02:00
|
|
|
xsltproc --nonet \
|
|
|
|
-o kernfs-scripts/teardown.sh kernfs.xsl \
|
|
|
|
$BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
|
2022-10-06 10:20:34 +02:00
|
|
|
chmod +x kernfs-scripts/teardown.sh
|
2022-03-30 17:45:35 +02:00
|
|
|
|
2019-03-13 07:31:55 +01:00
|
|
|
echo "done"
|
|
|
|
|
|
|
|
}
|