source: common/libs/func_install_blfs@ 2c1a763

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

try to fix func_install_blfs to work in all cases

WIP...

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