2013-10-29 16:42:03 +01:00
|
|
|
#!/bin/bash
|
2021-10-31 10:22:30 +01:00
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
set -e
|
|
|
|
|
2013-12-23 22:56:10 +01:00
|
|
|
: << inline_doc
|
|
|
|
Installs a set-up to build BLFS packages.
|
|
|
|
You can set these variables:
|
|
|
|
TRACKING_DIR : where the installed package file is kept.
|
2017-08-09 15:55:55 +02:00
|
|
|
(default /var/lib/jhalfs/BLFS)
|
|
|
|
INITSYS : which books do you want? 'sysv' or 'systemd' (default sysv)
|
2013-12-23 22:56:10 +01:00
|
|
|
BLFS_ROOT : where the installed tools will be installed, relative to $HOME.
|
|
|
|
Must start with a '/' (default /blfs_root)
|
|
|
|
BLFS_BRANCH_ID: development, branch-xxx, xxx (where xxx is a valid tag)
|
|
|
|
(default development)
|
2017-08-09 15:55:55 +02:00
|
|
|
LFS_BRANCH_ID : development, branch-xxx, xxx (where xxx is a valid tag)
|
|
|
|
(default development)
|
2013-12-23 22:56:10 +01:00
|
|
|
Examples:
|
|
|
|
1 - If you plan to use the tools to build BLFS on top of LFS, but you did not
|
|
|
|
use jhalfs, or forgot to include the jhalfs-blfs tools:
|
2014-09-23 22:18:44 +02:00
|
|
|
(as root) mkdir -p /var/lib/jhalfs/BLFS && chown -R <user> /var/lib/jhalfs
|
2017-03-15 22:06:17 +01:00
|
|
|
(as user) INITSYS=<your system> ./install-blfs-tools.sh
|
2017-03-02 17:38:25 +01:00
|
|
|
2 - To install with only user privileges (default to sysv):
|
2014-09-23 22:18:44 +02:00
|
|
|
TRACKING_DIR=$HOME/blfs_root/trackdir ./install-blfs-tools.sh
|
2017-03-15 10:16:40 +01:00
|
|
|
|
|
|
|
This script can also be called automatically after running make in this
|
|
|
|
directory. The parameters will then be taken from the configuration file.
|
2013-12-23 22:56:10 +01:00
|
|
|
inline_doc
|
|
|
|
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
# VT100 colors
|
|
|
|
declare -r BLACK=$'\e[1;30m'
|
|
|
|
declare -r DK_GRAY=$'\e[0;30m'
|
|
|
|
|
|
|
|
declare -r RED=$'\e[31m'
|
|
|
|
declare -r GREEN=$'\e[32m'
|
|
|
|
declare -r YELLOW=$'\e[33m'
|
|
|
|
declare -r BLUE=$'\e[34m'
|
|
|
|
declare -r MAGENTA=$'\e[35m'
|
|
|
|
declare -r CYAN=$'\e[36m'
|
|
|
|
declare -r WHITE=$'\e[37m'
|
|
|
|
|
|
|
|
declare -r OFF=$'\e[0m'
|
|
|
|
declare -r BOLD=$'\e[1m'
|
|
|
|
declare -r REVERSE=$'\e[7m'
|
|
|
|
declare -r HIDDEN=$'\e[8m'
|
|
|
|
|
|
|
|
declare -r tab_=$'\t'
|
|
|
|
declare -r nl_=$'\n'
|
|
|
|
|
|
|
|
declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
|
|
|
|
declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
|
|
|
|
declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
|
2017-03-15 10:16:40 +01:00
|
|
|
declare -r dotSTR=".................." # Format display of parameters and versions
|
2013-10-29 16:42:03 +01:00
|
|
|
|
|
|
|
# bold yellow > < pair
|
|
|
|
declare -r R_arrow=$'\e[1;33m>\e[0m'
|
|
|
|
declare -r L_arrow=$'\e[1;33m<\e[0m'
|
|
|
|
VERBOSITY=1
|
|
|
|
|
2017-03-15 10:16:40 +01:00
|
|
|
# Take parameters from "configuration" if $1="auto"
|
|
|
|
if [ "$1" = auto ]; then
|
|
|
|
[[ $VERBOSITY > 0 ]] && echo -n "Loading configuration ... "
|
|
|
|
source configuration
|
|
|
|
[[ $? > 0 ]] && echo -e "\nconfiguration could not be loaded" && exit 2
|
|
|
|
[[ $VERBOSITY > 0 ]] && echo "OK"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$BOOK_BLFS" = y ]; then
|
|
|
|
## Read variables and sanity checks
|
2021-05-01 09:24:56 +02:00
|
|
|
[[ "$relGIT" = y ]] && BLFS_BRANCH_ID=development
|
2017-03-15 10:16:40 +01:00
|
|
|
[[ "$BRANCH" = y ]] && BLFS_BRANCH_ID=$BRANCH_ID
|
|
|
|
[[ "$WORKING_COPY" = y ]] && BLFS_BOOK=$BOOK
|
|
|
|
[[ "$BRANCH_ID" = "**EDIT ME**" ]] &&
|
2017-08-09 15:55:55 +02:00
|
|
|
echo You have not set the BLFS book version or branch && exit 1
|
2017-03-15 10:16:40 +01:00
|
|
|
[[ "$BOOK" = "**EDIT ME**" ]] &&
|
2017-08-09 15:55:55 +02:00
|
|
|
echo You have not set the BLFS working copy location && exit 1
|
2021-05-01 09:24:56 +02:00
|
|
|
[[ "$LFS_relGIT" = y ]] && LFS_BRANCH_ID=development
|
2017-08-09 15:55:55 +02:00
|
|
|
[[ "$LFS_BRANCH" = y ]] && LFS_BRANCH_ID=$BLFS_LFS_BRANCH_ID
|
|
|
|
[[ "$LFS_WORKING_COPY" = y ]] && LFS_BOOK=$BLFS_LFS_BOOK
|
|
|
|
[[ "$LFS_BRANCH_ID" = "**EDIT ME**" ]] &&
|
|
|
|
echo You have not set the LFS book version or branch && exit 1
|
|
|
|
[[ "$LFS_BOOK" = "**EDIT ME**" ]] &&
|
|
|
|
echo You have not set the LFS working copy location && exit 1
|
2017-03-15 10:16:40 +01:00
|
|
|
fi
|
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
COMMON_DIR="common"
|
2017-03-15 10:16:40 +01:00
|
|
|
# blfs-tool envars
|
2013-10-29 16:42:03 +01:00
|
|
|
BLFS_TOOL='y'
|
|
|
|
BUILDDIR=$(cd ~;pwd)
|
2013-12-23 22:56:10 +01:00
|
|
|
BLFS_ROOT="${BLFS_ROOT:=/blfs_root}"
|
|
|
|
TRACKING_DIR="${TRACKING_DIR:=/var/lib/jhalfs/BLFS}"
|
2017-03-15 22:06:17 +01:00
|
|
|
INITSYS="${INITSYS:=sysv}"
|
2017-03-15 10:16:40 +01:00
|
|
|
BLFS_BRANCH_ID=${BLFS_BRANCH_ID:=development}
|
2017-08-09 15:55:55 +02:00
|
|
|
LFS_BRANCH_ID=${LFS_BRANCH_ID:=development}
|
2017-03-15 10:16:40 +01:00
|
|
|
BLFS_XML=${BLFS_XML:=blfs-xml}
|
2017-08-09 15:55:55 +02:00
|
|
|
LFS_XML=${LFS_XML:=lfs-xml}
|
2017-03-15 10:16:40 +01:00
|
|
|
|
|
|
|
# Validate the configuration:
|
2017-08-09 15:55:55 +02:00
|
|
|
PARAMS="BLFS_ROOT TRACKING_DIR INITSYS BLFS_XML LFS_XML"
|
2017-03-15 10:16:40 +01:00
|
|
|
if [ "$WORKING_COPY" = y ]; then
|
2017-08-09 15:55:55 +02:00
|
|
|
PARAMS="$PARAMS WORKING_COPY BLFS_BOOK"
|
2017-03-15 10:16:40 +01:00
|
|
|
else
|
|
|
|
PARAMS="$PARAMS BLFS_BRANCH_ID"
|
|
|
|
fi
|
2017-08-09 15:55:55 +02:00
|
|
|
if [ "$LFS_WORKING_COPY" = y ]; then
|
|
|
|
PARAMS="$PARAMS LFS_WORKING_COPY LFS_BOOK"
|
|
|
|
else
|
|
|
|
PARAMS="$PARAMS LFS_BRANCH_ID"
|
|
|
|
fi
|
2017-03-15 10:16:40 +01:00
|
|
|
# Format for displaying parameters:
|
|
|
|
declare -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
|
|
|
|
|
|
|
for config_param in $PARAMS; do
|
|
|
|
echo -e "`eval echo $PARAM_VALS`"
|
|
|
|
done
|
2013-10-29 16:42:03 +01:00
|
|
|
|
2017-03-15 10:16:40 +01:00
|
|
|
echo "${SD_BORDER}${nl_}"
|
|
|
|
echo -n "Are you happy with these settings? yes/no (no): "
|
|
|
|
read ANSWER
|
|
|
|
if [ x$ANSWER != "xyes" ] ; then
|
|
|
|
echo "${nl_}Rerun make and fix your settings.${nl_}"
|
|
|
|
exit
|
|
|
|
fi
|
2013-10-29 16:42:03 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
|
|
|
|
|
|
|
|
#*******************************************************************#
|
2021-11-09 13:31:53 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo -n "Loading function <func_check_version.sh> ..."
|
2013-10-29 16:42:03 +01:00
|
|
|
source $COMMON_DIR/libs/func_check_version.sh
|
|
|
|
[[ $? > 0 ]] && echo " function module did not load.." && exit 2
|
2021-11-09 13:31:53 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo " OK"
|
2013-10-29 16:42:03 +01:00
|
|
|
|
|
|
|
[[ $VERBOSITY > 0 ]] && echo "${SD_BORDER}${nl_}"
|
|
|
|
|
|
|
|
case $BLFS_BRANCH_ID in
|
2021-05-01 09:24:56 +02:00
|
|
|
development ) BLFS_TREE=trunk ;;
|
|
|
|
branch-* ) BLFS_TREE=${BLFS_BRANCH_ID#branch-} ;;
|
|
|
|
* ) BLFS_TREE=${BLFS_BRANCH_ID} ;;
|
2013-10-29 16:42:03 +01:00
|
|
|
esac
|
2017-08-09 15:55:55 +02:00
|
|
|
case $LFS_BRANCH_ID in
|
2021-05-01 09:24:56 +02:00
|
|
|
development ) LFS_TREE=trunk ;;
|
|
|
|
branch-* ) LFS_TREE=${LFS_BRANCH_ID#branch-} ;;
|
|
|
|
* ) LFS_TREE=${LFS_BRANCH_ID} ;;
|
2017-08-09 15:55:55 +02:00
|
|
|
esac
|
2013-10-29 16:42:03 +01:00
|
|
|
|
|
|
|
# Check for build prerequisites.
|
|
|
|
echo
|
2013-12-23 22:56:10 +01:00
|
|
|
check_alfs_tools
|
2013-10-29 16:42:03 +01:00
|
|
|
echo "${SD_BORDER}${nl_}"
|
|
|
|
|
|
|
|
# Install the files
|
2021-11-09 13:31:53 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo -n "Populating the ${BUILDDIR}${BLFS_ROOT} directory "
|
2013-10-29 16:42:03 +01:00
|
|
|
[[ ! -d ${BUILDDIR}${BLFS_ROOT} ]] && mkdir -pv ${BUILDDIR}${BLFS_ROOT}
|
2017-03-15 10:16:40 +01:00
|
|
|
rm -rf ${BUILDDIR}${BLFS_ROOT}/*
|
2013-10-29 16:42:03 +01:00
|
|
|
cp -r BLFS/* ${BUILDDIR}${BLFS_ROOT}
|
|
|
|
cp -r menu ${BUILDDIR}${BLFS_ROOT}
|
|
|
|
cp $COMMON_DIR/progress_bar.sh ${BUILDDIR}${BLFS_ROOT}
|
|
|
|
cp README.BLFS ${BUILDDIR}${BLFS_ROOT}
|
|
|
|
[[ $VERBOSITY > 0 ]] && echo "... OK"
|
|
|
|
|
|
|
|
# Clean-up
|
2021-11-09 13:31:53 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo -n "Cleaning the ${BUILDDIR}${BLFS_ROOT} directory "
|
2014-09-23 22:18:44 +02:00
|
|
|
# We do not want to keep an old version of the book:
|
2017-03-15 10:16:40 +01:00
|
|
|
rm -rf ${BUILDDIR}${BLFS_ROOT}/$BLFS_XML
|
2017-08-09 15:55:55 +02:00
|
|
|
rm -rf ${BUILDDIR}${BLFS_ROOT}/$LFS_XML
|
2013-10-29 16:42:03 +01:00
|
|
|
|
|
|
|
# Set some harcoded envars to their proper values
|
|
|
|
sed -i s@tracking-dir@$TRACKING_DIR@ \
|
2021-12-19 14:24:04 +01:00
|
|
|
${BUILDDIR}${BLFS_ROOT}/{Makefile,gen-makefile.sh,gen_pkg_book.sh}
|
2013-12-23 22:56:10 +01:00
|
|
|
|
|
|
|
# Ensures the tracking directory exists.
|
|
|
|
# Throws an error if it does not exist and the user does not
|
|
|
|
# have write permission to create it.
|
|
|
|
# If it exists, does nothing.
|
|
|
|
mkdir -p $TRACKING_DIR
|
2013-10-29 16:42:03 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo "... OK"
|
|
|
|
|
2017-03-15 10:16:40 +01:00
|
|
|
[[ -z "$BLFS_BOOK" ]] ||
|
2017-08-09 15:55:55 +02:00
|
|
|
[[ $BLFS_BOOK = $BUILDDIR$BLFS_ROOT/$BLFS_XML ]] || {
|
2021-11-09 13:31:53 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo -n "Retrieving BLFS working copy (may take some time) "
|
2017-03-15 10:16:40 +01:00
|
|
|
cp -a $BLFS_BOOK $BUILDDIR$BLFS_ROOT/$BLFS_XML
|
2021-11-09 13:31:53 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo "... OK"
|
2017-08-09 15:55:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
[[ -z "$LFS_BOOK" ]] ||
|
|
|
|
[[ $LFS_BOOK = $BUILDDIR$BLFS_ROOT/$LFS_XML ]] || {
|
2021-11-09 13:31:53 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo -n "Retrieving the LFS working copy (may take some time) "
|
2017-08-09 15:55:55 +02:00
|
|
|
cp -a $LFS_BOOK $BUILDDIR$BLFS_ROOT/$LFS_XML
|
2021-11-09 13:31:53 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo "... OK"
|
2017-08-09 15:55:55 +02:00
|
|
|
}
|
2017-03-15 10:16:40 +01:00
|
|
|
|
2021-11-09 13:31:53 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo "Initializing the BLFS tool directory "
|
2014-09-23 22:18:44 +02:00
|
|
|
make -j1 -C $BUILDDIR$BLFS_ROOT \
|
|
|
|
TRACKING_DIR=$TRACKING_DIR \
|
2017-03-15 22:06:17 +01:00
|
|
|
REV=$INITSYS \
|
2017-08-09 15:55:55 +02:00
|
|
|
LFS_XML=$BUILDDIR$BLFS_ROOT/$LFS_XML \
|
2021-05-01 09:24:56 +02:00
|
|
|
LFS-GIT=git://git.linuxfromscratch.org/lfs.git \
|
|
|
|
LFS-BRANCH=${LFS_TREE} \
|
2017-03-15 10:16:40 +01:00
|
|
|
BLFS_XML=$BUILDDIR$BLFS_ROOT/$BLFS_XML \
|
2021-05-01 09:24:56 +02:00
|
|
|
GIT=git://git.linuxfromscratch.org/blfs.git \
|
|
|
|
BLFS-BRANCH=${BLFS_TREE} \
|
2014-09-23 22:18:44 +02:00
|
|
|
$BUILDDIR$BLFS_ROOT/packages.xml
|
2013-10-29 16:42:03 +01:00
|
|
|
[[ $VERBOSITY > 0 ]] && echo "... OK"
|
|
|
|
|