[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
|
---|
| 10 | [[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && mkdir -pv ${BUILDDIR}${BLFS_ROOT}
|
---|
| 11 | cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
|
---|
| 12 | cp -r menu ${BUILDDIR}${BLFS_ROOT}
|
---|
| 13 | cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
|
---|
| 14 | cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
|
---|
[945ccaa] | 15 | if [ "$WRAP_INSTALL" = y ]; then
|
---|
| 16 | sed -e 's/PKGDIR/UNPACKDIR/' \
|
---|
| 17 | -e 's/PKG_DEST/PKG_DIR/' \
|
---|
| 18 | $PKGMNGTDIR/packInstall.sh > ${BUILDDIR}${BLFS_ROOT}/packInstall.sh
|
---|
| 19 | fi
|
---|
[e576789] | 20 |
|
---|
| 21 | # Clean-up
|
---|
| 22 | make -C ${BUILDDIR}${BLFS_ROOT}/menu clean
|
---|
| 23 | rm -rf ${BUILDDIR}${BLFS_ROOT}/libs/.svn
|
---|
| 24 | rm -rf ${BUILDDIR}${BLFS_ROOT}/xsl/.svn
|
---|
| 25 | rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/.svn
|
---|
| 26 | rm -rf ${BUILDDIR}${BLFS_ROOT}/menu/lxdialog/.svn
|
---|
| 27 |
|
---|
| 28 | # Set some harcoded envars to their proper values
|
---|
| 29 | sed -i s@tracking-dir@$TRACKING_DIR@ \
|
---|
| 30 | ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh}
|
---|
| 31 | sed -i s@trunk/BOOK@$BLFS_TREE@ \
|
---|
| 32 | ${BUILDDIR}${BLFS_ROOT}/Makefile
|
---|
| 33 |
|
---|
[854854e] | 34 | # If we have a working copy, copy it:
|
---|
| 35 | if [[ "$BLFS_WORKING_COPY" = "y" ]]; then
|
---|
[382b083] | 36 | echo "copying the local BLFS working copy (may take some time)"
|
---|
[e58cf153] | 37 | # -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
|
---|
[382b083] | 38 | # of blfs-xml, if blfs-xml already exists; --preserve=timestamps: if the local
|
---|
| 39 | # book has already been validated, tmp is posterior to the others, and
|
---|
| 40 | # validation will not be done again.
|
---|
| 41 | cp -ruT --preserve=timestamps $BLFS_WC_LOCATION \
|
---|
| 42 | ${BUILDDIR}${BLFS_ROOT}/blfs-xml
|
---|
[854854e] | 43 | fi
|
---|
| 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
|
---|
[26e6739] | 48 | sudo make -j1 -C $BUILDDIR$BLFS_ROOT \
|
---|
| 49 | REV=$INITSYS \
|
---|
| 50 | TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
|
---|
| 51 | $BUILDDIR$BLFS_ROOT/packages.xml
|
---|
[e576789] | 52 |
|
---|
| 53 | # Because the BLFS Makefile is supposed to be used in chroot (or booted)
|
---|
| 54 | # mode, the tracking file has wrong path for DTD. Change it:
|
---|
| 55 | sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
|
---|
| 56 |
|
---|
| 57 | # Manually build a 'configuration' file
|
---|
| 58 | if [ "$DEP_LIBXML" = y ]; then
|
---|
| 59 | LINE_LIBXML='CONFIG_libxml2=y'
|
---|
| 60 | else
|
---|
| 61 | LINE_LIBXML='#CONFIG_libxml2 is not set'
|
---|
| 62 | fi
|
---|
| 63 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
| 64 | LINE_LIBXSLT='CONFIG_libxslt=y'
|
---|
| 65 | else
|
---|
| 66 | LINE_LIBXSLT='#CONFIG_libxslt is not set'
|
---|
| 67 | fi
|
---|
[c1626d8] | 68 | # DocBook is a rec dep of libxslt
|
---|
| 69 | # if [ "$DEP_DBXML" = y ]; then
|
---|
| 70 | # LINE_DBXML='CONFIG_DocBook=y'
|
---|
| 71 | # else
|
---|
| 72 | # LINE_DBXML='#CONFIG_DocBook is not set'
|
---|
| 73 | # fi
|
---|
[e576789] | 74 | if [ "$DEP_LYNX" = y ]; then
|
---|
| 75 | LINE_LYNX='CONFIG_lynx=y'
|
---|
| 76 | else
|
---|
| 77 | LINE_LYNX='#CONFIG_lynx is not set'
|
---|
| 78 | fi
|
---|
| 79 | if [ "$DEP_SUDO" = y ]; then
|
---|
| 80 | LINE_SUDO='CONFIG_sudo=y'
|
---|
| 81 | else
|
---|
| 82 | LINE_SUDO='#CONFIG_sudo is not set'
|
---|
| 83 | fi
|
---|
| 84 | if [ "$DEP_WGET" = y ]; then
|
---|
| 85 | LINE_WGET='CONFIG_wget=y'
|
---|
| 86 | else
|
---|
| 87 | LINE_WGET='#CONFIG_wget is not set'
|
---|
| 88 | fi
|
---|
| 89 | if [ "$DEP_GPM" = y ]; then
|
---|
| 90 | LINE_GPM='CONFIG_gpm=y'
|
---|
| 91 | else
|
---|
| 92 | LINE_GPM='#CONFIG_gpm is not set'
|
---|
| 93 | fi
|
---|
| 94 | if [ "$DEP_SVN" = y ]; then
|
---|
| 95 | LINE_SVN='CONFIG_subversion=y'
|
---|
| 96 | else
|
---|
| 97 | LINE_SVN='#CONFIG_subversion is not set'
|
---|
| 98 | fi
|
---|
| 99 | if [ "$DEP_OPENSSL" = y ]; then
|
---|
| 100 | LINE_OPENSSL='CONFIG_openssl=y'
|
---|
| 101 | else
|
---|
| 102 | LINE_OPENSSL='#CONFIG_openssl is not set'
|
---|
| 103 | fi
|
---|
| 104 | if [ "$DEP_PYTHON" = y ]; then
|
---|
| 105 | LINE_PYTHON='CONFIG_python2=y'
|
---|
| 106 | else
|
---|
| 107 | LINE_PYTHON='#CONFIG_python2 is not set'
|
---|
| 108 | fi
|
---|
| 109 |
|
---|
| 110 | cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
|
---|
[1f25a75] | 111 | $LINE_OPENSSL
|
---|
[e576789] | 112 | $LINE_PYTHON
|
---|
| 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
|
---|
[945ccaa] | 123 | WRAP_INSTALL=$WRAP_INSTALL
|
---|
[e576789] | 124 | EOF
|
---|
| 125 |
|
---|
| 126 | # Generates the scripts for the blfs tools dependencies (in ./scripts)
|
---|
| 127 | yes "yes" | $BUILDDIR$BLFS_ROOT/gen_pkg_book.sh $BUILDDIR$BLFS_ROOT
|
---|
| 128 |
|
---|
| 129 | # Move the scriptlets where they should be
|
---|
| 130 | sudo rm -rf $BUILDDIR$BLFS_ROOT/scripts
|
---|
| 131 | mv scripts $BUILDDIR$BLFS_ROOT
|
---|
| 132 |
|
---|
| 133 | # Generates a list containing download and copying instructions for tarballs
|
---|
| 134 | echo -e '#!/bin/bash\nset -e\n' > $BUILDDIR$BLFS_ROOT/download_script
|
---|
[2cf28dc] | 135 | sed -n -e '/PACKAGE=/,/^fi/{/^fi/a\
|
---|
| 136 | cp $PACKAGE $SRC_ARCHIVE
|
---|
| 137 | p}' \
|
---|
[39da010] | 138 | -e '/|[ ]*md5sum/p' \
|
---|
[2cf28dc] | 139 | -e '/PACKAGE1=/,/^fi/{/^fi/a\
|
---|
| 140 | cp $PACKAGE1 $SRC_ARCHIVE
|
---|
| 141 | p}' \
|
---|
| 142 | -e '/PATCH=/,/^fi/{/^fi/a\
|
---|
[cee84ad] | 143 | cp $PATCH $SRC_ARCHIVE
|
---|
[2cf28dc] | 144 | p}' \
|
---|
| 145 | -e '/URL=/,/^fi/{/^fi/a\
|
---|
[cee84ad] | 146 | cp $BOOTPACKG $SRC_ARCHIVE
|
---|
[2cf28dc] | 147 | p}' \
|
---|
[e576789] | 148 | $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 149 | chmod u+x $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 150 |
|
---|
| 151 | # Downloads (or copy) to build_dir/sources
|
---|
| 152 | pushd $BUILDDIR/sources
|
---|
| 153 | # Remove `unpacked' files if some have been left
|
---|
| 154 | sudo find . -name unpacked -exec rm \{\} \;
|
---|
[67723e1] | 155 | if [ "$GETPKG" = "y" ]; then
|
---|
| 156 | FTP_SERVER=$SERVER/pub/blfs/ \
|
---|
[85506da] | 157 | SRC_ARCHIVE=${SRC_ARCHIVE:-/dev/null} \
|
---|
[67723e1] | 158 | $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 159 | else # Save the download script in case the user wants to run it later
|
---|
| 160 | cp $BUILDDIR$BLFS_ROOT/download_script .
|
---|
| 161 | fi
|
---|
[e576789] | 162 | popd
|
---|
| 163 | rm -v $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 164 |
|
---|
| 165 | # Suppresses unneeded parts of the scriptlets
|
---|
[c1626d8] | 166 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
[cbca63a] | 167 | # libxslt pulls docbook-xsl in, which populates the catalog with annoying
|
---|
| 168 | # **EDITME** references. Fortunately, those lines are regognizable because
|
---|
| 169 | # they occur between lines containing '/etc/xml/catalog' at the end of the
|
---|
| 170 | # line (without '&&'). I have not found a simple way to delete lines
|
---|
| 171 | # between 2 addresses, excluding either the first or the last one. So use
|
---|
| 172 | # a loop for accumulating lines and deleting at the end.
|
---|
| 173 | # Sorry for sed synthax.
|
---|
[c1626d8] | 174 | sed -i '\@^[[:space:]]*/etc/xml/catalog$@{
|
---|
| 175 | n
|
---|
| 176 | :a
|
---|
| 177 | \@/etc/xml/catalog$@bb
|
---|
| 178 | N
|
---|
| 179 | ba
|
---|
| 180 | :b
|
---|
| 181 | d}' \
|
---|
| 182 | $BUILDDIR$BLFS_ROOT/scripts/*docbook-xsl
|
---|
| 183 | fi
|
---|
[e576789] | 184 | if [ "$DEP_SUDO" = y ]; then
|
---|
[cbca63a] | 185 | sed -i '/cat.*pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
|
---|
[e576789] | 186 | fi
|
---|
| 187 | if [ "$DEP_SVN" = y ]; then
|
---|
| 188 | sed -i -e /javahl/d -e /swig/d $BUILDDIR$BLFS_ROOT/scripts/*subversion
|
---|
| 189 | fi
|
---|
| 190 | if [ "$DEP_LYNX" = y ]; then
|
---|
| 191 | if [ "$DEP_OPENSSL" = y -o "$DEP_WGET" = y ]; then
|
---|
[67723e1] | 192 | sed -e 's/configure/& --with-ssl/' \
|
---|
| 193 | -i $BUILDDIR$BLFS_ROOT/scripts/*lynx
|
---|
[e576789] | 194 | fi
|
---|
| 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
|
---|
| 209 | @for file in *-*; do \\
|
---|
| 210 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 211 | --stringparam package \$\${file##*z-} \\
|
---|
| 212 | -o track.tmp \\
|
---|
| 213 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 214 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 215 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 216 | rm track.tmp; \\
|
---|
| 217 | done
|
---|
| 218 | @touch \$@
|
---|
| 219 | @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
|
---|
| 220 | @echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 221 | EOF
|
---|
| 222 | popd
|
---|
| 223 | }
|
---|