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