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 |
|
---|
16 | # Clean-up
|
---|
17 | make -C ${BUILDDIR}${BLFS_ROOT}/menu clean
|
---|
18 | rm -rf ${BUILDDIR}${BLFS_ROOT}/libs/.svn
|
---|
19 | rm -rf ${BUILDDIR}${BLFS_ROOT}/xsl/.svn
|
---|
20 | rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/.svn
|
---|
21 | rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/lxdialog/.svn
|
---|
22 |
|
---|
23 | # Set some harcoded envars to their proper values
|
---|
24 | sed -i s@tracking-dir@$TRACKING_DIR@ \
|
---|
25 | ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh}
|
---|
26 | sed -i s@trunk/BOOK@$BLFS_TREE@ \
|
---|
27 | ${BUILDDIR}${BLFS_ROOT}/Makefile
|
---|
28 |
|
---|
29 | # If we have a working copy, copy it:
|
---|
30 | if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
|
---|
31 | echo "copying the local BLFS working copy (may take some time)"
|
---|
32 | # -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
|
---|
33 | # of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
|
---|
34 | # book has already been validated, tmp is posterior to the others, and
|
---|
35 | # validation will not be done again.
|
---|
36 | cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
|
---|
37 | ${BUILDDIR}${BLFS_ROOT}/blfs-xml
|
---|
38 | fi
|
---|
39 | # Downloads the book if necessary, initialize the tracking file and the
|
---|
40 | # package database.
|
---|
41 | # sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
|
---|
42 | # has to be created
|
---|
43 | sudo make -j1 -C $BUILDDIR$BLFS_ROOT TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
|
---|
44 | $BUILDDIR$BLFS_ROOT/packages.xml
|
---|
45 |
|
---|
46 | # Because the BLFS Makefile is supposed to be used in chroot (or booted)
|
---|
47 | # mode, the tracking file has wrong path for DTD. Change it:
|
---|
48 | sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
|
---|
49 |
|
---|
50 | # Manually build a 'configuration' file
|
---|
51 | if [ "$DEP_LIBXML" = y ]; then
|
---|
52 | LINE_LIBXML='CONFIG_libxml2=y'
|
---|
53 | else
|
---|
54 | LINE_LIBXML='#CONFIG_libxml2 is not set'
|
---|
55 | fi
|
---|
56 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
57 | LINE_LIBXSLT='CONFIG_libxslt=y'
|
---|
58 | else
|
---|
59 | LINE_LIBXSLT='#CONFIG_libxslt is not set'
|
---|
60 | fi
|
---|
61 | if [ "$DEP_TIDY" = y ]; then
|
---|
62 | LINE_TIDY='CONFIG_html-tidy=y'
|
---|
63 | else
|
---|
64 | LINE_TIDY='#CONFIG_html-tidy is not set'
|
---|
65 | fi
|
---|
66 | # DocBook is a rec dep of libxslt
|
---|
67 | # if [ "$DEP_DBXML" = y ]; then
|
---|
68 | # LINE_DBXML='CONFIG_DocBook=y'
|
---|
69 | # else
|
---|
70 | # LINE_DBXML='#CONFIG_DocBook is not set'
|
---|
71 | # fi
|
---|
72 | if [ "$DEP_LYNX" = y ]; then
|
---|
73 | LINE_LYNX='CONFIG_lynx=y'
|
---|
74 | else
|
---|
75 | LINE_LYNX='#CONFIG_lynx is not set'
|
---|
76 | fi
|
---|
77 | if [ "$DEP_SUDO" = y ]; then
|
---|
78 | LINE_SUDO='CONFIG_sudo=y'
|
---|
79 | else
|
---|
80 | LINE_SUDO='#CONFIG_sudo is not set'
|
---|
81 | fi
|
---|
82 | if [ "$DEP_WGET" = y ]; then
|
---|
83 | LINE_WGET='CONFIG_wget=y'
|
---|
84 | else
|
---|
85 | LINE_WGET='#CONFIG_wget is not set'
|
---|
86 | fi
|
---|
87 | if [ "$DEP_GPM" = y ]; then
|
---|
88 | LINE_GPM='CONFIG_gpm=y'
|
---|
89 | else
|
---|
90 | LINE_GPM='#CONFIG_gpm is not set'
|
---|
91 | fi
|
---|
92 | if [ "$DEP_SVN" = y ]; then
|
---|
93 | LINE_SVN='CONFIG_subversion=y'
|
---|
94 | else
|
---|
95 | LINE_SVN='#CONFIG_subversion is not set'
|
---|
96 | fi
|
---|
97 | if [ "$DEP_OPENSSL" = y ]; then
|
---|
98 | LINE_OPENSSL='CONFIG_openssl=y'
|
---|
99 | else
|
---|
100 | LINE_OPENSSL='#CONFIG_openssl is not set'
|
---|
101 | fi
|
---|
102 | if [ "$DEP_PYTHON" = y ]; then
|
---|
103 | LINE_PYTHON='CONFIG_python2=y'
|
---|
104 | else
|
---|
105 | LINE_PYTHON='#CONFIG_python2 is not set'
|
---|
106 | fi
|
---|
107 |
|
---|
108 | cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
|
---|
109 | $LINE_OPENSSL
|
---|
110 | $LINE_PYTHON
|
---|
111 | $LINE_LIBXML
|
---|
112 | $LINE_LIBXSLT
|
---|
113 | $LINE_TIDY
|
---|
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 | EOF
|
---|
123 |
|
---|
124 | # Generates the scripts for the blfs tools dependencies (in ./scripts)
|
---|
125 | yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh $BUILDDIR$BLFS_ROOT
|
---|
126 |
|
---|
127 | # Move the scriptlets where they should be
|
---|
128 | sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
|
---|
129 | mv scripts $BUILDDIR$BLFS_ROOT
|
---|
130 |
|
---|
131 | # The book instructions for CA certificates contains downloading
|
---|
132 | # instructions, which should not be used here, so:
|
---|
133 | if test -f $BUILDDIR$BLFS_ROOT/scripts/*cacerts; then
|
---|
134 | sed -i '/URL=/,/^wget/d' $BUILDDIR$BLFS_ROOT/scripts/*cacerts
|
---|
135 | fi
|
---|
136 |
|
---|
137 | # Generates a list containing download and copying instructions for tarballs
|
---|
138 | echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
|
---|
139 | sed -n -e '/PACKAGE=/,/^fi/p' \
|
---|
140 | -e '/|[ ]*md5sum/p' \
|
---|
141 | -e '/PACKAGE1=/,/^fi/p' \
|
---|
142 | -e '/PATCH=/,/^fi/p' \
|
---|
143 | -e '/URL=/,/^fi/p' \
|
---|
144 | $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
|
---|
145 | chmod u+x $BUILDDIR$BLFS_ROOT/download_script
|
---|
146 |
|
---|
147 | # Downloads (or copy) to build_dir/sources
|
---|
148 | pushd $BUILDDIR/sources
|
---|
149 | # Remove `unpacked' files if some have been left
|
---|
150 | sudo find . -name unpacked -exec rm \{\} \;
|
---|
151 | FTP_SERVER=$SERVER/pub/blfs/ SRC_ARCHIVE=$SRC_ARCHIVE $BUILDDIR$BLFS_ROOT/download_script
|
---|
152 | popd
|
---|
153 | rm -v $BUILDDIR$BLFS_ROOT/download_script
|
---|
154 |
|
---|
155 | # Suppresses unneeded parts of the scriptlets
|
---|
156 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
157 | # libxslt pulls docbook-xsl in, which populates the catalog with annoying
|
---|
158 | # **EDITME** references. Fortunately, those lines are regognizable because
|
---|
159 | # they occur between lines containing '/etc/xml/catalog' at the end of the
|
---|
160 | # line (without '&&'). I have not found a simple way to delete lines
|
---|
161 | # between 2 addresses, excluding either the first or the last one. So use
|
---|
162 | # a loop for accumulating lines and deleting at the end.
|
---|
163 | # Sorry for sed synthax.
|
---|
164 | sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
|
---|
165 | n
|
---|
166 | :a
|
---|
167 | \@/etc/xml/catalog$@bb
|
---|
168 | N
|
---|
169 | ba
|
---|
170 | :b
|
---|
171 | d}' \
|
---|
172 | $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
|
---|
173 | fi
|
---|
174 | if [ "$DEP_SUDO" = y ]; then
|
---|
175 | sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
|
---|
176 | fi
|
---|
177 | if [ "$DEP_SVN" = y ]; then
|
---|
178 | sed -i -e /javahl/d -e /swig/d $BUILDDIR$BLFS_ROOT/scripts/*subversion
|
---|
179 | fi
|
---|
180 | if [ "$DEP_LYNX" = y ]; then
|
---|
181 | if [ "$DEP_OPENSSL" = y -o "$DEP_WGET" = y ]; then
|
---|
182 | sed -i -e 's/configure/& --with-ssl/' \
|
---|
183 | -e '/make$/i echo "#define USE_OPENSSL_INCL 1" >> lynx_cfg.h &&' \
|
---|
184 | $BUILDDIR$BLFS_ROOT/scripts/*lynx
|
---|
185 | fi
|
---|
186 | fi
|
---|
187 | # At last generates the build Makefile
|
---|
188 | mkdir -p $BUILDDIR$BLFS_ROOT/work
|
---|
189 | pushd $BUILDDIR$BLFS_ROOT/work
|
---|
190 | ../gen-makefile.sh
|
---|
191 | # The generated Makefile updates the tracking file after each package
|
---|
192 | # installation, using libxslt, which is not installed yet. So move
|
---|
193 | # updating to the end of the process, adding an 'update' target
|
---|
194 | sed -i -e '/xsltproc/,+6d' \
|
---|
195 | -e '/^all/s@$@ update@' \
|
---|
196 | -e 's/touch/@touch/' Makefile
|
---|
197 | cat >> Makefile << EOF
|
---|
198 | update:
|
---|
199 | @echo Updating the tracking file
|
---|
200 | @for file in *-*; do \\
|
---|
201 | xsltproc --stringparam packages ../packages.xml \\
|
---|
202 | --stringparam package \$\${file##*z-} \\
|
---|
203 | -o track.tmp \\
|
---|
204 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
205 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
206 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
207 | rm track.tmp; \\
|
---|
208 | done
|
---|
209 | @touch \$@
|
---|
210 | @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
|
---|
211 | @echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
212 | EOF
|
---|
213 | popd
|
---|
214 | }
|
---|