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