source: common/libs/func_install_blfs@ 94a78dd

ablfs-more legacy plabs/lfs-user trunk
Last change on this file since 94a78dd was 94a78dd, checked in by Pierre Labastie <pierre@…>, 6 years ago

When installing BLFS tools, the database of installed packages is populated
with LFS pacakges. But packages installed only in tools should not be in
this database. As a side note, it would be cleaner to use an xsl stylesheet
for that.

  • Property mode set to 100644
File size: 8.4 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5#----------------------------# Prepare BLFS_ROOT and extract
6install_blfs_tools() { # the scriptlets to build
7#----------------------------# the dependency tools
8set -e
9# Install the files
10[[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && {
11 sudo mkdir -pv ${BUILDDIR}${BLFS_ROOT}
12 sudo chown $USER:$USER ${BUILDDIR}${BLFS_ROOT}
13}
14cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
15cp -r menu ${BUILDDIR}${BLFS_ROOT}
16cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
17cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
18if [ "$WRAP_INSTALL" = y ]; then
19 sed -e 's/PKGDIR/JH_UNPACKDIR/' \
20 -e 's/PKG_DEST/JH_PKG_DIR/' \
21 $PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
22fi
23
24# Clean-up
25make -C ${BUILDDIR}${BLFS_ROOT}/menu clean
26rm -rf ${BUILDDIR}${BLFS_ROOT}/libs/.svn
27rm -rf ${BUILDDIR}${BLFS_ROOT}/xsl/.svn
28rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/.svn
29rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/lxdialog/.svn
30
31# Set some harcoded envars to their proper values
32sed -i s@tracking-dir@$TRACKING_DIR@ \
33 ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh}
34sed -i s@trunk/BOOK@$BLFS_TREE@ \
35 ${BUILDDIR}${BLFS_ROOT}/Makefile
36
37# If we have a working copy, copy it:
38if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
39echo "copying the local BLFS working copy (may take some time)"
40# -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
41# of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
42# book has already been validated, tmp is posterior to the others, and
43# validation will not be done again.
44 cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
45 ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
46fi
47
48# Copy the LFS book. Note that now, the book is downloaded before running
49# the BLFS tools.
50cp -ruT --preserve=timestamps $BOOK \
51 ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
52
53# Downloads the book if necessary, initialize the tracking file and the
54# package database.
55# sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
56# has to be created
57sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
58 REV=$INITSYS \
59 TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
60 LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
61 LFS-SVN=$SVN_2/LFS/$TREE \
62 BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
63 SVN=$SVN_2/BLFS/$BLFS_TREE \
64 $BUILDDIR$BLFS_ROOT/packages.xml
65
66# Because the BLFS Makefile is supposed to be used in chroot (or booted)
67# mode, the tracking file has wrong path for DTD. Change it:
68sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
69
70# Manually build a 'configuration' file
71if [ "$DEP_LIBXML" = y ]; then
72 LINE_LIBXML='CONFIG_libxml2=y'
73else
74 LINE_LIBXML='#CONFIG_libxml2 is not set'
75fi
76if [ "$DEP_LIBXSLT" = y ]; then
77 LINE_LIBXSLT='CONFIG_libxslt=y'
78else
79 LINE_LIBXSLT='#CONFIG_libxslt is not set'
80fi
81# DocBook is a rec dep of libxslt
82# if [ "$DEP_DBXML" = y ]; then
83# LINE_DBXML='CONFIG_DocBook=y'
84# else
85# LINE_DBXML='#CONFIG_DocBook is not set'
86# fi
87if [ "$DEP_LYNX" = y ]; then
88 LINE_LYNX='CONFIG_lynx=y'
89else
90 LINE_LYNX='#CONFIG_lynx is not set'
91fi
92if [ "$DEP_SUDO" = y ]; then
93 LINE_SUDO='CONFIG_sudo=y'
94else
95 LINE_SUDO='#CONFIG_sudo is not set'
96fi
97if [ "$DEP_WGET" = y ]; then
98 LINE_WGET='CONFIG_wget=y'
99else
100 LINE_WGET='#CONFIG_wget is not set'
101fi
102if [ "$DEP_GPM" = y ]; then
103 LINE_GPM='CONFIG_gpm=y'
104else
105 LINE_GPM='#CONFIG_gpm is not set'
106fi
107if [ "$DEP_SVN" = y ]; then
108 LINE_SVN='CONFIG_subversion=y'
109else
110 LINE_SVN='#CONFIG_subversion is not set'
111fi
112if [ "$DEP_OPENSSL" = y ]; then
113 LINE_OPENSSL='CONFIG_openssl=y'
114else
115 LINE_OPENSSL='#CONFIG_openssl is not set'
116fi
117if [ "$DEP_PYTHON" = y ]; then
118 LINE_PYTHON='CONFIG_python2=y'
119else
120 LINE_PYTHON='#CONFIG_python2 is not set'
121fi
122
123cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
124$LINE_OPENSSL
125$LINE_PYTHON
126$LINE_LIBXML
127$LINE_LIBXSLT
128$LINE_WGET
129$LINE_SVN
130$LINE_GPM
131$LINE_LYNX
132$LINE_SUDO
133MAIL_SERVER=sendmail
134optDependency=2
135SUDO=n
136LANGUAGE=$LANG
137WRAP_INSTALL=$WRAP_INSTALL
138DEL_LA_FILES=$DEL_LA_FILES
139STATS=n
140EOF
141
142# Generates the scripts for the blfs tools dependencies (in ./scripts)
143yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh $BUILDDIR$BLFS_ROOT
144
145# Move the scriptlets where they should be
146sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
147mv scripts $BUILDDIR$BLFS_ROOT
148
149# Generates a list containing download and copying instructions for tarballs
150echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
151sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
152cp $PACKAGE $JH_SRC_ARCHIVE
153p}' \
154 -e '/|[ ]*md5sum/p' \
155 -e '/PACKAGE1=/,/^fi/{/^fi/a\
156cp $PACKAGE1 $JH_SRC_ARCHIVE
157p}' \
158 -e '/PATCH=/,/^fi/{/^fi/a\
159cp $PATCH $JH_SRC_ARCHIVE
160p}' \
161 -e '/URL=/,/^fi/{/^fi/a\
162cp $BOOTPACKG $JH_SRC_ARCHIVE
163p}' \
164 $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
165chmod u+x $BUILDDIR$BLFS_ROOT/download_script
166
167# Downloads (or copy) to build_dir/sources
168pushd $BUILDDIR/sources
169# Remove `unpacked' files if some have been left
170sudo find . -name unpacked -exec rm \{\} \;
171if [ "$GETPKG" = "y" ]; then
172 JH_FTP_SERVER=$SERVER/pub/blfs/ \
173 JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
174 $BUILDDIR$BLFS_ROOT/download_script
175else # Save the download script in case the user wants to run it later
176 cp $BUILDDIR$BLFS_ROOT/download_script .
177fi
178popd
179rm -v $BUILDDIR$BLFS_ROOT/download_script
180
181# Suppresses unneeded parts of the scriptlets
182if [ "$DEP_LIBXSLT" = y ]; then
183 # libxslt pulls docbook-xsl in, which populates the catalog with annoying
184 # **EDITME** references. Fortunately, those lines are regognizable because
185 # they occur between lines containing '/etc/xml/catalog' at the end of the
186 # line (without '&&'). I have not found a simple way to delete lines
187 # between 2 addresses, excluding either the first or the last one. So use
188 # a loop for accumulating lines and deleting at the end.
189 # Sorry for sed syntax.
190 sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
191n
192:a
193\@/etc/xml/catalog$@bb
194N
195ba
196:b
197d}' \
198 $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
199fi
200if [ "$DEP_SUDO" = y ]; then
201 sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
202fi
203if [ "$DEP_SVN" = y ]; then
204 sed -i -e /javahl/d -e /swig/d $BUILDDIR$BLFS_ROOT/scripts/*subversion
205fi
206# At last generates the build Makefile
207mkdir -p $BUILDDIR$BLFS_ROOT/work
208pushd $BUILDDIR$BLFS_ROOT/work
209../gen-makefile.sh
210# The generated Makefile updates the tracking file after each package
211# installation, using libxslt, which is not installed yet. So move
212# updating to the end of the process, adding an 'update' target
213sed -i -e '/xsltproc/,+6d' \
214 -e '/^all/s@$@ update@' \
215 -e 's/touch/@touch/' Makefile
216cat >> Makefile << EOF
217update:
218 @echo Updating the tracking file
219 @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
220 sed 's/.*>\([^<]*\)<.*/\1/' | \\
221 sort | uniq); do \\
222 if [ "x\$\$pack" = xtcl -o \\
223 "x\$\$pack" = xexpect -o \\
224 "x\$\$pack" = xdejagnu ]; then continue; \\
225 fi; \\
226 VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
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; \\
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; \\
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; \\
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.