[e576789] | 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
|
---|
[c7b535b] | 10 | [[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && {
|
---|
| 11 | sudo mkdir -pv ${BUILDDIR}${BLFS_ROOT}
|
---|
| 12 | sudo chown $USER:$USER ${BUILDDIR}${BLFS_ROOT}
|
---|
| 13 | }
|
---|
[e576789] | 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}
|
---|
[945ccaa] | 18 | if [ "$WRAP_INSTALL" = y ]; then
|
---|
[1fa0dee] | 19 | sed -e 's/PKGDIR/JH_UNPACKDIR/' \
|
---|
| 20 | -e 's/PKG_DEST/JH_PKG_DIR/' \
|
---|
[945ccaa] | 21 | $PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
|
---|
| 22 | fi
|
---|
[e576789] | 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 |
|
---|
[854854e] | 37 | # If we have a working copy, copy it:
|
---|
| 38 | if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
|
---|
[382b083] | 39 | echo "copying the local BLFS working copy (may take some time)"
|
---|
[e58cf153] | 40 | # -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
|
---|
[382b083] | 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 \
|
---|
[340c27e] | 45 | ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
|
---|
[854854e] | 46 | fi
|
---|
[b8aa7ed] | 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 |
|
---|
[854854e] | 53 | # Downloads the book if necessary, initialize the tracking file and the
|
---|
| 54 | # package database.
|
---|
[e576789] | 55 | # sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
|
---|
| 56 | # has to be created
|
---|
[340c27e] | 57 | sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
|
---|
| 58 | REV=$INITSYS \
|
---|
| 59 | TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
|
---|
[b8aa7ed] | 60 | LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
|
---|
| 61 | LFS-SVN=$SVN_2/LFS/$TREE \
|
---|
[340c27e] | 62 | BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
|
---|
| 63 | SVN=$SVN_2/BLFS/$BLFS_TREE \
|
---|
[26e6739] | 64 | $BUILDDIR$BLFS_ROOT/packages.xml
|
---|
[e576789] | 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
|
---|
[c1626d8] | 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
|
---|
[e576789] | 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
|
---|
[1f25a75] | 124 | $LINE_OPENSSL
|
---|
[e576789] | 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
|
---|
[625cb14] | 136 | LANGUAGE=$LANG
|
---|
[945ccaa] | 137 | WRAP_INSTALL=$WRAP_INSTALL
|
---|
[dc7fd7b] | 138 | DEL_LA_FILES=$DEL_LA_FILES
|
---|
[625cb14] | 139 | STATS=n
|
---|
[e576789] | 140 | EOF
|
---|
| 141 |
|
---|
| 142 | # Generates the scripts for the blfs tools dependencies (in ./scripts)
|
---|
| 143 | yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh $BUILDDIR$BLFS_ROOT
|
---|
| 144 |
|
---|
| 145 | # Move the scriptlets where they should be
|
---|
| 146 | sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
|
---|
| 147 | mv scripts $BUILDDIR$BLFS_ROOT
|
---|
| 148 |
|
---|
| 149 | # Generates a list containing download and copying instructions for tarballs
|
---|
| 150 | echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
|
---|
[2cf28dc] | 151 | sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
|
---|
[1fa0dee] | 152 | cp $PACKAGE $JH_SRC_ARCHIVE
|
---|
[2cf28dc] | 153 | p}' \
|
---|
[39da010] | 154 | -e '/|[ ]*md5sum/p' \
|
---|
[2cf28dc] | 155 | -e '/PACKAGE1=/,/^fi/{/^fi/a\
|
---|
[1fa0dee] | 156 | cp $PACKAGE1 $JH_SRC_ARCHIVE
|
---|
[2cf28dc] | 157 | p}' \
|
---|
| 158 | -e '/PATCH=/,/^fi/{/^fi/a\
|
---|
[1fa0dee] | 159 | cp $PATCH $JH_SRC_ARCHIVE
|
---|
[2cf28dc] | 160 | p}' \
|
---|
| 161 | -e '/URL=/,/^fi/{/^fi/a\
|
---|
[1fa0dee] | 162 | cp $BOOTPACKG $JH_SRC_ARCHIVE
|
---|
[2cf28dc] | 163 | p}' \
|
---|
[e576789] | 164 | $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 165 | chmod u+x $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 166 |
|
---|
| 167 | # Downloads (or copy) to build_dir/sources
|
---|
| 168 | pushd $BUILDDIR/sources
|
---|
| 169 | # Remove `unpacked' files if some have been left
|
---|
| 170 | sudo find . -name unpacked -exec rm \{\} \;
|
---|
[67723e1] | 171 | if [ "$GETPKG" = "y" ]; then
|
---|
[1fa0dee] | 172 | JH_FTP_SERVER=$SERVER/pub/blfs/ \
|
---|
| 173 | JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
|
---|
[67723e1] | 174 | $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 175 | else # Save the download script in case the user wants to run it later
|
---|
| 176 | cp $BUILDDIR$BLFS_ROOT/download_script .
|
---|
| 177 | fi
|
---|
[e576789] | 178 | popd
|
---|
| 179 | rm -v $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 180 |
|
---|
| 181 | # Suppresses unneeded parts of the scriptlets
|
---|
[c1626d8] | 182 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
[cbca63a] | 183 | # libxslt pulls docbook-xsl in, which populates the catalog with annoying
|
---|
| 184 | # **EDITME** references. Fortunately, those lines are regognizable because
|
---|
| 185 | # they occur between lines containing '/etc/xml/catalog' at the end of the
|
---|
| 186 | # line (without '&&'). I have not found a simple way to delete lines
|
---|
| 187 | # between 2 addresses, excluding either the first or the last one. So use
|
---|
| 188 | # a loop for accumulating lines and deleting at the end.
|
---|
[4b2a5fd] | 189 | # Sorry for sed syntax.
|
---|
[c1626d8] | 190 | sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
|
---|
| 191 | n
|
---|
| 192 | :a
|
---|
| 193 | \@/etc/xml/catalog$@bb
|
---|
| 194 | N
|
---|
| 195 | ba
|
---|
| 196 | :b
|
---|
| 197 | d}' \
|
---|
| 198 | $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
|
---|
| 199 | fi
|
---|
[e576789] | 200 | if [ "$DEP_SUDO" = y ]; then
|
---|
[cbca63a] | 201 | sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
|
---|
[e576789] | 202 | fi
|
---|
| 203 | if [ "$DEP_SVN" = y ]; then
|
---|
| 204 | sed -i -e /javahl/d -e /swig/d $BUILDDIR$BLFS_ROOT/scripts/*subversion
|
---|
| 205 | fi
|
---|
| 206 | # At last generates the build Makefile
|
---|
| 207 | mkdir -p $BUILDDIR$BLFS_ROOT/work
|
---|
| 208 | pushd $BUILDDIR$BLFS_ROOT/work
|
---|
| 209 | ../gen-makefile.sh
|
---|
[cbca63a] | 210 | # The generated Makefile updates the tracking file after each package
|
---|
| 211 | # installation, using libxslt, which is not installed yet. So move
|
---|
| 212 | # updating to the end of the process, adding an 'update' target
|
---|
[e576789] | 213 | sed -i -e '/xsltproc/,+6d' \
|
---|
| 214 | -e '/^all/s@$@ update@' \
|
---|
| 215 | -e 's/touch/@touch/' Makefile
|
---|
| 216 | cat >> Makefile << EOF
|
---|
| 217 | update:
|
---|
| 218 | @echo Updating the tracking file
|
---|
[6d1d77c] | 219 | @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
|
---|
| 220 | sed 's/.*>\([^<]*\)<.*/\1/' | \\
|
---|
| 221 | sort | uniq); do \\
|
---|
[94a78dd] | 222 | if [ "x\$\$pack" = xtcl -o \\
|
---|
| 223 | "x\$\$pack" = xexpect -o \\
|
---|
| 224 | "x\$\$pack" = xdejagnu ]; then continue; \\
|
---|
| 225 | fi; \\
|
---|
[e3f4b9a4] | 226 | VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
|
---|
[6d1d77c] | 227 | ../$LFS_XML/tmp/lfs-full.xml | \\
|
---|
| 228 | head -n2| \\
|
---|
| 229 | sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
|
---|
| 230 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 231 | --stringparam package \$\$pack \\
|
---|
| 232 | --stringparam version \$\$VERSION \\
|
---|
| 233 | -o track.tmp \\
|
---|
| 234 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 235 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 236 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 237 | rm track.tmp; \\
|
---|
| 238 | done; \\
|
---|
[e3f4b9a4] | 239 | VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
|
---|
| 240 | sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
|
---|
| 241 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 242 | --stringparam package LFS-Release \\
|
---|
| 243 | --stringparam version \$\$VERSION \\
|
---|
| 244 | -o track.tmp \\
|
---|
| 245 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 246 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 247 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 248 | rm track.tmp; \\
|
---|
[6d1d77c] | 249 | for file in *-*; do \\
|
---|
| 250 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 251 | --stringparam package \$\${file##*z-} \\
|
---|
| 252 | -o track.tmp \\
|
---|
| 253 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 254 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 255 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 256 | rm track.tmp; \\
|
---|
[e576789] | 257 | done
|
---|
| 258 | @touch \$@
|
---|
| 259 | @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
|
---|
| 260 | @echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 261 | EOF
|
---|
| 262 | popd
|
---|
| 263 | }
|
---|