source: common/libs/func_install_blfs@ 3faf067

ablfs-more legacy trunk
Last change on this file since 3faf067 was f81d8bd, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

func_install_blfs: gen_pkg_book needs the tracking file

The tracking file is needed for gen_pkg_book.sh as a first argument.
Since it is called to generate the initial scriptlets, it needs
to be passed the full path of the tracking file, including
$BUILD_DIR. The $TOPDIR is now the second argument (and still
needs to be passed too).

  • Property mode set to 100644
File size: 8.7 KB
RevLine 
[e576789]1#!/bin/bash
2
3#----------------------------# Prepare BLFS_ROOT and extract
4install_blfs_tools() { # the scriptlets to build
5#----------------------------# the dependency tools
6set -e
7# Install the files
[106157fd]8[[ ! -d "${BUILDDIR}${BLFS_ROOT}" ]] && {
9 sudo mkdir -pv "${BUILDDIR}${BLFS_ROOT}"
10 sudo chown "$USER" "${BUILDDIR}${BLFS_ROOT}"
[c7b535b]11}
[e576789]12cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
13cp -r menu ${BUILDDIR}${BLFS_ROOT}
14cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
15cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
[945ccaa]16if [ "$WRAP_INSTALL" = y ]; then
[1fa0dee]17 sed -e 's/PKGDIR/JH_UNPACKDIR/' \
18 -e 's/PKG_DEST/JH_PKG_DIR/' \
[945ccaa]19 $PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
20fi
[e576789]21
22# Set some harcoded envars to their proper values
23sed -i s@tracking-dir@$TRACKING_DIR@ \
[b734bfb]24 ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
[e576789]25sed -i s@trunk/BOOK@$BLFS_TREE@ \
26 ${BUILDDIR}${BLFS_ROOT}/Makefile
27
[854854e]28# If we have a working copy, copy it:
29if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
[382b083]30echo "copying the local BLFS working copy (may take some time)"
[e58cf153]31# -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
[382b083]32# of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
33# book has already been validated, tmp is posterior to the others, and
34# validation will not be done again.
35 cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
[340c27e]36 ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
[854854e]37fi
[b8aa7ed]38
39# Copy the LFS book. Note that now, the book is downloaded before running
40# the BLFS tools.
41cp -ruT --preserve=timestamps $BOOK \
42 ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
43
[854854e]44# Downloads the book if necessary, initialize the tracking file and the
45# package database.
[e576789]46# sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
47# has to be created
[340c27e]48sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
49 REV=$INITSYS \
50 TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
[b8aa7ed]51 LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
[dd5d63d]52 LFS-GIT=$GIT/lfs.git \
[2ac2fc5]53 LFS-BRANCH=${LFS_TREE} \
[340c27e]54 BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
[dd5d63d]55 GIT=$GIT/blfs.git \
[2ac2fc5]56 BLFS-BRANCH=${BLFS_TREE} \
[26e6739]57 $BUILDDIR$BLFS_ROOT/packages.xml
[e576789]58
[ae1d8a5]59# But then $BUILDDIR/var/lib/ is owned by root if just created, which
[088130f]60# prevents $LUSER to create "nss_db". The problem is that $LUSER
61# May not have been created yet. So do not change ownership here
62# and do it in master.sh for chapter 4.
63#sudo chown $LUSER:$LGROUP $BUILDDIR/var/lib
[ae1d8a5]64
[e576789]65# Because the BLFS Makefile is supposed to be used in chroot (or booted)
66# mode, the tracking file has wrong path for DTD. Change it:
67sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
68
69# Manually build a 'configuration' file
70if [ "$DEP_LIBXML" = y ]; then
71 LINE_LIBXML='CONFIG_libxml2=y'
72else
73 LINE_LIBXML='#CONFIG_libxml2 is not set'
74fi
75if [ "$DEP_LIBXSLT" = y ]; then
76 LINE_LIBXSLT='CONFIG_libxslt=y'
77else
78 LINE_LIBXSLT='#CONFIG_libxslt is not set'
79fi
[c1626d8]80# DocBook is a rec dep of libxslt
81# if [ "$DEP_DBXML" = y ]; then
82# LINE_DBXML='CONFIG_DocBook=y'
83# else
84# LINE_DBXML='#CONFIG_DocBook is not set'
85# fi
[e576789]86if [ "$DEP_LYNX" = y ]; then
87 LINE_LYNX='CONFIG_lynx=y'
88else
89 LINE_LYNX='#CONFIG_lynx is not set'
90fi
91if [ "$DEP_SUDO" = y ]; then
92 LINE_SUDO='CONFIG_sudo=y'
93else
94 LINE_SUDO='#CONFIG_sudo is not set'
95fi
96if [ "$DEP_WGET" = y ]; then
97 LINE_WGET='CONFIG_wget=y'
98else
99 LINE_WGET='#CONFIG_wget is not set'
100fi
101if [ "$DEP_GPM" = y ]; then
102 LINE_GPM='CONFIG_gpm=y'
103else
104 LINE_GPM='#CONFIG_gpm is not set'
105fi
[dd5d63d]106if [ "$DEP_GIT" = y ]; then
107 LINE_GIT='CONFIG_git=y'
[e576789]108else
[dd5d63d]109 LINE_GIT='#CONFIG_git is not set'
[e576789]110fi
111
112cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
113$LINE_LIBXML
114$LINE_LIBXSLT
115$LINE_WGET
[dd5d63d]116$LINE_GIT
[e576789]117$LINE_GPM
118$LINE_LYNX
119$LINE_SUDO
120MAIL_SERVER=sendmail
121optDependency=2
122SUDO=n
[625cb14]123LANGUAGE=$LANG
[945ccaa]124WRAP_INSTALL=$WRAP_INSTALL
[267b19d]125PACK_INSTALL=/blfs_root/packInstall.sh
[dc7fd7b]126DEL_LA_FILES=$DEL_LA_FILES
[625cb14]127STATS=n
[267b19d]128SRC_ARCHIVE=/sources
129BUILD_ROOT=/sources
130BUILD_SUBDIRS=y
131JOBS=$(if [ -n "$N_PARALLEL" ]; then echo $N_PARALLEL; else echo 1; fi)
[e576789]132EOF
[267b19d]133for OPT_VAR in CFLAGS CXXFLAGS LDFLAGS; do
134 eval optVal=\$${OPT_VAR}_$DEF_OPT_MODE
135 if [ -n "$optVal" ] && [ "$optVal" != unset ]; then
136 echo "CFG_$OPT_VAR"=\"$optVal\" >> $BUILDDIR$BLFS_ROOT/configuration
137 else
138 echo "CFG_$OPT_VAR"=EMPTY >> $BUILDDIR$BLFS_ROOT/configuration
139 fi
140done
[e576789]141
142# Generates the scripts for the blfs tools dependencies (in ./scripts)
[f81d8bd]143yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh \
144 $BUILDDIR$TRACKING_DIR/instpkg.xml \
145 $BUILDDIR$BLFS_ROOT
[e576789]146
147# Move the scriptlets where they should be
148sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
149mv scripts $BUILDDIR$BLFS_ROOT
150
151# Generates a list containing download and copying instructions for tarballs
152echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
[2cf28dc]153sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
[1fa0dee]154cp $PACKAGE $JH_SRC_ARCHIVE
[2cf28dc]155p}' \
[39da010]156 -e '/|[ ]*md5sum/p' \
[2cf28dc]157 -e '/PACKAGE1=/,/^fi/{/^fi/a\
[1fa0dee]158cp $PACKAGE1 $JH_SRC_ARCHIVE
[2cf28dc]159p}' \
160 -e '/PATCH=/,/^fi/{/^fi/a\
[1fa0dee]161cp $PATCH $JH_SRC_ARCHIVE
[2cf28dc]162p}' \
163 -e '/URL=/,/^fi/{/^fi/a\
[1fa0dee]164cp $BOOTPACKG $JH_SRC_ARCHIVE
[2cf28dc]165p}' \
[e576789]166 $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
167chmod u+x $BUILDDIR$BLFS_ROOT/download_script
168
169# Downloads (or copy) to build_dir/sources
170pushd $BUILDDIR/sources
171# Remove `unpacked' files if some have been left
172sudo find . -name unpacked -exec rm \{\} \;
[67723e1]173if [ "$GETPKG" = "y" ]; then
[1fa0dee]174 JH_FTP_SERVER=$SERVER/pub/blfs/ \
175 JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
[67723e1]176 $BUILDDIR$BLFS_ROOT/download_script
177else # Save the download script in case the user wants to run it later
178 cp $BUILDDIR$BLFS_ROOT/download_script .
179fi
[e576789]180popd
181rm -v $BUILDDIR$BLFS_ROOT/download_script
182
183# Suppresses unneeded parts of the scriptlets
[c1626d8]184if [ "$DEP_LIBXSLT" = y ]; then
[cbca63a]185 # libxslt pulls docbook-xsl in, which populates the catalog with annoying
186 # **EDITME** references. Fortunately, those lines are regognizable because
187 # they occur between lines containing '/etc/xml/catalog' at the end of the
188 # line (without '&&'). I have not found a simple way to delete lines
189 # between 2 addresses, excluding either the first or the last one. So use
190 # a loop for accumulating lines and deleting at the end.
[4b2a5fd]191 # Sorry for sed syntax.
[c1626d8]192 sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
193n
194:a
195\@/etc/xml/catalog$@bb
196N
197ba
198:b
199d}' \
200 $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
201fi
[e576789]202if [ "$DEP_SUDO" = y ]; then
[cbca63a]203 sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
[e576789]204fi
205# At last generates the build Makefile
206mkdir -p $BUILDDIR$BLFS_ROOT/work
207pushd $BUILDDIR$BLFS_ROOT/work
208../gen-makefile.sh
[cbca63a]209# The generated Makefile updates the tracking file after each package
210# installation, using libxslt, which is not installed yet. So move
211# updating to the end of the process, adding an 'update' target
[e576789]212sed -i -e '/xsltproc/,+6d' \
213 -e '/^all/s@$@ update@' \
214 -e 's/touch/@touch/' Makefile
215cat >> Makefile << EOF
216update:
217 @echo Updating the tracking file
[6d1d77c]218 @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
219 sed 's/.*>\([^<]*\)<.*/\1/' | \\
220 sort | uniq); do \\
[a1795f0]221 case "x\$\$pack" in \\
[ea0be93]222 xgcc* | *pass[12] | xvim | \\
[a1795f0]223 xshadow | xPython | xlinux-headers | xdbus | xsystemd )\\
224 continue ;; \\
225 esac; \\
[e3f4b9a4]226 VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
[6d1d77c]227 ../$LFS_XML/tmp/lfs-full.xml | \\
228 head -n2| \\
229 sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
230 xsltproc --stringparam packages ../packages.xml \\
231 --stringparam package \$\$pack \\
232 --stringparam version \$\$VERSION \\
233 -o track.tmp \\
234 ../xsl/bump.xsl \$(TRACKING_FILE); \\
235 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
236 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
237 rm track.tmp; \\
238 done; \\
[e3f4b9a4]239 VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
240 sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
241 xsltproc --stringparam packages ../packages.xml \\
242 --stringparam package LFS-Release \\
243 --stringparam version \$\$VERSION \\
244 -o track.tmp \\
245 ../xsl/bump.xsl \$(TRACKING_FILE); \\
246 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
247 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
248 rm track.tmp; \\
[6d1d77c]249 for file in *-*; do \\
250 xsltproc --stringparam packages ../packages.xml \\
251 --stringparam package \$\${file##*z-} \\
252 -o track.tmp \\
253 ../xsl/bump.xsl \$(TRACKING_FILE); \\
254 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
255 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
256 rm track.tmp; \\
[e576789]257 done
258 @touch \$@
259 @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
260 @echo --------------------------------------------------------------------------------\$(WHITE)
261EOF
262popd
263}
Note: See TracBrowser for help on using the repository browser.