[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
|
---|
[e58cf153] | 31 | # -r: recursive; -u: only if newer; -T: otherwise, would copy to a subdirectory
|
---|
| 32 | # of blfs-xml, if blfs-xml already exists
|
---|
| 33 | cp -ruT $BLFS_WC_LOCATION ${BUILDDIR}${BLFS_ROOT}/blfs-xml
|
---|
[854854e] | 34 | fi
|
---|
| 35 | # Downloads the book if necessary, initialize the tracking file and the
|
---|
| 36 | # package database.
|
---|
[e576789] | 37 | # sudo is needed if $BUILDDIR/var/lib is owned by root and /var/lib/jhalfs
|
---|
| 38 | # has to be created
|
---|
| 39 | sudo make -j1 -C $BUILDDIR$BLFS_ROOT TRACKING_DIR=$BUILDDIR$TRACKING_DIR \
|
---|
| 40 | $BUILDDIR$BLFS_ROOT/packages.xml
|
---|
| 41 |
|
---|
| 42 | # Because the BLFS Makefile is supposed to be used in chroot (or booted)
|
---|
| 43 | # mode, the tracking file has wrong path for DTD. Change it:
|
---|
| 44 | sudo sed -i s@$BUILDDIR@@ $BUILDDIR$TRACKING_DIR/instpkg.xml
|
---|
| 45 |
|
---|
| 46 | # Manually build a 'configuration' file
|
---|
| 47 | if [ "$DEP_LIBXML" = y ]; then
|
---|
| 48 | LINE_LIBXML='CONFIG_libxml2=y'
|
---|
| 49 | else
|
---|
| 50 | LINE_LIBXML='#CONFIG_libxml2 is not set'
|
---|
| 51 | fi
|
---|
| 52 | if [ "$DEP_LIBXSLT" = y ]; then
|
---|
| 53 | LINE_LIBXSLT='CONFIG_libxslt=y'
|
---|
| 54 | else
|
---|
| 55 | LINE_LIBXSLT='#CONFIG_libxslt is not set'
|
---|
| 56 | fi
|
---|
| 57 | if [ "$DEP_TIDY" = y ]; then
|
---|
| 58 | LINE_TIDY='CONFIG_html-tidy=y'
|
---|
| 59 | else
|
---|
| 60 | LINE_TIDY='#CONFIG_html-tidy is not set'
|
---|
| 61 | fi
|
---|
| 62 | if [ "$DEP_DBXML" = y ]; then
|
---|
| 63 | LINE_DBXML='CONFIG_DocBook=y'
|
---|
| 64 | else
|
---|
| 65 | LINE_DBXML='#CONFIG_DocBook is not set'
|
---|
| 66 | fi
|
---|
| 67 | if [ "$DEP_LYNX" = y ]; then
|
---|
| 68 | LINE_LYNX='CONFIG_lynx=y'
|
---|
| 69 | else
|
---|
| 70 | LINE_LYNX='#CONFIG_lynx is not set'
|
---|
| 71 | fi
|
---|
| 72 | if [ "$DEP_SUDO" = y ]; then
|
---|
| 73 | LINE_SUDO='CONFIG_sudo=y'
|
---|
| 74 | else
|
---|
| 75 | LINE_SUDO='#CONFIG_sudo is not set'
|
---|
| 76 | fi
|
---|
| 77 | if [ "$DEP_WGET" = y ]; then
|
---|
| 78 | LINE_WGET='CONFIG_wget=y'
|
---|
| 79 | else
|
---|
| 80 | LINE_WGET='#CONFIG_wget is not set'
|
---|
| 81 | fi
|
---|
| 82 | if [ "$DEP_GPM" = y ]; then
|
---|
| 83 | LINE_GPM='CONFIG_gpm=y'
|
---|
| 84 | else
|
---|
| 85 | LINE_GPM='#CONFIG_gpm is not set'
|
---|
| 86 | fi
|
---|
| 87 | if [ "$DEP_SVN" = y ]; then
|
---|
| 88 | LINE_SVN='CONFIG_subversion=y'
|
---|
| 89 | else
|
---|
| 90 | LINE_SVN='#CONFIG_subversion is not set'
|
---|
| 91 | fi
|
---|
| 92 | if [ "$DEP_OPENSSL" = y ]; then
|
---|
| 93 | LINE_OPENSSL='CONFIG_openssl=y'
|
---|
| 94 | else
|
---|
| 95 | LINE_OPENSSL='#CONFIG_openssl is not set'
|
---|
| 96 | fi
|
---|
| 97 | if [ "$DEP_PYTHON" = y ]; then
|
---|
| 98 | LINE_PYTHON='CONFIG_python2=y'
|
---|
| 99 | else
|
---|
| 100 | LINE_PYTHON='#CONFIG_python2 is not set'
|
---|
| 101 | fi
|
---|
| 102 |
|
---|
| 103 | cat >$BUILDDIR$BLFS_ROOT/configuration <<EOF
|
---|
| 104 | $LINE_PYTHON
|
---|
| 105 | $LINE_LIBXML
|
---|
| 106 | $LINE_LIBXSLT
|
---|
| 107 | $LINE_TIDY
|
---|
| 108 | $LINE_DBXML
|
---|
| 109 | $LINE_OPENSSL
|
---|
| 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
|
---|
| 129 | sed -n -e '/PACKAGE=/,/md5sum/p' \
|
---|
| 130 | -e '/PACKAGE1=/,/^fi/p' \
|
---|
| 131 | -e '/PATCH=/,/^fi/p' \
|
---|
[bbcdeab] | 132 | -e '/URL=/,/^fi/p' \
|
---|
[e576789] | 133 | $BUILDDIR$BLFS_ROOT/scripts/* >> $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 134 | chmod u+x $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 135 |
|
---|
| 136 | # Downloads (or copy) to build_dir/sources
|
---|
| 137 | pushd $BUILDDIR/sources
|
---|
| 138 | # Remove `unpacked' files if some have been left
|
---|
| 139 | sudo find . -name unpacked -exec rm \{\} \;
|
---|
| 140 | FTP_SERVER=$SERVER/pub/blfs/ SRC_ARCHIVE=$SRC_ARCHIVE $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 141 | # The blfs-bootscripts package is at the wrong location
|
---|
| 142 | mkdir -p blfs-bootscripts
|
---|
| 143 | cp blfs-bootscripts*tar* blfs-bootscripts
|
---|
| 144 | popd
|
---|
| 145 | rm -v $BUILDDIR$BLFS_ROOT/download_script
|
---|
| 146 |
|
---|
| 147 | # Suppresses unneeded parts of the scriptlets
|
---|
| 148 | if [ "$DEP_WGET" = y ] && ! [ "$DEP_OPENSSL" = y ]; then
|
---|
| 149 | sed -i s'/-ssl=.*/out-ssl/' $BUILDDIR$BLFS_ROOT/scripts/*wget
|
---|
| 150 | fi
|
---|
| 151 | if [ "$DEP_SUDO" = y ]; then
|
---|
| 152 | sed -i '/pam.d/i mkdir -p /etc/pam.d' $BUILDDIR$BLFS_ROOT/scripts/*sudo
|
---|
| 153 | fi
|
---|
| 154 | if [ "$DEP_SVN" = y ]; then
|
---|
| 155 | sed -i -e /javahl/d -e /swig/d $BUILDDIR$BLFS_ROOT/scripts/*subversion
|
---|
| 156 | sed -i -e '/pushd/,/popd/d' -e /tea/d $BUILDDIR$BLFS_ROOT/scripts/*sqlite
|
---|
| 157 | fi
|
---|
| 158 | if [ "$DEP_PYTHON" = y ]; then
|
---|
| 159 | sed -i -e '/^make.*Doc/d' -e '/^chmod/{n;N;d}' $BUILDDIR$BLFS_ROOT/scripts/*python2
|
---|
| 160 | fi
|
---|
| 161 | if [ "$DEP_OPENSSL" = y ]; then
|
---|
| 162 | sed -i 's/^make$/make -j1/' $BUILDDIR$BLFS_ROOT/scripts/*openssl
|
---|
| 163 | fi
|
---|
| 164 | if [ "$DEP_LYNX" = y ]; then
|
---|
| 165 | if [ "$DEP_OPENSSL" = y -o "$DEP_WGET" = y ]; then
|
---|
| 166 | sed -i -e 's/configure/& --with-ssl/' \
|
---|
| 167 | -e '/make$/i echo "#define USE_OPENSSL_INCL 1" >> lynx_cfg.h &&' \
|
---|
| 168 | $BUILDDIR$BLFS_ROOT/scripts/*lynx
|
---|
| 169 | fi
|
---|
| 170 | fi
|
---|
| 171 | # At last generates the build Makefile
|
---|
| 172 | mkdir -p $BUILDDIR$BLFS_ROOT/work
|
---|
| 173 | pushd $BUILDDIR$BLFS_ROOT/work
|
---|
| 174 | ../gen-makefile.sh
|
---|
| 175 | sed -i -e '/xsltproc/,+6d' \
|
---|
| 176 | -e '/^all/s@$@ update@' \
|
---|
| 177 | -e 's/touch/@touch/' Makefile
|
---|
| 178 | cat >> Makefile << EOF
|
---|
| 179 | update:
|
---|
| 180 | @echo Updating the tracking file
|
---|
| 181 | @for file in *-*; do \\
|
---|
| 182 | xsltproc --stringparam packages ../packages.xml \\
|
---|
| 183 | --stringparam package \$\${file##*z-} \\
|
---|
| 184 | -o track.tmp \\
|
---|
| 185 | ../xsl/bump.xsl \$(TRACKING_FILE); \\
|
---|
| 186 | sed -i 's@PACKDESC@$BLFS_ROOT/packdesc.dtd@' track.tmp; \\
|
---|
| 187 | xmllint --format --postvalid track.tmp > \$(TRACKING_FILE); \\
|
---|
| 188 | rm track.tmp; \\
|
---|
| 189 | done
|
---|
| 190 | @touch \$@
|
---|
| 191 | @echo -e "\n\n "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK
|
---|
| 192 | @echo --------------------------------------------------------------------------------\$(WHITE)
|
---|
| 193 | EOF
|
---|
| 194 | popd
|
---|
| 195 | }
|
---|