2013-10-29 16:42:03 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#----------------------------# Prepare BLFS_ROOT and extract
|
|
|
|
install_blfs_tools() { # the scriptlets to build
|
|
|
|
#----------------------------# the dependency tools
|
|
|
|
set -e
|
|
|
|
# Install the files
|
2021-06-30 16:03:51 +02:00
|
|
|
[[ ! -d "${BUILDDIR}${BLFS_ROOT}" ]] && {
|
|
|
|
sudo mkdir -pv "${BUILDDIR}${BLFS_ROOT}"
|
|
|
|
sudo chown "$USER" "${BUILDDIR}${BLFS_ROOT}"
|
2018-02-03 17:37:32 +01:00
|
|
|
}
|
2013-10-29 16:42:03 +01:00
|
|
|
cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
|
|
|
|
cp -r menu ${BUILDDIR}${BLFS_ROOT}
|
|
|
|
cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
|
|
|
|
cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
|
2017-04-09 12:29:32 +02:00
|
|
|
if [ "$WRAP_INSTALL" = y ]; then
|
2018-01-30 14:53:34 +01:00
|
|
|
sed -e 's/PKGDIR/JH_UNPACKDIR/' \
|
|
|
|
-e 's/PKG_DEST/JH_PKG_DIR/' \
|
2017-04-09 12:29:32 +02:00
|
|
|
$PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
|
|
|
|
fi
|
2013-10-29 16:42:03 +01:00
|
|
|
|
|
|
|
# Set some harcoded envars to their proper values
|
|
|
|
sed -i s@tracking-dir@$TRACKING_DIR@ \
|
2021-12-19 14:24:04 +01:00
|
|
|
${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
|
2013-10-29 16:42:03 +01:00
|
|
|
sed -i s@trunk/BOOK@$BLFS_TREE@ \
|
|
|
|
${BUILDDIR}${BLFS_ROOT}/Makefile
|
|
|
|
|
2013-11-16 23:35:25 +01:00
|
|
|
# If we have a working copy, copy it:
|
|
|
|
if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
|
2013-12-15 08:46:46 +01:00
|
|
|
echo "copying the local BLFS working copy (may take some time)"
|
2013-11-17 08:55:30 +01:00
|
|
|
# -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
|
2013-12-15 08:46:46 +01:00
|
|
|
# of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
|
|
|
|
# book has already been validated, tmp is posterior to the others, and
|
|
|
|
# validation will not be done again.
|
|
|
|
cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
|
2017-08-09 15:47:45 +02:00
|
|
|
${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
|
2013-11-16 23:35:25 +01:00
|
|
|
fi
|
2017-08-09 16:10:46 +02:00
|
|
|
|
|
|
|
# Copy the LFS book. Note that now, the book is downloaded before running
|
|
|
|
# the BLFS tools.
|
|
|
|
cp -ruT --preserve=timestamps $BOOK \
|
|
|
|
${BUILDDIR}${BLFS_ROOT}/$LFS_XML
|
|
|
|
|
2013-11-16 23:35:25 +01:00
|
|
|
# Downloads the book if necessary, initialize the tracking file and the
|
|
|
|
# package database.
|
2013-10-29 16:42:03 +01:00
|
|
|
# sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
|
|
|
|
# has to be created
|
2017-08-09 15:47:45 +02:00
|
|
|
sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
|
|
|
|
REV=$INITSYS \
|
|
|
|
TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
|
2017-08-09 16:10:46 +02:00
|
|
|
LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
|
2021-05-01 09:23:14 +02:00
|
|
|
LFS-BRANCH=${LFS_TREE} \
|
2017-08-09 15:47:45 +02:00
|
|
|
BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
|
2021-05-01 09:23:14 +02:00
|
|
|
BLFS-BRANCH=${BLFS_TREE} \
|
2016-10-16 16:02:34 +02:00
|
|
|
$BUILDDIR$BLFS_ROOT/packages.xml
|
2013-10-29 16:42:03 +01:00
|
|
|
|
2020-05-08 10:22:55 +02:00
|
|
|
# But then $BUILDDIR/var/lib/ is owned by root if just created, which
|
2020-09-17 17:30:29 +02:00
|
|
|
# prevents $LUSER to create "nss_db". The problem is that $LUSER
|
|
|
|
# May not have been created yet. So do not change ownership here
|
|
|
|
# and do it in master.sh for chapter 4.
|
|
|
|
#sudo chown $LUSER:$LGROUP $BUILDDIR/var/lib
|
2020-05-08 10:22:55 +02:00
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
# Because the BLFS Makefile is supposed to be used in chroot (or booted)
|
|
|
|
# mode, the tracking file has wrong path for DTD. Change it:
|
|
|
|
sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
|
|
|
|
|
|
|
|
# Manually build a 'configuration' file
|
|
|
|
if [ "$DEP_LIBXML" = y ]; then
|
|
|
|
LINE_LIBXML='CONFIG_libxml2=y'
|
|
|
|
else
|
|
|
|
LINE_LIBXML='#CONFIG_libxml2 is not set'
|
|
|
|
fi
|
|
|
|
if [ "$DEP_LIBXSLT" = y ]; then
|
|
|
|
LINE_LIBXSLT='CONFIG_libxslt=y'
|
|
|
|
else
|
|
|
|
LINE_LIBXSLT='#CONFIG_libxslt is not set'
|
|
|
|
fi
|
2013-12-24 19:52:24 +01:00
|
|
|
# DocBook is a rec dep of libxslt
|
|
|
|
# if [ "$DEP_DBXML" = y ]; then
|
|
|
|
# LINE_DBXML='CONFIG_DocBook=y'
|
|
|
|
# else
|
|
|
|
# LINE_DBXML='#CONFIG_DocBook is not set'
|
|
|
|
# fi
|
2013-10-29 16:42:03 +01:00
|
|
|
if [ "$DEP_LYNX" = y ]; then
|
|
|
|
LINE_LYNX='CONFIG_lynx=y'
|
|
|
|
else
|
|
|
|
LINE_LYNX='#CONFIG_lynx is not set'
|
|
|
|
fi
|
|
|
|
if [ "$DEP_SUDO" = y ]; then
|
|
|
|
LINE_SUDO='CONFIG_sudo=y'
|
|
|
|
else
|
|
|
|
LINE_SUDO='#CONFIG_sudo is not set'
|
|
|
|
fi
|
|
|
|
if [ "$DEP_WGET" = y ]; then
|
|
|
|
LINE_WGET='CONFIG_wget=y'
|
|
|
|
else
|
|
|
|
LINE_WGET='#CONFIG_wget is not set'
|
|
|
|
fi
|
|
|
|
if [ "$DEP_GPM" = y ]; then
|
|
|
|
LINE_GPM='CONFIG_gpm=y'
|
|
|
|
else
|
|
|
|
LINE_GPM='#CONFIG_gpm is not set'
|
|
|
|
fi
|
2021-04-29 11:40:46 +02:00
|
|
|
if [ "$DEP_GIT" = y ]; then
|
|
|
|
LINE_GIT='CONFIG_git=y'
|
2013-10-29 16:42:03 +01:00
|
|
|
else
|
2021-04-29 11:40:46 +02:00
|
|
|
LINE_GIT='#CONFIG_git is not set'
|
2013-10-29 16:42:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
|
|
|
|
$LINE_LIBXML
|
|
|
|
$LINE_LIBXSLT
|
|
|
|
$LINE_WGET
|
2021-04-29 11:40:46 +02:00
|
|
|
$LINE_GIT
|
2013-10-29 16:42:03 +01:00
|
|
|
$LINE_GPM
|
|
|
|
$LINE_LYNX
|
|
|
|
$LINE_SUDO
|
|
|
|
MAIL_SERVER=sendmail
|
|
|
|
optDependency=2
|
|
|
|
SUDO=n
|
2018-09-28 16:35:46 +02:00
|
|
|
LANGUAGE=$LANG
|
2017-04-09 12:29:32 +02:00
|
|
|
WRAP_INSTALL=$WRAP_INSTALL
|
2021-11-09 11:51:39 +01:00
|
|
|
PACK_INSTALL=/blfs_root/packInstall.sh
|
2018-01-12 20:04:19 +01:00
|
|
|
DEL_LA_FILES=$DEL_LA_FILES
|
2018-09-28 16:35:46 +02:00
|
|
|
STATS=n
|
2021-11-09 11:51:39 +01:00
|
|
|
SRC_ARCHIVE=/sources
|
|
|
|
BUILD_ROOT=/sources
|
|
|
|
BUILD_SUBDIRS=y
|
|
|
|
JOBS=$(if [ -n "$N_PARALLEL" ]; then echo $N_PARALLEL; else echo 1; fi)
|
2013-10-29 16:42:03 +01:00
|
|
|
EOF
|
2021-11-09 11:51:39 +01:00
|
|
|
for OPT_VAR in CFLAGS CXXFLAGS LDFLAGS; do
|
|
|
|
eval optVal=\$${OPT_VAR}_$DEF_OPT_MODE
|
|
|
|
if [ -n "$optVal" ] && [ "$optVal" != unset ]; then
|
|
|
|
echo "CFG_$OPT_VAR"=\"$optVal\" >> $BUILDDIR$BLFS_ROOT/configuration
|
|
|
|
else
|
|
|
|
echo "CFG_$OPT_VAR"=EMPTY >> $BUILDDIR$BLFS_ROOT/configuration
|
|
|
|
fi
|
|
|
|
done
|
2013-10-29 16:42:03 +01:00
|
|
|
|
|
|
|
# Generates the scripts for the blfs tools dependencies (in ./scripts)
|
2021-12-20 10:30:18 +01:00
|
|
|
yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh \
|
|
|
|
$BUILDDIR$TRACKING_DIR/instpkg.xml \
|
|
|
|
$BUILDDIR$BLFS_ROOT
|
2013-10-29 16:42:03 +01:00
|
|
|
|
|
|
|
# Move the scriptlets where they should be
|
|
|
|
sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
|
|
|
|
mv scripts $BUILDDIR$BLFS_ROOT
|
|
|
|
|
|
|
|
# Generates a list containing download and copying instructions for tarballs
|
|
|
|
echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
|
2017-03-16 14:40:18 +01:00
|
|
|
sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
|
2018-01-30 14:53:34 +01:00
|
|
|
cp $PACKAGE $JH_SRC_ARCHIVE
|
2017-03-16 14:40:18 +01:00
|
|
|
p}' \
|
2015-11-19 14:13:29 +01:00
|
|
|
-e '/|[ ]*md5sum/p' \
|
2017-03-16 14:40:18 +01:00
|
|
|
-e '/PACKAGE1=/,/^fi/{/^fi/a\
|
2018-01-30 14:53:34 +01:00
|
|
|
cp $PACKAGE1 $JH_SRC_ARCHIVE
|
2017-03-16 14:40:18 +01:00
|
|
|
p}' \
|
|
|
|
-e '/PATCH=/,/^fi/{/^fi/a\
|
2018-01-30 14:53:34 +01:00
|
|
|
cp $PATCH $JH_SRC_ARCHIVE
|
2017-03-16 14:40:18 +01:00
|
|
|
p}' \
|
|
|
|
-e '/URL=/,/^fi/{/^fi/a\
|
2018-01-30 14:53:34 +01:00
|
|
|
cp $BOOTPACKG $JH_SRC_ARCHIVE
|
2017-03-16 14:40:18 +01:00
|
|
|
p}' \
|
2013-10-29 16:42:03 +01:00
|
|
|
$BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
|
|
|
|
chmod u+x $BUILDDIR$BLFS_ROOT/download_script
|
|
|
|
|
|
|
|
# Downloads (or copy) to build_dir/sources
|
|
|
|
pushd $BUILDDIR/sources
|
|
|
|
# Remove `unpacked' files if some have been left
|
|
|
|
sudo find . -name unpacked -exec rm \{\} \;
|
2017-02-27 18:33:46 +01:00
|
|
|
if [ "$GETPKG" = "y" ]; then
|
2018-01-30 14:53:34 +01:00
|
|
|
JH_FTP_SERVER=$SERVER/pub/blfs/ \
|
|
|
|
JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
|
2017-02-27 18:33:46 +01:00
|
|
|
$BUILDDIR$BLFS_ROOT/download_script
|
|
|
|
else # Save the download script in case the user wants to run it later
|
|
|
|
cp $BUILDDIR$BLFS_ROOT/download_script .
|
|
|
|
fi
|
2013-10-29 16:42:03 +01:00
|
|
|
popd
|
|
|
|
rm -v $BUILDDIR$BLFS_ROOT/download_script
|
|
|
|
|
|
|
|
# Suppresses unneeded parts of the scriptlets
|
2013-12-24 19:52:24 +01:00
|
|
|
if [ "$DEP_LIBXSLT" = y ]; then
|
2013-12-25 12:26:55 +01:00
|
|
|
# libxslt pulls docbook-xsl in, which populates the catalog with annoying
|
|
|
|
# **EDITME** references. Fortunately, those lines are regognizable because
|
|
|
|
# they occur between lines containing '/etc/xml/catalog' at the end of the
|
|
|
|
# line (without '&&'). I have not found a simple way to delete lines
|
|
|
|
# between 2 addresses, excluding either the first or the last one. So use
|
|
|
|
# a loop for accumulating lines and deleting at the end.
|
2018-01-07 19:23:51 +01:00
|
|
|
# Sorry for sed syntax.
|
2013-12-24 19:52:24 +01:00
|
|
|
sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
|
|
|
|
n
|
|
|
|
:a
|
|
|
|
\@/etc/xml/catalog$@bb
|
|
|
|
N
|
|
|
|
ba
|
|
|
|
:b
|
|
|
|
d}' \
|
|
|
|
$BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
|
|
|
|
fi
|
2013-10-29 16:42:03 +01:00
|
|
|
if [ "$DEP_SUDO" = y ]; then
|
2013-12-25 12:26:55 +01:00
|
|
|
sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
|
2013-10-29 16:42:03 +01:00
|
|
|
fi
|
|
|
|
# At last generates the build Makefile
|
|
|
|
mkdir -p $BUILDDIR$BLFS_ROOT/work
|
|
|
|
pushd $BUILDDIR$BLFS_ROOT/work
|
|
|
|
../gen-makefile.sh
|
2013-12-25 12:26:55 +01:00
|
|
|
# The generated Makefile updates the tracking file after each package
|
|
|
|
# installation, using libxslt, which is not installed yet. So move
|
|
|
|
# updating to the end of the process, adding an 'update' target
|
2013-10-29 16:42:03 +01:00
|
|
|
sed -i -e '/xsltproc/,+6d' \
|
|
|
|
-e '/^all/s@$@ update@' \
|
|
|
|
-e 's/touch/@touch/' Makefile
|
|
|
|
cat >> Makefile << EOF
|
|
|
|
update:
|
|
|
|
@echo Updating the tracking file
|
2017-08-10 17:25:12 +02:00
|
|
|
@for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
|
|
|
|
sed 's/.*>\([^<]*\)<.*/\1/' | \\
|
|
|
|
sort | uniq); do \\
|
2019-09-25 09:50:45 +02:00
|
|
|
case "x\$\$pack" in \\
|
2020-10-15 15:15:33 +02:00
|
|
|
xgcc* | *pass[12] | xvim | \\
|
2019-09-25 09:50:45 +02:00
|
|
|
xshadow | xPython | xlinux-headers | xdbus | xsystemd )\\
|
|
|
|
continue ;; \\
|
|
|
|
esac; \\
|
2017-08-17 13:27:07 +02:00
|
|
|
VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
|
2017-08-10 17:25:12 +02:00
|
|
|
../$LFS_XML/tmp/lfs-full.xml | \\
|
|
|
|
head -n2| \\
|
|
|
|
sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
|
|
|
|
xsltproc --stringparam packages ../packages.xml \\
|
|
|
|
--stringparam package \$\$pack \\
|
|
|
|
--stringparam version \$\$VERSION \\
|
|
|
|
-o track.tmp \\
|
|
|
|
../xsl/bump.xsl \$(TRACKING_FILE); \\
|
|
|
|
sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
|
|
|
xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
|
|
|
rm track.tmp; \\
|
|
|
|
done; \\
|
2017-08-17 13:27:07 +02:00
|
|
|
VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
|
|
|
|
sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
|
|
|
|
xsltproc --stringparam packages ../packages.xml \\
|
|
|
|
--stringparam package LFS-Release \\
|
|
|
|
--stringparam version \$\$VERSION \\
|
|
|
|
-o track.tmp \\
|
|
|
|
../xsl/bump.xsl \$(TRACKING_FILE); \\
|
|
|
|
sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
|
|
|
xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
|
|
|
rm track.tmp; \\
|
2017-08-10 17:25:12 +02:00
|
|
|
for file in *-*; do \\
|
|
|
|
xsltproc --stringparam packages ../packages.xml \\
|
|
|
|
--stringparam package \$\${file##*z-} \\
|
|
|
|
-o track.tmp \\
|
|
|
|
../xsl/bump.xsl \$(TRACKING_FILE); \\
|
|
|
|
sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
|
|
|
xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
|
|
|
rm track.tmp; \\
|
2013-10-29 16:42:03 +01:00
|
|
|
done
|
|
|
|
@touch \$@
|
|
|
|
@echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
|
|
|
|
@echo --------------------------------------------------------------------------------\$(WHITE)
|
|
|
|
EOF
|
|
|
|
popd
|
|
|
|
}
|