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