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