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