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/UNPACKDIR/' \
|
---|
17 | -e 's/PKG_DEST/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 | # Downloads the book if necessary, initialize the tracking file and the
|
---|
45 | # package database.
|
---|
46 | # sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
|
---|
47 | # has to be created
|
---|
48 | sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
|
---|
49 | REV=$INITSYS \
|
---|
50 | TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
|
---|
51 | BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
|
---|
52 | SVN=$SVN_2/BLFS/$BLFS_TREE \
|
---|
53 | $BUILDDIR$BLFS_ROOT/packages.xml
|
---|
54 |
|
---|
55 | # Because the BLFS Makefile is supposed to be used in chroot (or booted)
|
---|
56 | # mode, the tracking file has wrong path for DTD. Change it:
|
---|
57 | sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
|
---|
58 |
|
---|
59 | # Manually build a 'configuration' file
|
---|
60 | if [ "$DEP_LIBXML" = y ]; then
|
---|
61 | LINE_LIBXML='CONFIG_libxml2=y'
|
---|
62 | else
|
---|
63 | LINE_LIBXML='#CONFIG_libxml2 is not set'
|
---|
64 | fi
|
---|
65 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
66 | LINE_LIBXSLT='CONFIG_libxslt=y'
|
---|
67 | else
|
---|
68 | LINE_LIBXSLT='#CONFIG_libxslt is not set'
|
---|
69 | fi
|
---|
70 | # DocBook is a rec dep of libxslt
|
---|
71 | # if [ "$DEP_DBXML" = y ]; then
|
---|
72 | # LINE_DBXML='CONFIG_DocBook=y'
|
---|
73 | # else
|
---|
74 | # LINE_DBXML='#CONFIG_DocBook is not set'
|
---|
75 | # fi
|
---|
76 | if [ "$DEP_LYNX" = y ]; then
|
---|
77 | LINE_LYNX='CONFIG_lynx=y'
|
---|
78 | else
|
---|
79 | LINE_LYNX='#CONFIG_lynx is not set'
|
---|
80 | fi
|
---|
81 | if [ "$DEP_SUDO" = y ]; then
|
---|
82 | LINE_SUDO='CONFIG_sudo=y'
|
---|
83 | else
|
---|
84 | LINE_SUDO='#CONFIG_sudo is not set'
|
---|
85 | fi
|
---|
86 | if [ "$DEP_WGET" = y ]; then
|
---|
87 | LINE_WGET='CONFIG_wget=y'
|
---|
88 | else
|
---|
89 | LINE_WGET='#CONFIG_wget is not set'
|
---|
90 | fi
|
---|
91 | if [ "$DEP_GPM" = y ]; then
|
---|
92 | LINE_GPM='CONFIG_gpm=y'
|
---|
93 | else
|
---|
94 | LINE_GPM='#CONFIG_gpm is not set'
|
---|
95 | fi
|
---|
96 | if [ "$DEP_SVN" = y ]; then
|
---|
97 | LINE_SVN='CONFIG_subversion=y'
|
---|
98 | else
|
---|
99 | LINE_SVN='#CONFIG_subversion is not set'
|
---|
100 | fi
|
---|
101 | if [ "$DEP_OPENSSL" = y ]; then
|
---|
102 | LINE_OPENSSL='CONFIG_openssl=y'
|
---|
103 | else
|
---|
104 | LINE_OPENSSL='#CONFIG_openssl is not set'
|
---|
105 | fi
|
---|
106 | if [ "$DEP_PYTHON" = y ]; then
|
---|
107 | LINE_PYTHON='CONFIG_python2=y'
|
---|
108 | else
|
---|
109 | LINE_PYTHON='#CONFIG_python2 is not set'
|
---|
110 | fi
|
---|
111 |
|
---|
112 | cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
|
---|
113 | $LINE_OPENSSL
|
---|
114 | $LINE_PYTHON
|
---|
115 | $LINE_LIBXML
|
---|
116 | $LINE_LIBXSLT
|
---|
117 | $LINE_WGET
|
---|
118 | $LINE_SVN
|
---|
119 | $LINE_GPM
|
---|
120 | $LINE_LYNX
|
---|
121 | $LINE_SUDO
|
---|
122 | MAIL_SERVER=sendmail
|
---|
123 | optDependency=2
|
---|
124 | SUDO=n
|
---|
125 | WRAP_INSTALL=$WRAP_INSTALL
|
---|
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 $SRC_ARCHIVE
|
---|
139 | p}' \
|
---|
140 | -e '/|[ ]*md5sum/p' \
|
---|
141 | -e '/PACKAGE1=/,/^fi/{/^fi/a\
|
---|
142 | cp $PACKAGE1 $SRC_ARCHIVE
|
---|
143 | p}' \
|
---|
144 | -e '/PATCH=/,/^fi/{/^fi/a\
|
---|
145 | cp $PATCH $SRC_ARCHIVE
|
---|
146 | p}' \
|
---|
147 | -e '/URL=/,/^fi/{/^fi/a\
|
---|
148 | cp $BOOTPACKG $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 | FTP_SERVER=$SERVER/pub/blfs/ \
|
---|
159 | 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 synthax.
|
---|
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 | if [ "$DEP_LYNX" = y ]; then
|
---|
193 | if [ "$DEP_OPENSSL" = y -o "$DEP_WGET" = y ]; then
|
---|
194 | sed -e 's/configure/& --with-ssl/' \
|
---|
195 | -i $BUILDDIR$BLFS_ROOT/scripts/*lynx
|
---|
196 | fi
|
---|
197 | fi
|
---|
198 | # At last generates the build Makefile
|
---|
199 | mkdir -p $BUILDDIR$BLFS_ROOT/work
|
---|
200 | pushd $BUILDDIR$BLFS_ROOT/work
|
---|
201 | ../gen-makefile.sh
|
---|
202 | # The generated Makefile updates the tracking file after each package
|
---|
203 | # installation, using libxslt, which is not installed yet. So move
|
---|
204 | # updating to the end of the process, adding an 'update' target
|
---|
205 | sed -i -e '/xsltproc/,+6d' \
|
---|
206 | -e '/^all/s@$@ update@' \
|
---|
207 | -e 's/touch/@touch/' Makefile
|
---|
208 | cat >> Makefile << EOF
|
---|
209 | update:
|
---|
210 | @echo Updating the tracking file
|
---|
211 | @for file in *-*; do \\
|
---|
212 | xsltproc --stringparam packages ../packages.xml \\
|
---|
213 | --stringparam package \$\${file##*z-} \\
|
---|
214 | -o track.tmp \\
|
---|
215 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
216 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
217 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
218 | rm track.tmp; \\
|
---|
219 | done
|
---|
220 | @touch \$@
|
---|
221 | @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
|
---|
222 | @echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
223 | EOF
|
---|
224 | popd
|
---|
225 | }
|
---|