source: common/libs/func_install_blfs@ dd5d63d

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

Adapt to git in func_install_blfs

  • Property mode set to 100644
File size: 8.1 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# Set some harcoded envars to their proper values
25sed -i s@tracking-dir@$TRACKING_DIR@ \
26 ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh}
27sed -i s@trunk/BOOK@$BLFS_TREE@ \
28 ${BUILDDIR}${BLFS_ROOT}/Makefile
29
30# If we have a working copy, copy it:
31if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
32echo "copying the local BLFS working copy (may take some time)"
33# -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
34# of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
35# book has already been validated, tmp is posterior to the others, and
36# validation will not be done again.
37 cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
38 ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
39fi
40
41# Copy the LFS book. Note that now, the book is downloaded before running
42# the BLFS tools.
43cp -ruT --preserve=timestamps $BOOK \
44 ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
45
46# Downloads the book if necessary, initialize the tracking file and the
47# package database.
48# sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
49# has to be created
50sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
51 REV=$INITSYS \
52 TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
53 LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
54 LFS-GIT=$GIT/lfs.git \
55 BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
56 GIT=$GIT/blfs.git \
57 $BUILDDIR$BLFS_ROOT/packages.xml
58
59# But then $BUILDDIR/var/lib/ is owned by root if just created, which
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
64
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
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
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
106if [ "$DEP_GIT" = y ]; then
107 LINE_GIT='CONFIG_git=y'
108else
109 LINE_GIT='#CONFIG_git is not set'
110fi
111
112cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
113$LINE_LIBXML
114$LINE_LIBXSLT
115$LINE_WGET
116$LINE_GIT
117$LINE_GPM
118$LINE_LYNX
119$LINE_SUDO
120MAIL_SERVER=sendmail
121optDependency=2
122SUDO=n
123LANGUAGE=$LANG
124WRAP_INSTALL=$WRAP_INSTALL
125DEL_LA_FILES=$DEL_LA_FILES
126STATS=n
127EOF
128
129# Generates the scripts for the blfs tools dependencies (in ./scripts)
130yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh $BUILDDIR$BLFS_ROOT
131
132# Move the scriptlets where they should be
133sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
134mv scripts $BUILDDIR$BLFS_ROOT
135
136# Generates a list containing download and copying instructions for tarballs
137echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
138sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
139cp $PACKAGE $JH_SRC_ARCHIVE
140p}' \
141 -e '/|[ ]*md5sum/p' \
142 -e '/PACKAGE1=/,/^fi/{/^fi/a\
143cp $PACKAGE1 $JH_SRC_ARCHIVE
144p}' \
145 -e '/PATCH=/,/^fi/{/^fi/a\
146cp $PATCH $JH_SRC_ARCHIVE
147p}' \
148 -e '/URL=/,/^fi/{/^fi/a\
149cp $BOOTPACKG $JH_SRC_ARCHIVE
150p}' \
151 $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
152chmod u+x $BUILDDIR$BLFS_ROOT/download_script
153
154# Downloads (or copy) to build_dir/sources
155pushd $BUILDDIR/sources
156# Remove `unpacked' files if some have been left
157sudo find . -name unpacked -exec rm \{\} \;
158if [ "$GETPKG" = "y" ]; then
159 JH_FTP_SERVER=$SERVER/pub/blfs/ \
160 JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
161 $BUILDDIR$BLFS_ROOT/download_script
162else # Save the download script in case the user wants to run it later
163 cp $BUILDDIR$BLFS_ROOT/download_script .
164fi
165popd
166rm -v $BUILDDIR$BLFS_ROOT/download_script
167
168# Suppresses unneeded parts of the scriptlets
169if [ "$DEP_LIBXSLT" = y ]; then
170 # libxslt pulls docbook-xsl in, which populates the catalog with annoying
171 # **EDITME** references. Fortunately, those lines are regognizable because
172 # they occur between lines containing '/etc/xml/catalog' at the end of the
173 # line (without '&&'). I have not found a simple way to delete lines
174 # between 2 addresses, excluding either the first or the last one. So use
175 # a loop for accumulating lines and deleting at the end.
176 # Sorry for sed syntax.
177 sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
178n
179:a
180\@/etc/xml/catalog$@bb
181N
182ba
183:b
184d}' \
185 $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
186fi
187if [ "$DEP_SUDO" = y ]; then
188 sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
189fi
190# At last generates the build Makefile
191mkdir -p $BUILDDIR$BLFS_ROOT/work
192pushd $BUILDDIR$BLFS_ROOT/work
193../gen-makefile.sh
194# The generated Makefile updates the tracking file after each package
195# installation, using libxslt, which is not installed yet. So move
196# updating to the end of the process, adding an 'update' target
197sed -i -e '/xsltproc/,+6d' \
198 -e '/^all/s@$@ update@' \
199 -e 's/touch/@touch/' Makefile
200cat >> Makefile << EOF
201update:
202 @echo Updating the tracking file
203 @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
204 sed 's/.*>\([^<]*\)<.*/\1/' | \\
205 sort | uniq); do \\
206 case "x\$\$pack" in \\
207 xgcc* | *pass[12] | xvim | \\
208 xshadow | xPython | xlinux-headers | xdbus | xsystemd )\\
209 continue ;; \\
210 esac; \\
211 VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
212 ../$LFS_XML/tmp/lfs-full.xml | \\
213 head -n2| \\
214 sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
215 xsltproc --stringparam packages ../packages.xml \\
216 --stringparam package \$\$pack \\
217 --stringparam version \$\$VERSION \\
218 -o track.tmp \\
219 ../xsl/bump.xsl \$(TRACKING_FILE); \\
220 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
221 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
222 rm track.tmp; \\
223 done; \\
224 VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
225 sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
226 xsltproc --stringparam packages ../packages.xml \\
227 --stringparam package LFS-Release \\
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 for file in *-*; do \\
235 xsltproc --stringparam packages ../packages.xml \\
236 --stringparam package \$\${file##*z-} \\
237 -o track.tmp \\
238 ../xsl/bump.xsl \$(TRACKING_FILE); \\
239 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
240 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
241 rm track.tmp; \\
242 done
243 @touch \$@
244 @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
245 @echo --------------------------------------------------------------------------------\$(WHITE)
246EOF
247popd
248}
Note: See TracBrowser for help on using the repository browser.