[e576789] | 1 | #!/bin/bash
|
---|
[fd4a798] | 2 |
|
---|
[e576789] | 3 | set -e
|
---|
| 4 |
|
---|
[65d7d46] | 5 | : << inline_doc
|
---|
| 6 | Installs a set-up to build BLFS packages.
|
---|
| 7 | You can set these variables:
|
---|
| 8 | TRACKING_DIR : where the installed package file is kept.
|
---|
[506120ee] | 9 | (default /var/lib/jhalfs/BLFS)
|
---|
| 10 | INITSYS : which books do you want? 'sysv' or 'systemd' (default sysv)
|
---|
[65d7d46] | 11 | BLFS_ROOT : where the installed tools will be installed, relative to $HOME.
|
---|
| 12 | Must start with a '/' (default /blfs_root)
|
---|
[9b99ada] | 13 | BLFS_COMMIT : any commit (branch/tag/sha)
|
---|
| 14 | (default trunk)
|
---|
| 15 | LFS_COMMIT : any commit (branch/tag/sha)
|
---|
| 16 | (default trunk)
|
---|
[65d7d46] | 17 | Examples:
|
---|
| 18 | 1 - If you plan to use the tools to build BLFS on top of LFS, but you did not
|
---|
| 19 | use jhalfs, or forgot to include the jhalfs-blfs tools:
|
---|
[2dd1992] | 20 | (as root) mkdir -p /var/lib/jhalfs/BLFS && chown -R <user> /var/lib/jhalfs
|
---|
[39dc04a] | 21 | (as user) INITSYS=<your system> ./install-blfs-tools.sh
|
---|
[84440e6] | 22 | 2 - To install with only user privileges (default to sysv):
|
---|
[2dd1992] | 23 | TRACKING_DIR=$HOME/blfs_root/trackdir ./install-blfs-tools.sh
|
---|
[e5d44f5] | 24 |
|
---|
| 25 | This script can also be called automatically after running make in this
|
---|
| 26 | directory. The parameters will then be taken from the configuration file.
|
---|
[65d7d46] | 27 | inline_doc
|
---|
| 28 |
|
---|
| 29 |
|
---|
[e576789] | 30 | # VT100 colors
|
---|
| 31 | declare -r BLACK=$'\e[1;30m'
|
---|
| 32 | declare -r DK_GRAY=$'\e[0;30m'
|
---|
| 33 |
|
---|
| 34 | declare -r RED=$'\e[31m'
|
---|
| 35 | declare -r GREEN=$'\e[32m'
|
---|
| 36 | declare -r YELLOW=$'\e[33m'
|
---|
| 37 | declare -r BLUE=$'\e[34m'
|
---|
| 38 | declare -r MAGENTA=$'\e[35m'
|
---|
| 39 | declare -r CYAN=$'\e[36m'
|
---|
| 40 | declare -r WHITE=$'\e[37m'
|
---|
| 41 |
|
---|
| 42 | declare -r OFF=$'\e[0m'
|
---|
| 43 | declare -r BOLD=$'\e[1m'
|
---|
| 44 | declare -r REVERSE=$'\e[7m'
|
---|
| 45 | declare -r HIDDEN=$'\e[8m'
|
---|
| 46 |
|
---|
| 47 | declare -r tab_=$'\t'
|
---|
| 48 | declare -r nl_=$'\n'
|
---|
| 49 |
|
---|
| 50 | declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
|
---|
| 51 | declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
|
---|
| 52 | declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
|
---|
[e5d44f5] | 53 | declare -r dotSTR=".................." # Format display of parameters and versions
|
---|
[e576789] | 54 |
|
---|
| 55 | # bold yellow > < pair
|
---|
| 56 | declare -r R_arrow=$'\e[1;33m>\e[0m'
|
---|
| 57 | declare -r L_arrow=$'\e[1;33m<\e[0m'
|
---|
| 58 | VERBOSITY=1
|
---|
| 59 |
|
---|
[e5d44f5] | 60 | # Take parameters from "configuration" if $1="auto"
|
---|
| 61 | if [ "$1" = auto ]; then
|
---|
| 62 | [[ $VERBOSITY > 0 ]] && echo -n "Loading configuration ... "
|
---|
| 63 | source configuration
|
---|
| 64 | [[ $? > 0 ]] && echo -e "\nconfiguration could not be loaded" && exit 2
|
---|
| 65 | [[ $VERBOSITY > 0 ]] && echo "OK"
|
---|
| 66 | fi
|
---|
| 67 |
|
---|
| 68 | if [ "$BOOK_BLFS" = y ]; then
|
---|
| 69 | ## Read variables and sanity checks
|
---|
[9b99ada] | 70 | [[ "$BRANCH" = y ]] && BLFS_COMMIT=$COMMIT
|
---|
[e5d44f5] | 71 | [[ "$WORKING_COPY" = y ]] && BLFS_BOOK=$BOOK
|
---|
| 72 | [[ "$BOOK" = "**EDIT ME**" ]] &&
|
---|
[506120ee] | 73 | echo You have not set the BLFS working copy location && exit 1
|
---|
[9b99ada] | 74 | [[ "$LFS_BRANCH" = y ]] && LFS_COMMIT=$BLFS_LFS_COMMIT
|
---|
[506120ee] | 75 | [[ "$LFS_WORKING_COPY" = y ]] && LFS_BOOK=$BLFS_LFS_BOOK
|
---|
| 76 | [[ "$LFS_BOOK" = "**EDIT ME**" ]] &&
|
---|
| 77 | echo You have not set the LFS working copy location && exit 1
|
---|
[e5d44f5] | 78 | fi
|
---|
| 79 |
|
---|
[e576789] | 80 | COMMON_DIR="common"
|
---|
[e5d44f5] | 81 | # blfs-tool envars
|
---|
[e576789] | 82 | BLFS_TOOL='y'
|
---|
| 83 | BUILDDIR=$(cd ~;pwd)
|
---|
[65d7d46] | 84 | BLFS_ROOT="${BLFS_ROOT:=/blfs_root}"
|
---|
| 85 | TRACKING_DIR="${TRACKING_DIR:=/var/lib/jhalfs/BLFS}"
|
---|
[39dc04a] | 86 | INITSYS="${INITSYS:=sysv}"
|
---|
[9b99ada] | 87 | BLFS_COMMIT=${BLFS_COMMIT:=trunk}
|
---|
| 88 | LFS_COMMIT=${LFS_COMMIT:=trunk}
|
---|
[e5d44f5] | 89 | BLFS_XML=${BLFS_XML:=blfs-xml}
|
---|
[506120ee] | 90 | LFS_XML=${LFS_XML:=lfs-xml}
|
---|
[e5d44f5] | 91 |
|
---|
| 92 | # Validate the configuration:
|
---|
[506120ee] | 93 | PARAMS="BLFS_ROOT TRACKING_DIR INITSYS BLFS_XML LFS_XML"
|
---|
[e5d44f5] | 94 | if [ "$WORKING_COPY" = y ]; then
|
---|
[506120ee] | 95 | PARAMS="$PARAMS WORKING_COPY BLFS_BOOK"
|
---|
[e5d44f5] | 96 | else
|
---|
[9b99ada] | 97 | PARAMS="$PARAMS BLFS_COMMIT"
|
---|
[e5d44f5] | 98 | fi
|
---|
[506120ee] | 99 | if [ "$LFS_WORKING_COPY" = y ]; then
|
---|
| 100 | PARAMS="$PARAMS LFS_WORKING_COPY LFS_BOOK"
|
---|
| 101 | else
|
---|
[9b99ada] | 102 | PARAMS="$PARAMS LFS_COMMIT"
|
---|
[506120ee] | 103 | fi
|
---|
[e5d44f5] | 104 | # Format for displaying parameters:
|
---|
| 105 | declare -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
| 106 |
|
---|
| 107 | for config_param in $PARAMS; do
|
---|
| 108 | echo -e "`eval echo $PARAM_VALS`"
|
---|
| 109 | done
|
---|
[e576789] | 110 |
|
---|
[e5d44f5] | 111 | echo "${SD_BORDER}${nl_}"
|
---|
| 112 | echo -n "Are you happy with these settings? yes/no (no): "
|
---|
| 113 | read ANSWER
|
---|
| 114 | if [ x$ANSWER != "xyes" ] ; then
|
---|
| 115 | echo "${nl_}Rerun make and fix your settings.${nl_}"
|
---|
| 116 | exit
|
---|
| 117 | fi
|
---|
[e576789] | 118 | [[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
|
---|
| 119 |
|
---|
| 120 | #*******************************************************************#
|
---|
[e25788e] | 121 | [[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh> ..."
|
---|
[e576789] | 122 | source $COMMON_DIR/libs/func_check_version.sh
|
---|
| 123 | [[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
---|
[e25788e] | 124 | [[ $VERBOSITY > 0 ]] && echo " OK"
|
---|
[e576789] | 125 |
|
---|
| 126 | [[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
|
---|
| 127 |
|
---|
| 128 | # Check for build prerequisites.
|
---|
| 129 | echo
|
---|
[65d7d46] | 130 | check_alfs_tools
|
---|
[e576789] | 131 | echo "${SD_BORDER}${nl_}"
|
---|
| 132 |
|
---|
| 133 | # Install the files
|
---|
[e25788e] | 134 | [[ $VERBOSITY > 0 ]] && echo -n "Populating the ${BUILDDIR}${BLFS_ROOT} directory "
|
---|
[e576789] | 135 | [[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && mkdir -pv ${BUILDDIR}${BLFS_ROOT}
|
---|
[e5d44f5] | 136 | rm -rf ${BUILDDIR}${BLFS_ROOT}/*
|
---|
[e576789] | 137 | cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
|
---|
| 138 | cp -r menu ${BUILDDIR}${BLFS_ROOT}
|
---|
| 139 | cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
|
---|
| 140 | cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
|
---|
| 141 | [[ $VERBOSITY > 0 ]] && echo "... OK"
|
---|
| 142 |
|
---|
| 143 | # Clean-up
|
---|
[e25788e] | 144 | [[ $VERBOSITY > 0 ]] && echo -n "Cleaning the ${BUILDDIR}${BLFS_ROOT} directory "
|
---|
[2dd1992] | 145 | # We do not want to keep an old version of the book:
|
---|
[e5d44f5] | 146 | rm -rf ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
|
---|
[506120ee] | 147 | rm -rf ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
|
---|
[e576789] | 148 |
|
---|
| 149 | # Set some harcoded envars to their proper values
|
---|
| 150 | sed -i s@tracking-dir@$TRACKING_DIR@ \
|
---|
[b734bfb] | 151 | ${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
|
---|
[65d7d46] | 152 |
|
---|
| 153 | # Ensures the tracking directory exists.
|
---|
| 154 | # Throws an error if it does not exist and the user does not
|
---|
| 155 | # have write permission to create it.
|
---|
| 156 | # If it exists, does nothing.
|
---|
| 157 | mkdir -p $TRACKING_DIR
|
---|
[e576789] | 158 | [[ $VERBOSITY > 0 ]] && echo "... OK"
|
---|
| 159 |
|
---|
[e5d44f5] | 160 | [[ -z "$BLFS_BOOK" ]] ||
|
---|
[506120ee] | 161 | [[ $BLFS_BOOK = $BUILDDIR$BLFS_ROOT/$BLFS_XML ]] || {
|
---|
[e25788e] | 162 | [[ $VERBOSITY > 0 ]] && echo -n "Retrieving BLFS working copy (may take some time) "
|
---|
[e5d44f5] | 163 | cp -a $BLFS_BOOK $BUILDDIR$BLFS_ROOT/$BLFS_XML
|
---|
[e25788e] | 164 | [[ $VERBOSITY > 0 ]] && echo "... OK"
|
---|
[506120ee] | 165 | }
|
---|
| 166 |
|
---|
| 167 | [[ -z "$LFS_BOOK" ]] ||
|
---|
| 168 | [[ $LFS_BOOK = $BUILDDIR$BLFS_ROOT/$LFS_XML ]] || {
|
---|
[e25788e] | 169 | [[ $VERBOSITY > 0 ]] && echo -n "Retrieving the LFS working copy (may take some time) "
|
---|
[506120ee] | 170 | cp -a $LFS_BOOK $BUILDDIR$BLFS_ROOT/$LFS_XML
|
---|
[e25788e] | 171 | [[ $VERBOSITY > 0 ]] && echo "... OK"
|
---|
[506120ee] | 172 | }
|
---|
[e5d44f5] | 173 |
|
---|
[e25788e] | 174 | [[ $VERBOSITY > 0 ]] && echo "Initializing the BLFS tool directory "
|
---|
[2dd1992] | 175 | make -j1 -C $BUILDDIR$BLFS_ROOT \
|
---|
| 176 | TRACKING_DIR=$TRACKING_DIR \
|
---|
[39dc04a] | 177 | REV=$INITSYS \
|
---|
[506120ee] | 178 | LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
|
---|
[9b99ada] | 179 | LFS-BRANCH=${LFS_COMMIT} \
|
---|
[e5d44f5] | 180 | BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
|
---|
[9b99ada] | 181 | BLFS-BRANCH=${BLFS_COMMIT} \
|
---|
[2dd1992] | 182 | $BUILDDIR$BLFS_ROOT/packages.xml
|
---|
[e576789] | 183 | [[ $VERBOSITY > 0 ]] && echo "... OK"
|
---|
| 184 |
|
---|