[e576789] | 1 | #!/bin/bash
|
---|
| 2 |
|
---|
| 3 | #----------------------------# Prepare BLFS_ROOT and extract
|
---|
| 4 | install_blfs_tools() { # the scriptlets to build
|
---|
| 5 | #----------------------------# the dependency tools
|
---|
| 6 | set -e
|
---|
| 7 | # Install the files
|
---|
[106157fd] | 8 | [[ ! -d "${BUILDDIR}${BLFS_ROOT}" ]] && {
|
---|
| 9 | sudo mkdir -pv "${BUILDDIR}${BLFS_ROOT}"
|
---|
| 10 | sudo chown "$USER" "${BUILDDIR}${BLFS_ROOT}"
|
---|
[c7b535b] | 11 | }
|
---|
[e576789] | 12 | cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
|
---|
| 13 | cp -r menu ${BUILDDIR}${BLFS_ROOT}
|
---|
| 14 | cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
|
---|
| 15 | cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
|
---|
[945ccaa] | 16 | if [ "$WRAP_INSTALL" = y ]; then
|
---|
[1fa0dee] | 17 | sed -e 's/PKGDIR/JH_UNPACKDIR/' \
|
---|
| 18 | -e 's/PKG_DEST/JH_PKG_DIR/' \
|
---|
[945ccaa] | 19 | $PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
|
---|
| 20 | fi
|
---|
[e576789] | 21 |
|
---|
| 22 | # Set some harcoded envars to their proper values
|
---|
| 23 | sed -i s@tracking-dir@$TRACKING_DIR@ \
|
---|
[b734bfb] | 24 | ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
|
---|
[e576789] | 25 | sed -i s@trunk/BOOK@$BLFS_TREE@ \
|
---|
| 26 | ${BUILDDIR}${BLFS_ROOT}/Makefile
|
---|
| 27 |
|
---|
[854854e] | 28 | # If we have a working copy, copy it:
|
---|
| 29 | if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
|
---|
[382b083] | 30 | echo "copying the local BLFS working copy (may take some time)"
|
---|
[e58cf153] | 31 | # -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
|
---|
[382b083] | 32 | # of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
|
---|
| 33 | # book has already been validated, tmp is posterior to the others, and
|
---|
| 34 | # validation will not be done again.
|
---|
| 35 | cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
|
---|
[340c27e] | 36 | ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
|
---|
[854854e] | 37 | fi
|
---|
[b8aa7ed] | 38 |
|
---|
| 39 | # Copy the LFS book. Note that now, the book is downloaded before running
|
---|
| 40 | # the BLFS tools.
|
---|
| 41 | cp -ruT --preserve=timestamps $BOOK \
|
---|
| 42 | ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
|
---|
| 43 |
|
---|
[854854e] | 44 | # Downloads the book if necessary, initialize the tracking file and the
|
---|
| 45 | # package database.
|
---|
[e576789] | 46 | # sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
|
---|
| 47 | # has to be created
|
---|
[340c27e] | 48 | sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
|
---|
| 49 | REV=$INITSYS \
|
---|
| 50 | TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
|
---|
[b8aa7ed] | 51 | LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
|
---|
[2ac2fc5] | 52 | LFS-BRANCH=${LFS_TREE} \
|
---|
[340c27e] | 53 | BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
|
---|
[2ac2fc5] | 54 | BLFS-BRANCH=${BLFS_TREE} \
|
---|
[26e6739] | 55 | $BUILDDIR$BLFS_ROOT/packages.xml
|
---|
[e576789] | 56 |
|
---|
[ae1d8a5] | 57 | # But then $BUILDDIR/var/lib/ is owned by root if just created, which
|
---|
[088130f] | 58 | # prevents $LUSER to create "nss_db". The problem is that $LUSER
|
---|
| 59 | # May not have been created yet. So do not change ownership here
|
---|
| 60 | # and do it in master.sh for chapter 4.
|
---|
| 61 | #sudo chown $LUSER:$LGROUP $BUILDDIR/var/lib
|
---|
[ae1d8a5] | 62 |
|
---|
[e576789] | 63 | # Because the BLFS Makefile is supposed to be used in chroot (or booted)
|
---|
| 64 | # mode, the tracking file has wrong path for DTD. Change it:
|
---|
| 65 | sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
|
---|
| 66 |
|
---|
| 67 | # Manually build a 'configuration' file
|
---|
| 68 | if [ "$DEP_LIBXML" = y ]; then
|
---|
| 69 | LINE_LIBXML='CONFIG_libxml2=y'
|
---|
| 70 | else
|
---|
| 71 | LINE_LIBXML='#CONFIG_libxml2 is not set'
|
---|
| 72 | fi
|
---|
| 73 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
| 74 | LINE_LIBXSLT='CONFIG_libxslt=y'
|
---|
| 75 | else
|
---|
| 76 | LINE_LIBXSLT='#CONFIG_libxslt is not set'
|
---|
| 77 | fi
|
---|
[c1626d8] | 78 | # DocBook is a rec dep of libxslt
|
---|
| 79 | # if [ "$DEP_DBXML" = y ]; then
|
---|
| 80 | # LINE_DBXML='CONFIG_DocBook=y'
|
---|
| 81 | # else
|
---|
| 82 | # LINE_DBXML='#CONFIG_DocBook is not set'
|
---|
| 83 | # fi
|
---|
[e576789] | 84 | if [ "$DEP_LYNX" = y ]; then
|
---|
| 85 | LINE_LYNX='CONFIG_lynx=y'
|
---|
| 86 | else
|
---|
| 87 | LINE_LYNX='#CONFIG_lynx is not set'
|
---|
| 88 | fi
|
---|
| 89 | if [ "$DEP_SUDO" = y ]; then
|
---|
| 90 | LINE_SUDO='CONFIG_sudo=y'
|
---|
| 91 | else
|
---|
| 92 | LINE_SUDO='#CONFIG_sudo is not set'
|
---|
| 93 | fi
|
---|
| 94 | if [ "$DEP_WGET" = y ]; then
|
---|
| 95 | LINE_WGET='CONFIG_wget=y'
|
---|
| 96 | else
|
---|
| 97 | LINE_WGET='#CONFIG_wget is not set'
|
---|
| 98 | fi
|
---|
| 99 | if [ "$DEP_GPM" = y ]; then
|
---|
| 100 | LINE_GPM='CONFIG_gpm=y'
|
---|
| 101 | else
|
---|
| 102 | LINE_GPM='#CONFIG_gpm is not set'
|
---|
| 103 | fi
|
---|
[dd5d63d] | 104 | if [ "$DEP_GIT" = y ]; then
|
---|
| 105 | LINE_GIT='CONFIG_git=y'
|
---|
[e576789] | 106 | else
|
---|
[dd5d63d] | 107 | LINE_GIT='#CONFIG_git is not set'
|
---|
[e576789] | 108 | fi
|
---|
| 109 |
|
---|
| 110 | cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
|
---|
| 111 | $LINE_LIBXML
|
---|
| 112 | $LINE_LIBXSLT
|
---|
| 113 | $LINE_WGET
|
---|
[dd5d63d] | 114 | $LINE_GIT
|
---|
[e576789] | 115 | $LINE_GPM
|
---|
| 116 | $LINE_LYNX
|
---|
| 117 | $LINE_SUDO
|
---|
| 118 | MAIL_SERVER=sendmail
|
---|
| 119 | optDependency=2
|
---|
| 120 | SUDO=n
|
---|
[625cb14] | 121 | LANGUAGE=$LANG
|
---|
[945ccaa] | 122 | WRAP_INSTALL=$WRAP_INSTALL
|
---|
[267b19d] | 123 | PACK_INSTALL=/blfs_root/packInstall.sh
|
---|
[dc7fd7b] | 124 | DEL_LA_FILES=$DEL_LA_FILES
|
---|
[625cb14] | 125 | STATS=n
|
---|
[267b19d] | 126 | SRC_ARCHIVE=/sources
|
---|
| 127 | BUILD_ROOT=/sources
|
---|
| 128 | BUILD_SUBDIRS=y
|
---|
| 129 | JOBS=$(if [ -n "$N_PARALLEL" ]; then echo $N_PARALLEL; else echo 1; fi)
|
---|
[e576789] | 130 | EOF
|
---|
[267b19d] | 131 | for OPT_VAR in CFLAGS CXXFLAGS LDFLAGS; do
|
---|
| 132 | eval optVal=\$${OPT_VAR}_$DEF_OPT_MODE
|
---|
| 133 | if [ -n "$optVal" ] && [ "$optVal" != unset ]; then
|
---|
| 134 | echo "CFG_$OPT_VAR"=\"$optVal\" >> $BUILDDIR$BLFS_ROOT/configuration
|
---|
| 135 | else
|
---|
| 136 | echo "CFG_$OPT_VAR"=EMPTY >> $BUILDDIR$BLFS_ROOT/configuration
|
---|
| 137 | fi
|
---|
| 138 | done
|
---|
[e576789] | 139 |
|
---|
| 140 | # Generates the scripts for the blfs tools dependencies (in ./scripts)
|
---|
[f81d8bd] | 141 | yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh \
|
---|
| 142 | $BUILDDIR$TRACKING_DIR/instpkg.xml \
|
---|
| 143 | $BUILDDIR$BLFS_ROOT
|
---|
[e576789] | 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 | # At last generates the build Makefile
|
---|
| 204 | mkdir -p $BUILDDIR$BLFS_ROOT/work
|
---|
| 205 | pushd $BUILDDIR$BLFS_ROOT/work
|
---|
| 206 | ../gen-makefile.sh
|
---|
[cbca63a] | 207 | # The generated Makefile updates the tracking file after each package
|
---|
| 208 | # installation, using libxslt, which is not installed yet. So move
|
---|
| 209 | # updating to the end of the process, adding an 'update' target
|
---|
[e576789] | 210 | sed -i -e '/xsltproc/,+6d' \
|
---|
| 211 | -e '/^all/s@$@ update@' \
|
---|
| 212 | -e 's/touch/@touch/' Makefile
|
---|
| 213 | cat >> Makefile << EOF
|
---|
| 214 | update:
|
---|
| 215 | @echo Updating the tracking file
|
---|
[6d1d77c] | 216 | @for pack in \$\$(grep '<productname' ../$LFS_XML/tmp/lfs-full.xml | \\
|
---|
| 217 | sed 's/.*>\([^<]*\)<.*/\1/' | \\
|
---|
| 218 | sort | uniq); do \\
|
---|
[a1795f0] | 219 | case "x\$\$pack" in \\
|
---|
[ea0be93] | 220 | xgcc* | *pass[12] | xvim | \\
|
---|
[a1795f0] | 221 | xshadow | xPython | xlinux-headers | xdbus | xsystemd )\\
|
---|
| 222 | continue ;; \\
|
---|
| 223 | esac; \\
|
---|
[e3f4b9a4] | 224 | VERSION=\$\$(grep -A1 ">\$\$pack</product" \\
|
---|
[6d1d77c] | 225 | ../$LFS_XML/tmp/lfs-full.xml | \\
|
---|
| 226 | head -n2| \\
|
---|
| 227 | sed -n '2s/.*>\([^<]*\)<.*/\1/p'); \\
|
---|
| 228 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 229 | --stringparam package \$\$pack \\
|
---|
| 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; \\
|
---|
| 236 | done; \\
|
---|
[e3f4b9a4] | 237 | VERSION=\$\$(grep 'echo.*lfs-release' ../$LFS_XML/tmp/lfs-full.xml | \\
|
---|
| 238 | sed 's/.*echo[ ]*\([^ ]*\).*/\1/'); \\
|
---|
| 239 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 240 | --stringparam package LFS-Release \\
|
---|
| 241 | --stringparam version \$\$VERSION \\
|
---|
| 242 | -o track.tmp \\
|
---|
| 243 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 244 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 245 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 246 | rm track.tmp; \\
|
---|
[6d1d77c] | 247 | for file in *-*; do \\
|
---|
| 248 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 249 | --stringparam package \$\${file##*z-} \\
|
---|
| 250 | -o track.tmp \\
|
---|
| 251 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 252 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 253 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 254 | rm track.tmp; \\
|
---|
[e576789] | 255 | done
|
---|
| 256 | @touch \$@
|
---|
| 257 | @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
|
---|
| 258 | @echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 259 | EOF
|
---|
| 260 | popd
|
---|
| 261 | }
|
---|