[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
|
---|
[088130f] | 65 | # prevents $LUSER to create "nss_db". The problem is that $LUSER
|
---|
| 66 | # May not have been created yet. So do not change ownership here
|
---|
| 67 | # and do it in master.sh for chapter 4.
|
---|
| 68 | #sudo chown $LUSER:$LGROUP $BUILDDIR/var/lib
|
---|
[ae1d8a5] | 69 |
|
---|
[e576789] | 70 | # Because the BLFS Makefile is supposed to be used in chroot (or booted)
|
---|
| 71 | # mode, the tracking file has wrong path for DTD. Change it:
|
---|
| 72 | sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
|
---|
| 73 |
|
---|
| 74 | # Manually build a 'configuration' file
|
---|
| 75 | if [ "$DEP_LIBXML" = y ]; then
|
---|
| 76 | LINE_LIBXML='CONFIG_libxml2=y'
|
---|
| 77 | else
|
---|
| 78 | LINE_LIBXML='#CONFIG_libxml2 is not set'
|
---|
| 79 | fi
|
---|
| 80 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
| 81 | LINE_LIBXSLT='CONFIG_libxslt=y'
|
---|
| 82 | else
|
---|
| 83 | LINE_LIBXSLT='#CONFIG_libxslt is not set'
|
---|
| 84 | fi
|
---|
[c1626d8] | 85 | # DocBook is a rec dep of libxslt
|
---|
| 86 | # if [ "$DEP_DBXML" = y ]; then
|
---|
| 87 | # LINE_DBXML='CONFIG_DocBook=y'
|
---|
| 88 | # else
|
---|
| 89 | # LINE_DBXML='#CONFIG_DocBook is not set'
|
---|
| 90 | # fi
|
---|
[e576789] | 91 | if [ "$DEP_LYNX" = y ]; then
|
---|
| 92 | LINE_LYNX='CONFIG_lynx=y'
|
---|
| 93 | else
|
---|
| 94 | LINE_LYNX='#CONFIG_lynx is not set'
|
---|
| 95 | fi
|
---|
| 96 | if [ "$DEP_SUDO" = y ]; then
|
---|
| 97 | LINE_SUDO='CONFIG_sudo=y'
|
---|
| 98 | else
|
---|
| 99 | LINE_SUDO='#CONFIG_sudo is not set'
|
---|
| 100 | fi
|
---|
| 101 | if [ "$DEP_WGET" = y ]; then
|
---|
| 102 | LINE_WGET='CONFIG_wget=y'
|
---|
| 103 | else
|
---|
| 104 | LINE_WGET='#CONFIG_wget is not set'
|
---|
| 105 | fi
|
---|
| 106 | if [ "$DEP_GPM" = y ]; then
|
---|
| 107 | LINE_GPM='CONFIG_gpm=y'
|
---|
| 108 | else
|
---|
| 109 | LINE_GPM='#CONFIG_gpm is not set'
|
---|
| 110 | fi
|
---|
| 111 | if [ "$DEP_SVN" = y ]; then
|
---|
| 112 | LINE_SVN='CONFIG_subversion=y'
|
---|
| 113 | else
|
---|
| 114 | LINE_SVN='#CONFIG_subversion is not set'
|
---|
| 115 | fi
|
---|
| 116 |
|
---|
| 117 | cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
|
---|
| 118 | $LINE_LIBXML
|
---|
| 119 | $LINE_LIBXSLT
|
---|
| 120 | $LINE_WGET
|
---|
| 121 | $LINE_SVN
|
---|
| 122 | $LINE_GPM
|
---|
| 123 | $LINE_LYNX
|
---|
| 124 | $LINE_SUDO
|
---|
| 125 | MAIL_SERVER=sendmail
|
---|
| 126 | optDependency=2
|
---|
| 127 | SUDO=n
|
---|
[625cb14] | 128 | LANGUAGE=$LANG
|
---|
[945ccaa] | 129 | WRAP_INSTALL=$WRAP_INSTALL
|
---|
[dc7fd7b] | 130 | DEL_LA_FILES=$DEL_LA_FILES
|
---|
[625cb14] | 131 | STATS=n
|
---|
[e576789] | 132 | EOF
|
---|
| 133 |
|
---|
| 134 | # Generates the scripts for the blfs tools dependencies (in ./scripts)
|
---|
| 135 | yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh $BUILDDIR$BLFS_ROOT
|
---|
| 136 |
|
---|
| 137 | # Move the scriptlets where they should be
|
---|
| 138 | sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
|
---|
| 139 | mv scripts $BUILDDIR$BLFS_ROOT
|
---|
| 140 |
|
---|
| 141 | # Generates a list containing download and copying instructions for tarballs
|
---|
| 142 | echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
|
---|
[2cf28dc] | 143 | sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
|
---|
[1fa0dee] | 144 | cp $PACKAGE $JH_SRC_ARCHIVE
|
---|
[2cf28dc] | 145 | p}' \
|
---|
[39da010] | 146 | -e '/|[ ]*md5sum/p' \
|
---|
[2cf28dc] | 147 | -e '/PACKAGE1=/,/^fi/{/^fi/a\
|
---|
[1fa0dee] | 148 | cp $PACKAGE1 $JH_SRC_ARCHIVE
|
---|
[2cf28dc] | 149 | p}' \
|
---|
| 150 | -e '/PATCH=/,/^fi/{/^fi/a\
|
---|
[1fa0dee] | 151 | cp $PATCH $JH_SRC_ARCHIVE
|
---|
[2cf28dc] | 152 | p}' \
|
---|
| 153 | -e '/URL=/,/^fi/{/^fi/a\
|
---|
[1fa0dee] | 154 | cp $BOOTPACKG $JH_SRC_ARCHIVE
|
---|
[2cf28dc] | 155 | p}' \
|
---|
[e576789] | 156 | $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 157 | chmod u+x $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 158 |
|
---|
| 159 | # Downloads (or copy) to build_dir/sources
|
---|
| 160 | pushd $BUILDDIR/sources
|
---|
| 161 | # Remove `unpacked' files if some have been left
|
---|
| 162 | sudo find . -name unpacked -exec rm \{\} \;
|
---|
[67723e1] | 163 | if [ "$GETPKG" = "y" ]; then
|
---|
[1fa0dee] | 164 | JH_FTP_SERVER=$SERVER/pub/blfs/ \
|
---|
| 165 | JH_SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
|
---|
[67723e1] | 166 | $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 167 | else # Save the download script in case the user wants to run it later
|
---|
| 168 | cp $BUILDDIR$BLFS_ROOT/download_script .
|
---|
| 169 | fi
|
---|
[e576789] | 170 | popd
|
---|
| 171 | rm -v $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 172 |
|
---|
| 173 | # Suppresses unneeded parts of the scriptlets
|
---|
[c1626d8] | 174 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
[cbca63a] | 175 | # libxslt pulls docbook-xsl in, which populates the catalog with annoying
|
---|
| 176 | # **EDITME** references. Fortunately, those lines are regognizable because
|
---|
| 177 | # they occur between lines containing '/etc/xml/catalog' at the end of the
|
---|
| 178 | # line (without '&&'). I have not found a simple way to delete lines
|
---|
| 179 | # between 2 addresses, excluding either the first or the last one. So use
|
---|
| 180 | # a loop for accumulating lines and deleting at the end.
|
---|
[4b2a5fd] | 181 | # Sorry for sed syntax.
|
---|
[c1626d8] | 182 | sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
|
---|
| 183 | n
|
---|
| 184 | :a
|
---|
| 185 | \@/etc/xml/catalog$@bb
|
---|
| 186 | N
|
---|
| 187 | ba
|
---|
| 188 | :b
|
---|
| 189 | d}' \
|
---|
| 190 | $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
|
---|
| 191 | fi
|
---|
[e576789] | 192 | if [ "$DEP_SUDO" = y ]; then
|
---|
[cbca63a] | 193 | sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
|
---|
[e576789] | 194 | fi
|
---|
| 195 | if [ "$DEP_SVN" = y ]; then
|
---|
| 196 | sed -i -e /javahl/d -e /swig/d $BUILDDIR$BLFS_ROOT/scripts/*subversion
|
---|
| 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
|
---|
[cbca63a] | 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
|
---|
[e576789] | 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
|
---|
[6d1d77c] | 211 | @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
|
---|
| 212 | sed 's/.*>\([^<]*\)<.*/\1/' | \\
|
---|
| 213 | sort | uniq); do \\
|
---|
[a1795f0] | 214 | case "x\$\$pack" in \\
|
---|
[ea0be93] | 215 | xgcc* | *pass[12] | xvim | \\
|
---|
[a1795f0] | 216 | xshadow | xPython | xlinux-headers | xdbus | xsystemd )\\
|
---|
| 217 | continue ;; \\
|
---|
| 218 | esac; \\
|
---|
[e3f4b9a4] | 219 | VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
|
---|
[6d1d77c] | 220 | ../$LFS_XML/tmp/lfs-full.xml | \\
|
---|
| 221 | head -n2| \\
|
---|
| 222 | sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
|
---|
| 223 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 224 | --stringparam package \$\$pack \\
|
---|
| 225 | --stringparam version \$\$VERSION \\
|
---|
| 226 | -o track.tmp \\
|
---|
| 227 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 228 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 229 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 230 | rm track.tmp; \\
|
---|
| 231 | done; \\
|
---|
[e3f4b9a4] | 232 | VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
|
---|
| 233 | sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
|
---|
| 234 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 235 | --stringparam package LFS-Release \\
|
---|
| 236 | --stringparam version \$\$VERSION \\
|
---|
| 237 | -o track.tmp \\
|
---|
| 238 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 239 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 240 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 241 | rm track.tmp; \\
|
---|
[6d1d77c] | 242 | for file in *-*; do \\
|
---|
| 243 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 244 | --stringparam package \$\${file##*z-} \\
|
---|
| 245 | -o track.tmp \\
|
---|
| 246 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 247 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 248 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 249 | rm track.tmp; \\
|
---|
[e576789] | 250 | done
|
---|
| 251 | @touch \$@
|
---|
| 252 | @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
|
---|
| 253 | @echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 254 | EOF
|
---|
| 255 | popd
|
---|
| 256 | }
|
---|