source: common/libs/func_install_blfs@ 8c2b505

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

try to fix func_install_blfs to work in all cases

WIP...

  • Property mode set to 100644
File size: 9.3 KB
Line 
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
8[[ ! -d "${BUILDDIR}${BLFS_ROOT}" ]] && {
9 sudo mkdir -pv "${BUILDDIR}${BLFS_ROOT}"
10 sudo chown "$USER" "${BUILDDIR}${BLFS_ROOT}"
11}
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}
16if [ "$WRAP_INSTALL" = y ]; then
17 sed -e 's/PKGDIR/JH_UNPACKDIR/' \
18 -e 's/PKG_DEST/JH_PKG_DIR/' \
19 $PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
20fi
21
22# Set some harcoded envars to their proper values
23sed -i s@tracking-dir@$TRACKING_DIR@ \
24 ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
25sed -i s@trunk/BOOK@$BLFS_TREE@ \
26 ${BUILDDIR}${BLFS_ROOT}/Makefile
27
28# If we have a working copy, copy it:
29if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
30echo "copying the local BLFS working copy (may take some time)"
31# -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
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.
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 \
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.
43sudo cp -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# 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).
53# sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
54# has to be created
55sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
56 REV=$INITSYS \
57 LFS-BRANCH=${COMMIT} \
58 BLFS-BRANCH=${BLFS_TREE} \
59 update
60sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
61 REV=$INITSYS \
62 TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
63 LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
64 LFS-BRANCH="${COMMIT}" \
65 BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
66 BLFS-BRANCH=${BLFS_TREE} \
67 update \
68 $BUILDDIR$BLFS_ROOT/packages.xml
69
70# But then $BUILDDIR/var/lib/ is owned by root if just created, which
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
75
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
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
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
117if [ "$DEP_GIT" = y ]; then
118 LINE_GIT='CONFIG_git=y'
119else
120 LINE_GIT='#CONFIG_git is not set'
121fi
122
123cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
124$LINE_LIBXML
125$LINE_LIBXSLT
126$LINE_WGET
127$LINE_GIT
128$LINE_GPM
129$LINE_LYNX
130$LINE_SUDO
131MAIL_SERVER=sendmail
132optDependency=2
133SUDO=n
134LANGUAGE=$LANG
135WRAP_INSTALL=$WRAP_INSTALL
136PACK_INSTALL=/blfs_root/packInstall.sh
137DEL_LA_FILES=$DEL_LA_FILES
138STATS=n
139SRC_ARCHIVE=/sources
140BUILD_ROOT=/sources
141BUILD_SUBDIRS=y
142JOBS=$(if [ -n "$N_PARALLEL" ]; then echo $N_PARALLEL; else echo 1; fi)
143EOF
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
152
153# Generates the scripts for the blfs tools dependencies (in ./scripts)
154yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh \
155 $BUILDDIR$TRACKING_DIR/instpkg.xml \
156 $BUILDDIR$BLFS_ROOT
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
164sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
165cp $PACKAGE $JH_SRC_ARCHIVE
166p}' \
167 -e '/|[ ]*md5sum/p' \
168 -e '/PACKAGE1=/,/^fi/{/^fi/a\
169cp $PACKAGE1 $JH_SRC_ARCHIVE
170p}' \
171 -e '/PATCH=/,/^fi/{/^fi/a\
172cp $PATCH $JH_SRC_ARCHIVE
173p}' \
174 -e '/URL=/,/^fi/{/^fi/a\
175cp $BOOTPACKG $JH_SRC_ARCHIVE
176p}' \
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 \{\} \;
184if [ "$GETPKG" = "y" ]; then
185 JH_FTP_SERVER=$SERVER/pub/blfs/ \
186 JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
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
191popd
192rm -v $BUILDDIR$BLFS_ROOT/download_script
193
194# Suppresses unneeded parts of the scriptlets
195if [ "$DEP_LIBXSLT" = y ]; then
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.
202 # Sorry for sed syntax.
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
213if [ "$DEP_SUDO" = y ]; then
214 sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
215fi
216# At last generates the build Makefile
217mkdir -p $BUILDDIR$BLFS_ROOT/work
218pushd $BUILDDIR$BLFS_ROOT/work
219../gen-makefile.sh
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
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
229 @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
230 sed 's/.*>\([^<]*\)<.*/\1/' | \\
231 sort | uniq); do \\
232 case "x\$\$pack" in \\
233 xgcc* | *pass[12] | xvim | \\
234 xshadow | xPython | xlinux-headers | xdbus | xsystemd )\\
235 continue ;; \\
236 esac; \\
237 VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
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; \\
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; \\
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; \\
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.