This repository has been archived on 2024-10-17. You can view files and clone it, but cannot push or open issues or pull requests.
MahiroOS-jhalfs/common/libs/func_book_parser

317 lines
12 KiB
Text
Raw Normal View History

2006-11-11 20:06:46 +01:00
#!/bin/bash
# $Id$
#----------------------------#
get_book() { #
#----------------------------#
cd $JHALFSDIR
if [ -z $WORKING_COPY ] ; then
# Check for Subversion or git instead of just letting the script fail.
test `type -p git` || eval "echo \"This feature requires Git.\"
exit 1"
2006-11-11 20:06:46 +01:00
echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
case $PROGNAME in
lfs) git_root="lfs.git" ;;
clfs*) ;;
2006-11-11 20:06:46 +01:00
*) 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}/.git ]; then
git clone $GIT/$git_root ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1
if [ ! $TREE == "development" ]; then
pushd ${PROGNAME}-$LFSVRS > /dev/null
echo "Checking out $LFSVRS at $PWD in $TREE"
2013-10-03 12:28:37 +02:00
git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
popd > /dev/null
fi
else
cd ${PROGNAME}-$LFSVRS
# If the repo is in "detached head" state, git pull fails, so get
# back first to master:
git checkout trunk >>$LOGDIR/$LOG 2>&1
git pull >>$LOGDIR/$LOG 2>&1
if [ ! $TREE == "development" ]; then
git checkout ${TREE} >>$LOGDIR/$LOG 2>&1
fi
2006-11-11 20:06:46 +01:00
fi
echo -ne "done\n"
2006-11-11 20:06:46 +01: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
# Clean
rm -rf ${PROGNAME}-commands
2006-11-11 20:06:46 +01:00
# Extract the commands
echo -n "Extracting commands for"
2006-11-11 20:06:46 +01:00
case ${PROGNAME} in
clfs)
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
xsltproc --nonet \
--xinclude \
--stringparam method "$METHOD" \
--stringparam testsuite "$TEST" \
--stringparam bomb-testsuite "$BOMB_TEST" \
--stringparam timezone "$TIMEZONE" \
--stringparam page "$PAGE" \
--stringparam lang "$LANG" \
--stringparam sparc "$SPARC64_PROC" \
--stringparam x86 "$TARGET" \
--stringparam mips "$TARGET" \
-o ./${PROGNAME}-commands/ \
$XSL \
$BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
2006-11-11 20:06:46 +01:00
;;
clfs2)
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
xsltproc --nonet \
--xinclude \
--stringparam timezone "$TIMEZONE" \
--stringparam page "$PAGE" \
--stringparam lang "$LANG" \
--output ./${PROGNAME}-commands/ \
$XSL \
$BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
2006-11-11 20:06:46 +01:00
;;
clfs3)
echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture... "
xsltproc --nonet \
--xinclude \
--stringparam endian x$ENDIAN \
--stringparam timezone "$TIMEZONE" \
--stringparam page "$PAGE" \
--stringparam lang "$LANG" \
--output ./${PROGNAME}-commands/ \
$XSL \
$BOOK/BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
2006-11-11 20:06:46 +01:00
;;
hlfs)
echo -n " ${L_arrow}${BOLD}$MODEL + $KERNEL${R_arrow} HLFS flavour... "
xsltproc --nonet \
--xinclude \
2017-06-29 18:54:28 +02:00
--stringparam model "$MODEL" \
--stringparam kernel "$KERNEL" \
--stringparam testsuite "$TEST" \
--stringparam bomb-testsuite "$BOMB_TEST" \
--stringparam features \
x$SSP$ASLR$PAX$HARDENED_TMP$WARNINGS$MISC$BLOWFISH \
2017-06-29 18:54:28 +02:00
--stringparam timezone "$TIMEZONE" \
--stringparam page "$PAGE" \
--stringparam lang "$LANG" \
--stringparam grsecurity_host "$GRSECURITY_HOST" \
--output ./${PROGNAME}-commands/ \
$XSL \
$BOOK/index.xml >>$LOGDIR/$LOG 2>&1
2006-11-11 20:06:46 +01:00
;;
lfs)
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
2013-03-03 13:33:25 +01:00
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 >> $LOGDIR/$LOG 2>&1
fi
popd > /dev/null
# 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.
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 bomb-testsuite "$BOMB_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" \
--output ./${PROGNAME}-commands/ \
$XSL \
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...
sed -i 's/-iv /-v /' ./${PROGNAME}-commands/chapter??/*kernel*
2006-11-11 20:06:46 +01:00
;;
*) echo -n " ${L_arrow}${PROGNAME}${R_arrow} book invalid, terminate build... "
2006-11-11 20:06:46 +01:00
exit 1 ;;
esac
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
# 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
# On the other hand, lfs needs two auxiliary files
if [ "${PROGNAME}" = lfs ]; then
create_chroot_scripts
create_kernfs_scripts
fi
2006-11-11 20:06:46 +01: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
clfs*)
VERSION=$(xmllint --noent $BOOK/BOOK/prologue/$ARCH/bookinfo.xml 2>/dev/null | grep subtitle | sed -e 's/^.*ion //' -e 's/<\/.*//') ;;
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
echo -n "Creating <${PROGNAME}> list of tarball names for $BOOK"
if [ ! -z "$ARCH" ] ; then echo -n " $ARCH" ; fi
echo -n "... "
2006-11-11 20:06:46 +01:00
case ${PROGNAME} in
clfs*)
xsltproc --nonet --xinclude \
-o pkg_tarball_list \
packages.xsl \
$BOOK/BOOK/materials/${ARCH}-chapter.xml >>$LOGDIR/$LOG 2>&1
2006-11-11 20:06:46 +01:00
;;
hlfs)
xsltproc --nonet --xinclude \
--stringparam model "$MODEL" \
--stringparam kernel "$KERNEL" \
--output pkg_tarball_list \
packages.xsl \
2006-11-11 20:06:46 +01:00
$BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
;;
lfs)
# lfs does not use the package list anymore
2006-11-11 20:06:46 +01:00
;;
*)
2006-11-11 20:06:46 +01:00
esac
echo "done"
2006-11-11 20:06:46 +01:00
}
#----------------------------#
create_chroot_scripts() { #
#----------------------------#
rm -rf chroot-scripts
echo -n "Creating chroot commands scripts from $BOOK"
if [ ! -z $ARCH ] ; then echo -n " $ARCH" ; fi
echo -n "... "
case ${PROGNAME} in
clfs*)
xsltproc --nonet --xinclude \
-o chroot-scripts/ chroot.xsl \
$BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
;;
hlfs)
xsltproc --nonet --xinclude \
-o chroot-scripts/ chroot.xsl \
$BOOK/index.xml >> $LOGDIR/$LOG 2>&1
;;
lfs)
xsltproc --nonet --xinclude \
-o chroot-scripts/ chroot.xsl \
$BOOK/chapter0?/*chroot*.xml >> $LOGDIR/$LOG 2>&1
;;
*)
esac
echo "done"
}
#----------------------------#
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
clfs*)
xsltproc --nonet --xinclude \
-o kernfs-scripts/ kernfs.xsl \
$BOOK/BOOK/${ARCH}-index.xml >> $LOGDIR/$LOG 2>&1
;;
hlfs)
xsltproc --nonet --xinclude \
-o kernfs-scripts/ kernfs.xsl \
$BOOK/index.xml >> $LOGDIR/$LOG 2>&1
;;
lfs)
xsltproc --nonet \
-o kernfs-scripts/devices.sh kernfs.xsl \
$BOOK/*/kernfs.xml >> $LOGDIR/$LOG 2>&1
xsltproc --nonet \
-o kernfs-scripts/teardown.sh kernfs.xsl \
$BOOK/chapter??/reboot.xml >> $LOGDIR/$LOG 2>&1
;;
*)
esac
echo "done"
}