source: common/libs/func_install_blfs@ c5f4ef3

ablfs-more trunk
Last change on this file since c5f4ef3 was 924076f, checked in by Pierre Labastie <pierre.labastie@…>, 12 months ago

blfs tools: fix JOBS

If all cores are used, it should be set to 0, which will use nproc
after the cpuset has been defined, and not nproc (which is the number
of cores/threads on the machine).

  • 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}
25
26# If we have a working copy, copy it:
27if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
28echo "copying the local BLFS working copy (may take some time)"
29# -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
30# of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
31# book has already been validated, tmp is posterior to the others, and
32# validation will not be done again.
33# sudo is needed because make (below) may already have been run and
34# may have put some files owned by root
35 sudo cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
36 ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
37fi
38
39# Copy the LFS book. Note that now, the book is downloaded before running
40# the BLFS tools.
41sudo cp -ruT --preserve=timestamps $BOOK \
42 ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
43
44# Downloads the book if necessary, initialize the tracking file and the
45# package database.
46# updating first is needed if the xml sources have already been cloned
47# and we want to set the branches.
48# Note that if LFS-BRANCH or BLFS-BRANCH is empty, which may happen
49# if using a working copy, then the corresponding update is not
50# performed by make (see BLFS/Makefile).
51# sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
52# has to be created
53sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
54 REV=$INITSYS \
55 LFS-BRANCH=${COMMIT} \
56 BLFS-BRANCH=${BLFS_COMMIT} \
57 update
58sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
59 REV=$INITSYS \
60 TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
61 LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
62 LFS-BRANCH="${COMMIT}" \
63 BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
64 BLFS-BRANCH=${BLFS_COMMIT} \
65 $BUILDDIR$BLFS_ROOT/packages.xml
66
67# But then $BUILDDIR/var/lib/ is owned by root if just created, which
68# prevents $LUSER to create "nss_db". The problem is that $LUSER
69# May not have been created yet. So do not change ownership here
70# and do it in master.sh for chapter 4.
71#sudo chown $LUSER:$LGROUP $BUILDDIR/var/lib
72
73# Because the BLFS Makefile is supposed to be used in chroot (or booted)
74# mode, the tracking file has wrong path for DTD. Change it:
75sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
76
77# Manually build a 'configuration' file
78if [ "$DEP_LIBXML" = y ]; then
79 LINE_LIBXML='CONFIG_libxml2=y'
80else
81 LINE_LIBXML='#CONFIG_libxml2 is not set'
82fi
83if [ "$DEP_LIBXSLT" = y ]; then
84 LINE_LIBXSLT='CONFIG_libxslt=y'
85else
86 LINE_LIBXSLT='#CONFIG_libxslt is not set'
87fi
88# DocBook is a rec dep of libxslt
89# if [ "$DEP_DBXML" = y ]; then
90# LINE_DBXML='CONFIG_DocBook=y'
91# else
92# LINE_DBXML='#CONFIG_DocBook is not set'
93# fi
94if [ "$DEP_LYNX" = y ]; then
95 LINE_LYNX='CONFIG_lynx=y'
96else
97 LINE_LYNX='#CONFIG_lynx is not set'
98fi
99if [ "$DEP_SUDO" = y ]; then
100 LINE_SUDO='CONFIG_sudo=y'
101else
102 LINE_SUDO='#CONFIG_sudo is not set'
103fi
104if [ "$DEP_WGET" = y ]; then
105 LINE_WGET='CONFIG_wget=y'
106else
107 LINE_WGET='#CONFIG_wget is not set'
108fi
109if [ "$DEP_GPM" = y ]; then
110 LINE_GPM='CONFIG_gpm=y'
111else
112 LINE_GPM='#CONFIG_gpm is not set'
113fi
114if [ "$DEP_GIT" = y ]; then
115 LINE_GIT='CONFIG_git=y'
116else
117 LINE_GIT='#CONFIG_git is not set'
118fi
119
120cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
121$LINE_LIBXML
122$LINE_LIBXSLT
123$LINE_WGET
124$LINE_GIT
125$LINE_GPM
126$LINE_LYNX
127$LINE_SUDO
128MAIL_SERVER=sendmail
129optDependency=2
130SUDO=n
131LANGUAGE=$LANG
132WRAP_INSTALL=$WRAP_INSTALL
133PACK_INSTALL=/blfs_root/packInstall.sh
134DEL_LA_FILES=$DEL_LA_FILES
135STATS=n
136SRC_ARCHIVE=/sources
137BUILD_ROOT=/sources
138BUILD_SUBDIRS=y
139JOBS=$(if [ "$ALL_CORES" = y ]; then echo 0; else echo $N_PARALLEL; fi)
140EOF
141# The 0 value above is for using all cores
142for OPT_VAR in CFLAGS CXXFLAGS LDFLAGS; do
143 eval optVal=\$${OPT_VAR}_$DEF_OPT_MODE
144 if [ -n "$optVal" ] && [ "$optVal" != unset ]; then
145 echo "CFG_$OPT_VAR"=\"$optVal\" >> $BUILDDIR$BLFS_ROOT/configuration
146 else
147 echo "CFG_$OPT_VAR"=EMPTY >> $BUILDDIR$BLFS_ROOT/configuration
148 fi
149done
150
151# Generates the scripts for the blfs tools dependencies (in ./scripts)
152yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh \
153 $BUILDDIR$TRACKING_DIR/instpkg.xml \
154 $BUILDDIR$BLFS_ROOT
155
156# Move the scriptlets where they should be
157sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
158mv scripts $BUILDDIR$BLFS_ROOT
159
160# Generates a list containing download and copying instructions for tarballs
161echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
162sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
163[ ! -f "$JH_SRC_ARCHIVE/$PACKAGE" ] && cp $PACKAGE $JH_SRC_ARCHIVE
164p}' \
165 -e '/|[ ]*md5sum/p' \
166 -e '/PACKAGE1=/,/^fi/{/^fi/a\
167[ ! -f "$JH_SRC_ARCHIVE/$PACKAGE1" ] && cp $PACKAGE1 $JH_SRC_ARCHIVE
168p}' \
169 -e '/PATCH=/,/^fi/{/^fi/a\
170[ ! -f "$JH_SRC_ARCHIVE/$PATCH" ] && cp $PATCH $JH_SRC_ARCHIVE
171p}' \
172 -e '/URL=/,/^fi/{/^fi/a\
173[ ! -f "$JH_SRC_ARCHIVE/$BOOTPACKG" ] && cp $BOOTPACKG $JH_SRC_ARCHIVE
174p}' \
175 $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
176chmod u+x $BUILDDIR$BLFS_ROOT/download_script
177
178# Downloads (or copy) to build_dir/sources
179pushd $BUILDDIR/sources
180# Remove `unpacked' files if some have been left
181sudo find . -name unpacked -exec rm \{\} \;
182if [ "$GETPKG" = "y" ]; then
183 JH_FTP_SERVER=$SERVER/pub/blfs/ \
184 JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
185 $BUILDDIR$BLFS_ROOT/download_script
186else # Save the download script in case the user wants to run it later
187 cp $BUILDDIR$BLFS_ROOT/download_script .
188fi
189popd
190rm -v $BUILDDIR$BLFS_ROOT/download_script
191
192# Suppresses unneeded parts of the scriptlets
193if [ "$DEP_LIBXSLT" = y ]; then
194 # libxslt pulls docbook-xsl in, which populates the catalog with annoying
195 # **EDITME** references. Fortunately, those lines are regognizable because
196 # they occur between lines containing '/etc/xml/catalog' at the end of the
197 # line (without '&&'). I have not found a simple way to delete lines
198 # between 2 addresses, excluding either the first or the last one. So use
199 # a loop for accumulating lines and deleting at the end.
200 # Sorry for sed syntax.
201 sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
202n
203:a
204\@/etc/xml/catalog$@bb
205N
206ba
207:b
208d}' \
209 $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
210fi
211if [ "$DEP_SUDO" = y ]; then
212 sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
213fi
214# At last generates the build Makefile
215mkdir -p $BUILDDIR$BLFS_ROOT/work
216pushd $BUILDDIR$BLFS_ROOT/work
217../gen-makefile.sh
218# The generated Makefile updates the tracking file after each package
219# installation, using libxslt, which is not installed yet. So move
220# updating to the end of the process, adding an 'update' target
221sed -i -e '/xsltproc/,+6d' \
222 -e '/^all/i update:' \
223 -e 's/touch/@touch/' Makefile
224cat >> Makefile << EOF
225update: all
226 @echo Updating the tracking file
227 @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
228 sed 's/.*>\([^<]*\)<.*/\1/' | \\
229 sort | uniq); do \\
230 case "x\$\$pack" in \\
231 xgcc* | *pass[12] | xvim | \\
232 xshadow | xPython | xlinux-headers | xdbus | xsystemd )\\
233 continue ;; \\
234 esac; \\
235 VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
236 ../$LFS_XML/tmp/lfs-full.xml | \\
237 head -n2| \\
238 sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
239 xsltproc --stringparam packages ../packages.xml \\
240 --stringparam package \$\$pack \\
241 --stringparam version \$\$VERSION \\
242 -o track.tmp \\
243 ../xsl/bump.xsl \$(TRACKING_FILE); \\
244 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
245 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
246 rm track.tmp; \\
247 done; \\
248 VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
249 sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
250 xsltproc --stringparam packages ../packages.xml \\
251 --stringparam package LFS-Release \\
252 --stringparam version \$\$VERSION \\
253 -o track.tmp \\
254 ../xsl/bump.xsl \$(TRACKING_FILE); \\
255 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
256 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
257 rm track.tmp; \\
258 for file in *-*; do \\
259 xsltproc --stringparam packages ../packages.xml \\
260 --stringparam package \$\${file##*z-} \\
261 -o track.tmp \\
262 ../xsl/bump.xsl \$(TRACKING_FILE); \\
263 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
264 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
265 rm track.tmp; \\
266 done
267 @touch \$@
268 @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
269 @echo --------------------------------------------------------------------------------\$(WHITE)
270EOF
271popd
272}
Note: See TracBrowser for help on using the repository browser.