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