source: common/libs/func_install_blfs@ 6613034

ablfs-more legacy trunk
Last change on this file since 6613034 was c7b535b, checked in by Pierre Labastie <pierre@…>, 7 years ago

Remove the need to have write access to BUILDDIR, using sudi, which is
required anyway. ticket #1715

  • Property mode set to 100644
File size: 8.2 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
136WRAP_INSTALL=$WRAP_INSTALL
137DEL_LA_FILES=$DEL_LA_FILES
138EOF
139
140# Generates the scripts for the blfs tools dependencies (in ./scripts)
141yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh $BUILDDIR$BLFS_ROOT
142
143# Move the scriptlets where they should be
144sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
145mv scripts $BUILDDIR$BLFS_ROOT
146
147# Generates a list containing download and copying instructions for tarballs
148echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
149sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
150cp $PACKAGE $JH_SRC_ARCHIVE
151p}' \
152 -e '/|[ ]*md5sum/p' \
153 -e '/PACKAGE1=/,/^fi/{/^fi/a\
154cp $PACKAGE1 $JH_SRC_ARCHIVE
155p}' \
156 -e '/PATCH=/,/^fi/{/^fi/a\
157cp $PATCH $JH_SRC_ARCHIVE
158p}' \
159 -e '/URL=/,/^fi/{/^fi/a\
160cp $BOOTPACKG $JH_SRC_ARCHIVE
161p}' \
162 $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
163chmod u+x $BUILDDIR$BLFS_ROOT/download_script
164
165# Downloads (or copy) to build_dir/sources
166pushd $BUILDDIR/sources
167# Remove `unpacked' files if some have been left
168sudo find . -name unpacked -exec rm \{\} \;
169if [ "$GETPKG" = "y" ]; then
170 JH_FTP_SERVER=$SERVER/pub/blfs/ \
171 JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
172 $BUILDDIR$BLFS_ROOT/download_script
173else # Save the download script in case the user wants to run it later
174 cp $BUILDDIR$BLFS_ROOT/download_script .
175fi
176popd
177rm -v $BUILDDIR$BLFS_ROOT/download_script
178
179# Suppresses unneeded parts of the scriptlets
180if [ "$DEP_LIBXSLT" = y ]; then
181 # libxslt pulls docbook-xsl in, which populates the catalog with annoying
182 # **EDITME** references. Fortunately, those lines are regognizable because
183 # they occur between lines containing '/etc/xml/catalog' at the end of the
184 # line (without '&&'). I have not found a simple way to delete lines
185 # between 2 addresses, excluding either the first or the last one. So use
186 # a loop for accumulating lines and deleting at the end.
187 # Sorry for sed syntax.
188 sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
189n
190:a
191\@/etc/xml/catalog$@bb
192N
193ba
194:b
195d}' \
196 $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
197fi
198if [ "$DEP_SUDO" = y ]; then
199 sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
200fi
201if [ "$DEP_SVN" = y ]; then
202 sed -i -e /javahl/d -e /swig/d $BUILDDIR$BLFS_ROOT/scripts/*subversion
203fi
204# At last generates the build Makefile
205mkdir -p $BUILDDIR$BLFS_ROOT/work
206pushd $BUILDDIR$BLFS_ROOT/work
207../gen-makefile.sh
208# The generated Makefile updates the tracking file after each package
209# installation, using libxslt, which is not installed yet. So move
210# updating to the end of the process, adding an 'update' target
211sed -i -e '/xsltproc/,+6d' \
212 -e '/^all/s@$@ update@' \
213 -e 's/touch/@touch/' Makefile
214cat >> Makefile << EOF
215update:
216 @echo Updating the tracking file
217 @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
218 sed 's/.*>\([^<]*\)<.*/\1/' | \\
219 sort | uniq); do \\
220 VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
221 ../$LFS_XML/tmp/lfs-full.xml | \\
222 head -n2| \\
223 sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
224 xsltproc --stringparam packages ../packages.xml \\
225 --stringparam package \$\$pack \\
226 --stringparam version \$\$VERSION \\
227 -o track.tmp \\
228 ../xsl/bump.xsl \$(TRACKING_FILE); \\
229 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
230 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
231 rm track.tmp; \\
232 done; \\
233 VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
234 sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
235 xsltproc --stringparam packages ../packages.xml \\
236 --stringparam package LFS-Release \\
237 --stringparam version \$\$VERSION \\
238 -o track.tmp \\
239 ../xsl/bump.xsl \$(TRACKING_FILE); \\
240 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
241 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
242 rm track.tmp; \\
243 for file in *-*; do \\
244 xsltproc --stringparam packages ../packages.xml \\
245 --stringparam package \$\${file##*z-} \\
246 -o track.tmp \\
247 ../xsl/bump.xsl \$(TRACKING_FILE); \\
248 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
249 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
250 rm track.tmp; \\
251 done
252 @touch \$@
253 @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
254 @echo --------------------------------------------------------------------------------\$(WHITE)
255EOF
256popd
257}
Note: See TracBrowser for help on using the repository browser.