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