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