source: common/libs/func_install_blfs@ 91e8eaa

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

Fix grepping for VERSION (func_install_blfs)
Add LFS-Release (update-lfs.sh and func_install_blfs)

  • Property mode set to 100644
File size: 8.3 KB
RevLine 
[e576789]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} ]] && mkdir -pv ${BUILDDIR}${BLFS_ROOT}
11cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
12cp -r menu ${BUILDDIR}${BLFS_ROOT}
13cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
14cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
[945ccaa]15if [ "$WRAP_INSTALL" = y ]; then
16 sed -e 's/PKGDIR/UNPACKDIR/' \
17 -e 's/PKG_DEST/PKG_DIR/' \
18 $PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
19fi
[e576789]20
21# Clean-up
22make -C ${BUILDDIR}${BLFS_ROOT}/menu clean
23rm -rf ${BUILDDIR}${BLFS_ROOT}/libs/.svn
24rm -rf ${BUILDDIR}${BLFS_ROOT}/xsl/.svn
25rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/.svn
26rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/lxdialog/.svn
27
28# Set some harcoded envars to their proper values
29sed -i s@tracking-dir@$TRACKING_DIR@ \
30 ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh}
31sed -i s@trunk/BOOK@$BLFS_TREE@ \
32 ${BUILDDIR}${BLFS_ROOT}/Makefile
33
[854854e]34# If we have a working copy, copy it:
35if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
[382b083]36echo "copying the local BLFS working copy (may take some time)"
[e58cf153]37# -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
[382b083]38# of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
39# book has already been validated, tmp is posterior to the others, and
40# validation will not be done again.
41 cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
[340c27e]42 ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
[854854e]43fi
[b8aa7ed]44
45# Copy the LFS book. Note that now, the book is downloaded before running
46# the BLFS tools.
47cp -ruT --preserve=timestamps $BOOK \
48 ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
49
[854854e]50# Downloads the book if necessary, initialize the tracking file and the
51# package database.
[e576789]52# sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
53# has to be created
[340c27e]54sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
55 REV=$INITSYS \
56 TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
[b8aa7ed]57 LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
58 LFS-SVN=$SVN_2/LFS/$TREE \
[340c27e]59 BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
60 SVN=$SVN_2/BLFS/$BLFS_TREE \
[26e6739]61 $BUILDDIR$BLFS_ROOT/packages.xml
[e576789]62
63# Because the BLFS Makefile is supposed to be used in chroot (or booted)
64# mode, the tracking file has wrong path for DTD. Change it:
65sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
66
67# Manually build a 'configuration' file
68if [ "$DEP_LIBXML" = y ]; then
69 LINE_LIBXML='CONFIG_libxml2=y'
70else
71 LINE_LIBXML='#CONFIG_libxml2 is not set'
72fi
73if [ "$DEP_LIBXSLT" = y ]; then
74 LINE_LIBXSLT='CONFIG_libxslt=y'
75else
76 LINE_LIBXSLT='#CONFIG_libxslt is not set'
77fi
[c1626d8]78# DocBook is a rec dep of libxslt
79# if [ "$DEP_DBXML" = y ]; then
80# LINE_DBXML='CONFIG_DocBook=y'
81# else
82# LINE_DBXML='#CONFIG_DocBook is not set'
83# fi
[e576789]84if [ "$DEP_LYNX" = y ]; then
85 LINE_LYNX='CONFIG_lynx=y'
86else
87 LINE_LYNX='#CONFIG_lynx is not set'
88fi
89if [ "$DEP_SUDO" = y ]; then
90 LINE_SUDO='CONFIG_sudo=y'
91else
92 LINE_SUDO='#CONFIG_sudo is not set'
93fi
94if [ "$DEP_WGET" = y ]; then
95 LINE_WGET='CONFIG_wget=y'
96else
97 LINE_WGET='#CONFIG_wget is not set'
98fi
99if [ "$DEP_GPM" = y ]; then
100 LINE_GPM='CONFIG_gpm=y'
101else
102 LINE_GPM='#CONFIG_gpm is not set'
103fi
104if [ "$DEP_SVN" = y ]; then
105 LINE_SVN='CONFIG_subversion=y'
106else
107 LINE_SVN='#CONFIG_subversion is not set'
108fi
109if [ "$DEP_OPENSSL" = y ]; then
110 LINE_OPENSSL='CONFIG_openssl=y'
111else
112 LINE_OPENSSL='#CONFIG_openssl is not set'
113fi
114if [ "$DEP_PYTHON" = y ]; then
115 LINE_PYTHON='CONFIG_python2=y'
116else
117 LINE_PYTHON='#CONFIG_python2 is not set'
118fi
119
120cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
[1f25a75]121$LINE_OPENSSL
[e576789]122$LINE_PYTHON
123$LINE_LIBXML
124$LINE_LIBXSLT
125$LINE_WGET
126$LINE_SVN
127$LINE_GPM
128$LINE_LYNX
129$LINE_SUDO
130MAIL_SERVER=sendmail
131optDependency=2
132SUDO=n
[945ccaa]133WRAP_INSTALL=$WRAP_INSTALL
[e576789]134EOF
135
136# Generates the scripts for the blfs tools dependencies (in ./scripts)
137yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh $BUILDDIR$BLFS_ROOT
138
139# Move the scriptlets where they should be
140sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
141mv scripts $BUILDDIR$BLFS_ROOT
142
143# Generates a list containing download and copying instructions for tarballs
144echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
[2cf28dc]145sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
146cp $PACKAGE $SRC_ARCHIVE
147p}' \
[39da010]148 -e '/|[ ]*md5sum/p' \
[2cf28dc]149 -e '/PACKAGE1=/,/^fi/{/^fi/a\
150cp $PACKAGE1 $SRC_ARCHIVE
151p}' \
152 -e '/PATCH=/,/^fi/{/^fi/a\
[cee84ad]153cp $PATCH $SRC_ARCHIVE
[2cf28dc]154p}' \
155 -e '/URL=/,/^fi/{/^fi/a\
[cee84ad]156cp $BOOTPACKG $SRC_ARCHIVE
[2cf28dc]157p}' \
[e576789]158 $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
159chmod u+x $BUILDDIR$BLFS_ROOT/download_script
160
161# Downloads (or copy) to build_dir/sources
162pushd $BUILDDIR/sources
163# Remove `unpacked' files if some have been left
164sudo find . -name unpacked -exec rm \{\} \;
[67723e1]165if [ "$GETPKG" = "y" ]; then
166 FTP_SERVER=$SERVER/pub/blfs/ \
[85506da]167 SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
[67723e1]168 $BUILDDIR$BLFS_ROOT/download_script
169else # Save the download script in case the user wants to run it later
170 cp $BUILDDIR$BLFS_ROOT/download_script .
171fi
[e576789]172popd
173rm -v $BUILDDIR$BLFS_ROOT/download_script
174
175# Suppresses unneeded parts of the scriptlets
[c1626d8]176if [ "$DEP_LIBXSLT" = y ]; then
[cbca63a]177 # libxslt pulls docbook-xsl in, which populates the catalog with annoying
178 # **EDITME** references. Fortunately, those lines are regognizable because
179 # they occur between lines containing '/etc/xml/catalog' at the end of the
180 # line (without '&&'). I have not found a simple way to delete lines
181 # between 2 addresses, excluding either the first or the last one. So use
182 # a loop for accumulating lines and deleting at the end.
183 # Sorry for sed synthax.
[c1626d8]184 sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
185n
186:a
187\@/etc/xml/catalog$@bb
188N
189ba
190:b
191d}' \
192 $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
193fi
[e576789]194if [ "$DEP_SUDO" = y ]; then
[cbca63a]195 sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
[e576789]196fi
197if [ "$DEP_SVN" = y ]; then
198 sed -i -e /javahl/d -e /swig/d $BUILDDIR$BLFS_ROOT/scripts/*subversion
199fi
200if [ "$DEP_LYNX" = y ]; then
201 if [ "$DEP_OPENSSL" = y -o "$DEP_WGET" = y ]; then
[67723e1]202 sed -e 's/configure/& --with-ssl/' \
203 -i $BUILDDIR$BLFS_ROOT/scripts/*lynx
[e576789]204 fi
205fi
206# At last generates the build Makefile
207mkdir -p $BUILDDIR$BLFS_ROOT/work
208pushd $BUILDDIR$BLFS_ROOT/work
209../gen-makefile.sh
[cbca63a]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
[e576789]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
[6d1d77c]219 @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
220 sed 's/.*>\([^<]*\)<.*/\1/' | \\
221 sort | uniq); do \\
[e3f4b9a4]222 VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
[6d1d77c]223 ../$LFS_XML/tmp/lfs-full.xml | \\
224 head -n2| \\
225 sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
226 xsltproc --stringparam packages ../packages.xml \\
227 --stringparam package \$\$pack \\
228 --stringparam version \$\$VERSION \\
229 -o track.tmp \\
230 ../xsl/bump.xsl \$(TRACKING_FILE); \\
231 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
232 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
233 rm track.tmp; \\
234 done; \\
[e3f4b9a4]235 VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
236 sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
237 xsltproc --stringparam packages ../packages.xml \\
238 --stringparam package LFS-Release \\
239 --stringparam version \$\$VERSION \\
240 -o track.tmp \\
241 ../xsl/bump.xsl \$(TRACKING_FILE); \\
242 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
243 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
244 rm track.tmp; \\
[6d1d77c]245 for file in *-*; do \\
246 xsltproc --stringparam packages ../packages.xml \\
247 --stringparam package \$\${file##*z-} \\
248 -o track.tmp \\
249 ../xsl/bump.xsl \$(TRACKING_FILE); \\
250 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
251 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
252 rm track.tmp; \\
[e576789]253 done
254 @touch \$@
255 @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
256 @echo --------------------------------------------------------------------------------\$(WHITE)
257EOF
258popd
259}
Note: See TracBrowser for help on using the repository browser.