source: common/libs/func_install_blfs@ bc64795

ablfs-more trunk
Last change on this file since bc64795 was c1f02f2, checked in by Pierre Labastie <pierre.labastie@…>, 10 months ago

LFS: remove alternate server code

It's been broken for years, and nobody has complained, so I'd say
it is not useful. If a user wants to use a mirror instead of upstream,
better use a wget-list directly on this server...

  • Property mode set to 100644
File size: 9.3 KB
RevLine 
[e576789]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
[106157fd]8[[ ! -d "${BUILDDIR}${BLFS_ROOT}" ]] && {
9 sudo mkdir -pv "${BUILDDIR}${BLFS_ROOT}"
10 sudo chown "$USER" "${BUILDDIR}${BLFS_ROOT}"
[c7b535b]11}
[e576789]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}
[945ccaa]16if [ "$WRAP_INSTALL" = y ]; then
[1fa0dee]17 sed -e 's/PKGDIR/JH_UNPACKDIR/' \
18 -e 's/PKG_DEST/JH_PKG_DIR/' \
[945ccaa]19 $PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
20fi
[e576789]21
22# Set some harcoded envars to their proper values
23sed -i s@tracking-dir@$TRACKING_DIR@ \
[b734bfb]24 ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
[e576789]25
[854854e]26# If we have a working copy, copy it:
27if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
[382b083]28echo "copying the local BLFS working copy (may take some time)"
[e58cf153]29# -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
[382b083]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.
[2c1a763]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 \
[340c27e]36 ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
[854854e]37fi
[b8aa7ed]38
39# Copy the LFS book. Note that now, the book is downloaded before running
40# the BLFS tools.
[2c1a763]41sudo cp -ruT --preserve=timestamps $BOOK \
[b8aa7ed]42 ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
43
[854854e]44# Downloads the book if necessary, initialize the tracking file and the
45# package database.
[2c1a763]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).
[e576789]51# sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
52# has to be created
[2c1a763]53sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
54 REV=$INITSYS \
55 LFS-BRANCH=${COMMIT} \
[9b99ada]56 BLFS-BRANCH=${BLFS_COMMIT} \
[2c1a763]57 update
[340c27e]58sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
59 REV=$INITSYS \
60 TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
[b8aa7ed]61 LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
[2fd624d]62 LFS-BRANCH="${COMMIT}" \
[340c27e]63 BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
[9b99ada]64 BLFS-BRANCH=${BLFS_COMMIT} \
[26e6739]65 $BUILDDIR$BLFS_ROOT/packages.xml
[e576789]66
[ae1d8a5]67# But then $BUILDDIR/var/lib/ is owned by root if just created, which
[088130f]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
[ae1d8a5]72
[e576789]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
[c1626d8]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
[e576789]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
[dd5d63d]114if [ "$DEP_GIT" = y ]; then
115 LINE_GIT='CONFIG_git=y'
[e576789]116else
[dd5d63d]117 LINE_GIT='#CONFIG_git is not set'
[e576789]118fi
119
120cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
121$LINE_LIBXML
122$LINE_LIBXSLT
123$LINE_WGET
[dd5d63d]124$LINE_GIT
[e576789]125$LINE_GPM
126$LINE_LYNX
127$LINE_SUDO
128MAIL_SERVER=sendmail
129optDependency=2
130SUDO=n
[625cb14]131LANGUAGE=$LANG
[945ccaa]132WRAP_INSTALL=$WRAP_INSTALL
[267b19d]133PACK_INSTALL=/blfs_root/packInstall.sh
[dc7fd7b]134DEL_LA_FILES=$DEL_LA_FILES
[625cb14]135STATS=n
[267b19d]136SRC_ARCHIVE=/sources
137BUILD_ROOT=/sources
138BUILD_SUBDIRS=y
139JOBS=$(if [ -n "$N_PARALLEL" ]; then echo $N_PARALLEL; else echo 1; fi)
[e576789]140EOF
[267b19d]141for OPT_VAR in CFLAGS CXXFLAGS LDFLAGS; do
142 eval optVal=\$${OPT_VAR}_$DEF_OPT_MODE
143 if [ -n "$optVal" ] && [ "$optVal" != unset ]; then
144 echo "CFG_$OPT_VAR"=\"$optVal\" >> $BUILDDIR$BLFS_ROOT/configuration
145 else
146 echo "CFG_$OPT_VAR"=EMPTY >> $BUILDDIR$BLFS_ROOT/configuration
147 fi
148done
[e576789]149
150# Generates the scripts for the blfs tools dependencies (in ./scripts)
[f81d8bd]151yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh \
152 $BUILDDIR$TRACKING_DIR/instpkg.xml \
153 $BUILDDIR$BLFS_ROOT
[e576789]154
155# Move the scriptlets where they should be
156sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
157mv scripts $BUILDDIR$BLFS_ROOT
158
159# Generates a list containing download and copying instructions for tarballs
160echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
[2cf28dc]161sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
[30a444a]162[ ! -f "$JH_SRC_ARCHIVE/$PACKAGE" ] && cp $PACKAGE $JH_SRC_ARCHIVE
[2cf28dc]163p}' \
[39da010]164 -e '/|[ ]*md5sum/p' \
[2cf28dc]165 -e '/PACKAGE1=/,/^fi/{/^fi/a\
[30a444a]166[ ! -f "$JH_SRC_ARCHIVE/$PACKAGE1" ] && cp $PACKAGE1 $JH_SRC_ARCHIVE
[2cf28dc]167p}' \
168 -e '/PATCH=/,/^fi/{/^fi/a\
[30a444a]169[ ! -f "$JH_SRC_ARCHIVE/$PATCH" ] && cp $PATCH $JH_SRC_ARCHIVE
[2cf28dc]170p}' \
171 -e '/URL=/,/^fi/{/^fi/a\
[30a444a]172[ ! -f "$JH_SRC_ARCHIVE/$BOOTPACKG" ] && cp $BOOTPACKG $JH_SRC_ARCHIVE
[2cf28dc]173p}' \
[e576789]174 $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
175chmod u+x $BUILDDIR$BLFS_ROOT/download_script
176
177# Downloads (or copy) to build_dir/sources
178pushd $BUILDDIR/sources
179# Remove `unpacked' files if some have been left
180sudo find . -name unpacked -exec rm \{\} \;
[67723e1]181if [ "$GETPKG" = "y" ]; then
[1fa0dee]182 JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
[67723e1]183 $BUILDDIR$BLFS_ROOT/download_script
184else # Save the download script in case the user wants to run it later
185 cp $BUILDDIR$BLFS_ROOT/download_script .
186fi
[e576789]187popd
188rm -v $BUILDDIR$BLFS_ROOT/download_script
189
190# Suppresses unneeded parts of the scriptlets
[c1626d8]191if [ "$DEP_LIBXSLT" = y ]; then
[cbca63a]192 # libxslt pulls docbook-xsl in, which populates the catalog with annoying
193 # **EDITME** references. Fortunately, those lines are regognizable because
194 # they occur between lines containing '/etc/xml/catalog' at the end of the
195 # line (without '&&'). I have not found a simple way to delete lines
196 # between 2 addresses, excluding either the first or the last one. So use
197 # a loop for accumulating lines and deleting at the end.
[4b2a5fd]198 # Sorry for sed syntax.
[c1626d8]199 sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
200n
201:a
202\@/etc/xml/catalog$@bb
203N
204ba
205:b
206d}' \
207 $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
208fi
[e576789]209if [ "$DEP_SUDO" = y ]; then
[cbca63a]210 sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
[e576789]211fi
212# At last generates the build Makefile
213mkdir -p $BUILDDIR$BLFS_ROOT/work
214pushd $BUILDDIR$BLFS_ROOT/work
215../gen-makefile.sh
[cbca63a]216# The generated Makefile updates the tracking file after each package
217# installation, using libxslt, which is not installed yet. So move
218# updating to the end of the process, adding an 'update' target
[e576789]219sed -i -e '/xsltproc/,+6d' \
220 -e '/^all/s@$@ update@' \
221 -e 's/touch/@touch/' Makefile
222cat >> Makefile << EOF
223update:
224 @echo Updating the tracking file
[6d1d77c]225 @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
226 sed 's/.*>\([^<]*\)<.*/\1/' | \\
227 sort | uniq); do \\
[a1795f0]228 case "x\$\$pack" in \\
[ea0be93]229 xgcc* | *pass[12] | xvim | \\
[a1795f0]230 xshadow | xPython | xlinux-headers | xdbus | xsystemd )\\
231 continue ;; \\
232 esac; \\
[e3f4b9a4]233 VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
[6d1d77c]234 ../$LFS_XML/tmp/lfs-full.xml | \\
235 head -n2| \\
236 sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
237 xsltproc --stringparam packages ../packages.xml \\
238 --stringparam package \$\$pack \\
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; \\
245 done; \\
[e3f4b9a4]246 VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
247 sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
248 xsltproc --stringparam packages ../packages.xml \\
249 --stringparam package LFS-Release \\
250 --stringparam version \$\$VERSION \\
251 -o track.tmp \\
252 ../xsl/bump.xsl \$(TRACKING_FILE); \\
253 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
254 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
255 rm track.tmp; \\
[6d1d77c]256 for file in *-*; do \\
257 xsltproc --stringparam packages ../packages.xml \\
258 --stringparam package \$\${file##*z-} \\
259 -o track.tmp \\
260 ../xsl/bump.xsl \$(TRACKING_FILE); \\
261 sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
262 xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
263 rm track.tmp; \\
[e576789]264 done
265 @touch \$@
266 @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
267 @echo --------------------------------------------------------------------------------\$(WHITE)
268EOF
269popd
270}
Note: See TracBrowser for help on using the repository browser.