2006-08-29 20:16:27 +02:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
2013-10-30 16:44:46 +01:00
|
|
|
# Pass trap handlers to functions
|
|
|
|
set -E
|
2006-08-29 20:16:27 +02:00
|
|
|
|
|
|
|
# VT100 colors
|
|
|
|
declare -r RED=$'\e[31m'
|
|
|
|
declare -r GREEN=$'\e[32m'
|
|
|
|
declare -r YELLOW=$'\e[33m'
|
|
|
|
|
2019-04-13 18:31:24 +02:00
|
|
|
# shellcheck disable=SC2034
|
|
|
|
declare -r BLUE=$'\e[34m'
|
2006-08-29 20:16:27 +02:00
|
|
|
declare -r OFF=$'\e[0m'
|
|
|
|
declare -r BOLD=$'\e[1m'
|
|
|
|
declare -r tab_=$'\t'
|
|
|
|
declare -r nl_=$'\n'
|
|
|
|
|
2019-04-13 18:31:24 +02:00
|
|
|
# shellcheck disable=SC2034
|
2006-08-29 20:16:27 +02:00
|
|
|
declare -r DD_BORDER="${BOLD}==============================================================================${OFF}"
|
2019-04-13 18:31:24 +02:00
|
|
|
# shellcheck disable=SC2034
|
2006-08-29 20:16:27 +02:00
|
|
|
declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
|
2019-04-13 18:31:24 +02:00
|
|
|
# shellcheck disable=SC2034
|
2006-08-29 20:16:27 +02:00
|
|
|
declare -r STAR_BORDER="${BOLD}******************************************************************************${OFF}"
|
|
|
|
|
|
|
|
# bold yellow > < pair
|
|
|
|
declare -r R_arrow=$'\e[1;33m>\e[0m'
|
|
|
|
declare -r L_arrow=$'\e[1;33m<\e[0m'
|
|
|
|
|
|
|
|
|
|
|
|
#>>>>>>>>>>>>>>>ERROR TRAPPING >>>>>>>>>>>>>>>>>>>>
|
|
|
|
#-----------------------#
|
|
|
|
simple_error() { # Basic error trap.... JUST DIE
|
|
|
|
#-----------------------#
|
2019-04-13 18:31:24 +02:00
|
|
|
LASTLINE="$1"
|
|
|
|
LASTERR="$2"
|
|
|
|
LASTSOURCE="$4"
|
|
|
|
error_message "${GREEN} Error $LASTERR at $LASTSOURCE line ${LASTLINE}!"
|
2006-08-29 20:16:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
see_ya() {
|
2019-04-13 18:31:24 +02:00
|
|
|
printf '\n%b%bjhalfs%b exit%b\n' "$L_arrow" "$BOLD" "$R_arrow" "$OFF"
|
2006-08-29 20:16:27 +02:00
|
|
|
}
|
|
|
|
##### Simple error TRAPS
|
|
|
|
# ctrl-c SIGINT
|
|
|
|
# ctrl-y
|
|
|
|
# ctrl-z SIGTSTP
|
|
|
|
# SIGHUP 1 HANGUP
|
|
|
|
# SIGINT 2 INTRERRUPT FROM KEYBOARD Ctrl-C
|
|
|
|
# SIGQUIT 3
|
|
|
|
# SIGKILL 9 KILL
|
|
|
|
# SIGTERM 15 TERMINATION
|
|
|
|
# SIGSTOP 17,18,23 STOP THE PROCESS
|
|
|
|
#####
|
|
|
|
set -e
|
|
|
|
trap see_ya 0
|
2013-10-30 16:44:46 +01:00
|
|
|
trap 'simple_error "${LINENO}" "$?" "${FUNCNAME}" "${BASH_SOURCE}"' ERR
|
2019-01-13 09:32:24 +01:00
|
|
|
trap 'echo -e "\n\n${RED}INTERRUPT${OFF} trapped\n" && exit 2' \
|
|
|
|
HUP INT QUIT TERM # STOP stops tterminal output and does not seem to
|
|
|
|
# execute the handler
|
2006-08-29 20:16:27 +02:00
|
|
|
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
|
2019-04-13 18:31:24 +02:00
|
|
|
simple_message() {
|
|
|
|
# Prevents having to check $VERBOSITY everywhere
|
|
|
|
if [ "$VERBOSITY" -ne 0 ] ; then
|
|
|
|
# shellcheck disable=SC2059
|
|
|
|
printf "$*"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
warning_message() {
|
|
|
|
simple_message "${YELLOW}\\nWARNING:${OFF} $*\\n\\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
error_message() {
|
|
|
|
# Prints an error message and exits with LASTERR or 1
|
|
|
|
if [ -n "$LASTERR" ] ; then
|
|
|
|
LASTERR=$(printf '%d' "$LASTERR")
|
|
|
|
else
|
|
|
|
LASTERR=1
|
|
|
|
fi
|
|
|
|
# If +e then disable text output
|
|
|
|
if [[ "$-" =~ e ]]; then
|
|
|
|
printf '\n\n%bERROR:%b %s\n' "$RED" "$OFF" "$*" >&2
|
|
|
|
fi
|
|
|
|
exit "$LASTERR"
|
|
|
|
}
|
|
|
|
|
|
|
|
load_file() {
|
|
|
|
# source files in a consistent way with an optional message
|
|
|
|
file="$1"
|
|
|
|
shift
|
|
|
|
msg="Loading file ${file}..."
|
|
|
|
[ -z "$*" ] || msg="$*..."
|
|
|
|
simple_message "$msg"
|
|
|
|
|
|
|
|
# shellcheck disable=SC1090
|
|
|
|
source "$file" 2>/dev/null || error_message "$file did not load"
|
|
|
|
simple_message "OK\\n"
|
|
|
|
}
|
|
|
|
|
2021-01-17 11:10:59 +01:00
|
|
|
git_commit=$(git log -1 --format=format:"%h %ad")
|
2006-08-29 20:16:27 +02:00
|
|
|
version="
|
2021-01-17 11:10:59 +01:00
|
|
|
${BOLD} \"jhalfs\"${OFF} builder tool (development) $git_commit
|
2006-08-29 20:16:27 +02:00
|
|
|
|
2021-01-17 11:10:59 +01:00
|
|
|
Copyright (C) 2005-2021, the jhalfs team:
|
2019-04-24 18:16:20 +02:00
|
|
|
Jeremy Huntwork
|
|
|
|
George Boudreau
|
|
|
|
Manuel Canales Esparcia
|
|
|
|
Thomas Pegg
|
|
|
|
Matthew Burgess
|
|
|
|
Pierre Labastie
|
2006-08-29 20:16:27 +02:00
|
|
|
|
2019-04-24 18:16:20 +02:00
|
|
|
Unless specified, all the files in this directory and its sub-directories
|
|
|
|
are subjected to the ${BOLD}MIT license${OFF}. See the ${BOLD}LICENSE${OFF} file.
|
2006-08-29 20:16:27 +02:00
|
|
|
|
2019-04-24 18:16:20 +02:00
|
|
|
The files in the ${BOLD}menu${OFF} directory are subjected to the ${BOLD}ISC License${OFF}.
|
|
|
|
See ${BOLD}LICENSE.txt${OFF} and ${BOLD}README${OFF} in that directory.
|
2006-08-29 20:16:27 +02:00
|
|
|
"
|
|
|
|
|
2019-04-24 18:16:20 +02:00
|
|
|
usage="${nl_}${tab_}${BOLD}${RED}This script cannot be called directly${OFF}
|
|
|
|
${tab_}Type ${BOLD}make${OFF} to run the tool, or
|
|
|
|
${tab_}Type ${BOLD}./jhalfs -v${OFF} to display version information."
|
|
|
|
|
2006-08-29 20:16:27 +02:00
|
|
|
case $1 in
|
2017-04-02 11:00:42 +02:00
|
|
|
-v ) echo "$version" && exit ;;
|
2006-08-29 20:16:27 +02:00
|
|
|
run ) : ;;
|
2019-04-24 18:16:20 +02:00
|
|
|
* ) echo "$usage" && exit 1 ;;
|
2006-08-29 20:16:27 +02:00
|
|
|
esac
|
|
|
|
|
2013-04-04 22:07:25 +02:00
|
|
|
# If the user has not saved his configuration file, let's ask
|
|
|
|
# if he or she really wants to run this stuff
|
2019-04-17 09:06:13 +02:00
|
|
|
time_current=$(stat -c '%Y' configuration 2>/dev/null || date +%s)
|
2019-06-15 19:25:10 +02:00
|
|
|
time_old=$(stat -c '%Y' configuration.old 2>/dev/null || printf '%s' "$time_current")
|
2019-04-17 09:06:13 +02:00
|
|
|
if [ "$(printf '%d' "$time_old")" -ge "$(printf '%d' "$time_current")" ] ; then
|
|
|
|
printf 'Do you want to run jhalfs? yes/no (yes): '
|
2019-04-13 18:31:24 +02:00
|
|
|
read -r ANSWER
|
2019-04-17 09:06:13 +02:00
|
|
|
case ${ANSWER:0:1} in
|
|
|
|
n|N) printf "\nExiting gracefully.\n"; exit ;;
|
|
|
|
esac
|
2013-04-04 22:07:25 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Change this to 0 to suppress almost all messages
|
2006-08-29 20:16:27 +02:00
|
|
|
VERBOSITY=1
|
|
|
|
|
2019-04-13 18:31:24 +02:00
|
|
|
load_file configuration "Loading config params from <configuration>"
|
2006-08-29 20:16:27 +02:00
|
|
|
|
|
|
|
# These are boolean vars generated from Config.in.
|
2012-02-02 00:29:37 +01:00
|
|
|
# ISSUE: If a boolean parameter is not set to y(es) there
|
|
|
|
# is no variable defined by the menu app. This can
|
|
|
|
# cause a headache if you are not aware.
|
|
|
|
# The following variables MUST exist. If they don't, the
|
|
|
|
# default value is n(o).
|
2006-08-29 20:16:27 +02:00
|
|
|
RUNMAKE=${RUNMAKE:-n}
|
|
|
|
GETPKG=${GETPKG:-n}
|
|
|
|
COMPARE=${COMPARE:-n}
|
|
|
|
RUN_ICA=${RUN_ICA:-n}
|
2012-02-02 00:29:37 +01:00
|
|
|
PKGMNGT=${PKGMNGT:-n}
|
2017-04-09 12:29:32 +02:00
|
|
|
WRAP_INSTALL=${WRAP_INSTALL:-n}
|
2006-08-29 20:16:27 +02:00
|
|
|
BOMB_TEST=${BOMB_TEST:-n}
|
|
|
|
STRIP=${STRIP:=n}
|
|
|
|
REPORT=${REPORT:=n}
|
2019-09-05 19:22:04 +02:00
|
|
|
NCURSES5=${NCURSES5:-n}
|
2018-01-12 20:04:19 +01:00
|
|
|
DEL_LA_FILES=${DEL_LA_FILES:-n}
|
2012-02-10 10:43:23 +01:00
|
|
|
FULL_LOCALE=${FULL_LOCALE:-n}
|
2006-08-29 20:16:27 +02:00
|
|
|
GRSECURITY_HOST=${GRSECURITY_HOST:-n}
|
2006-10-14 19:22:29 +02:00
|
|
|
CUSTOM_TOOLS=${CUSTOM_TOOLS:-n}
|
2006-10-19 19:27:18 +02:00
|
|
|
REBUILD_MAKEFILE=${REBUILD_MAKEFILE:-n}
|
2007-04-28 17:24:20 +02:00
|
|
|
INSTALL_LOG=${INSTALL_LOG:-n}
|
2007-05-30 21:47:27 +02:00
|
|
|
CLEAN=${CLEAN:=n}
|
2007-06-04 21:36:27 +02:00
|
|
|
SET_SSP=${SET_SSP:=n}
|
|
|
|
SET_ASLR=${SET_ASLR:=n}
|
|
|
|
SET_PAX=${SET_PAX:=n}
|
|
|
|
SET_HARDENED_TMP=${SET_HARDENED_TMP:=n}
|
|
|
|
SET_WARNINGS=${SET_WARNINGS:=n}
|
|
|
|
SET_MISC=${SET_MISC:=n}
|
|
|
|
SET_BLOWFISH=${SET_BLOWFISH:=n}
|
2017-04-09 12:29:32 +02:00
|
|
|
UNICODE=${UNICODE:=n}
|
2019-03-09 09:11:37 +01:00
|
|
|
LOCAL=${LOCAL:=n}
|
2018-01-14 11:26:43 +01:00
|
|
|
REALSBU=${REALSBU:=n}
|
2020-05-01 16:24:32 +02:00
|
|
|
SAVE_CH5=${SAVE_CH5:=n}
|
2006-08-29 20:16:27 +02:00
|
|
|
|
2008-10-28 00:26:29 +01:00
|
|
|
if [[ "${NO_PROGRESS_BAR}" = "y" ]] ; then
|
2019-04-13 18:31:24 +02:00
|
|
|
# shellcheck disable=SC2034
|
|
|
|
NO_PROGRESS="#"
|
2008-10-28 00:26:29 +01:00
|
|
|
fi
|
|
|
|
|
2007-09-14 18:56:24 +02:00
|
|
|
# Sanity check on the location of $BUILDDIR / $JHALFSDIR
|
2019-04-13 18:31:24 +02:00
|
|
|
CWD="$(cd "$(dirname "$0")" && pwd)"
|
|
|
|
if [[ $JHALFSDIR == "$CWD" ]]; then
|
|
|
|
echo " The jhalfs source directory conflicts with the jhalfs build directory."
|
|
|
|
echo " Please move the source directory or change the build directory."
|
|
|
|
exit 2
|
2007-09-14 18:56:24 +02:00
|
|
|
fi
|
|
|
|
|
2009-10-23 17:53:53 +02:00
|
|
|
# Book sources envars
|
2006-08-29 20:18:06 +02:00
|
|
|
BRANCH_ID=${BRANCH_ID:=development}
|
|
|
|
|
|
|
|
case $BRANCH_ID in
|
|
|
|
development )
|
2022-03-01 21:09:30 +01:00
|
|
|
TREE=trunk
|
2006-08-29 20:18:06 +02:00
|
|
|
LFSVRS=development
|
|
|
|
;;
|
|
|
|
*EDIT* ) echo " You forgot to set the branch or stable book version."
|
|
|
|
echo " Please rerun make and fix the configuration."
|
|
|
|
exit 2 ;;
|
|
|
|
branch-* )
|
2022-03-01 21:09:30 +01:00
|
|
|
LFSVRS=${BRANCH_ID}
|
|
|
|
TREE=${BRANCH_ID#branch-}
|
2006-08-29 20:18:06 +02:00
|
|
|
;;
|
|
|
|
* )
|
2022-03-01 21:09:30 +01:00
|
|
|
LFSVRS=${BRANCH_ID}
|
|
|
|
TREE=${BRANCH_ID}
|
2006-08-29 20:18:06 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2006-08-29 20:16:27 +02:00
|
|
|
# Set the document location...
|
2013-04-04 23:13:02 +02:00
|
|
|
BOOK=${BOOK:=$JHALFSDIR/$PROGNAME-$LFSVRS}
|
2006-08-29 20:16:27 +02:00
|
|
|
|
2006-08-29 20:18:06 +02:00
|
|
|
|
2006-10-05 22:25:52 +02:00
|
|
|
#--- Envars not sourced from configuration
|
2019-04-13 18:31:24 +02:00
|
|
|
# shellcheck disable=SC2034
|
2022-03-01 21:09:30 +01:00
|
|
|
declare -r GIT="git://git.linuxfromscratch.org"
|
2006-10-05 22:25:52 +02:00
|
|
|
declare -r LOG=000-masterscript.log
|
|
|
|
|
2006-08-29 20:16:27 +02:00
|
|
|
# Set true internal variables
|
|
|
|
COMMON_DIR="common"
|
2019-04-13 18:31:24 +02:00
|
|
|
PACKAGE_DIR=$(echo "$PROGNAME" | tr '[:lower:]' '[:upper:]')
|
2006-08-29 20:16:27 +02:00
|
|
|
MODULE=$PACKAGE_DIR/master.sh
|
2012-02-02 00:29:37 +01:00
|
|
|
PKGMNGTDIR="pkgmngt"
|
|
|
|
# The name packageManager.xml is hardcoded in *.xsl, so no variable.
|
2006-08-29 20:16:27 +02:00
|
|
|
|
2019-04-13 18:31:24 +02:00
|
|
|
for file in \
|
|
|
|
"$COMMON_DIR/common-functions" \
|
|
|
|
"$COMMON_DIR/libs/func_book_parser" \
|
|
|
|
"$COMMON_DIR/libs/func_download_pkgs" \
|
|
|
|
"$COMMON_DIR/libs/func_wrt_Makefile" \
|
|
|
|
"$MODULE" ; do
|
|
|
|
load_file "$file"
|
|
|
|
done
|
2006-10-14 19:22:29 +02:00
|
|
|
|
2019-04-13 18:31:24 +02:00
|
|
|
simple_message "${SD_BORDER}${nl_}"
|
2006-10-14 19:22:29 +02:00
|
|
|
|
|
|
|
|
2019-04-13 18:31:24 +02:00
|
|
|
#*******************************************************************#
|
|
|
|
LASTERR=2
|
|
|
|
for file in \
|
|
|
|
"$COMMON_DIR/libs/func_check_version.sh" \
|
|
|
|
"$COMMON_DIR/libs/func_validate_configs.sh" \
|
|
|
|
"$COMMON_DIR/libs/func_custom_pkgs" ; do
|
|
|
|
load_file "$file"
|
|
|
|
done
|
|
|
|
unset LASTERR
|
|
|
|
|
|
|
|
simple_message "${SD_BORDER}${nl_}"
|
2019-04-24 17:03:58 +02:00
|
|
|
simple_message "Checking tools required for jhalfs${nl_}"
|
2013-12-15 11:10:25 +01:00
|
|
|
check_alfs_tools
|
2019-04-13 18:31:24 +02:00
|
|
|
simple_message "${SD_BORDER}${nl_}"
|
2006-08-29 20:16:27 +02:00
|
|
|
|
2013-10-29 16:42:03 +01:00
|
|
|
# blfs-tool envars
|
|
|
|
BLFS_TOOL=${BLFS_TOOL:-n}
|
|
|
|
if [[ "${BLFS_TOOL}" = "y" ]] ; then
|
2021-12-13 16:10:37 +01:00
|
|
|
#not needed now that the check is in alfs_tools
|
|
|
|
# simple_message 'Checking supplementary tools for installing BLFS'
|
|
|
|
# check_blfs_tools
|
2019-04-13 18:31:24 +02:00
|
|
|
simple_message "${SD_BORDER}${nl_}"
|
2021-05-01 09:21:06 +02:00
|
|
|
BLFS_GIT=${BLFS_GIT:-n}
|
2013-11-16 23:35:25 +01:00
|
|
|
BLFS_WORKING_COPY=${BLFS_WORKING_COPY:-n}
|
|
|
|
BLFS_BRANCH=${BLFS_BRANCH:-n}
|
2021-05-01 09:21:06 +02:00
|
|
|
if [[ "${BLFS_GIT}" = "y" ]]; then
|
2013-11-16 23:35:25 +01:00
|
|
|
BLFS_BRANCH_ID=development
|
2021-05-01 09:21:06 +02:00
|
|
|
BLFS_TREE=trunk
|
2013-11-16 23:35:25 +01:00
|
|
|
elif [[ "${BLFS_WORKING_COPY}" = "y" ]]; then
|
2019-04-13 18:31:24 +02:00
|
|
|
if [[ ! -d "$BLFS_WC_LOCATION/postlfs" ]] ; then
|
2013-11-16 23:35:25 +01:00
|
|
|
echo " BLFS tools: This is not a working copy: $BLFS_WC_LOCATION."
|
|
|
|
echo " Please rerun make and fix the configuration."
|
|
|
|
exit 2
|
2019-04-13 18:31:24 +02:00
|
|
|
fi
|
2021-05-01 09:21:06 +02:00
|
|
|
BLFS_TREE=$(cd $BLFS_WC_LOCATION; git branch --show-current)
|
|
|
|
BLFS_BRANCH_ID=${BLFS_TREE/trunk/development}
|
2013-11-17 21:13:04 +01:00
|
|
|
elif [[ "${BLFS_BRANCH}" = "y" ]] ; then
|
2013-11-16 23:35:25 +01:00
|
|
|
case $BLFS_BRANCH_ID in
|
|
|
|
*EDIT* ) echo " You forgot to set the BLFS branch or stable book version."
|
|
|
|
echo " Please rerun make and fix the configuration."
|
|
|
|
exit 2 ;;
|
2021-05-01 09:21:06 +02:00
|
|
|
* ) BLFS_TREE=${BLFS_BRANCH_ID#branch-}
|
2013-11-16 23:35:25 +01:00
|
|
|
esac
|
|
|
|
fi
|
2019-04-13 18:31:24 +02:00
|
|
|
load_file "${COMMON_DIR}/libs/func_install_blfs"
|
2013-10-29 16:42:03 +01:00
|
|
|
fi
|
2006-08-29 20:16:27 +02:00
|
|
|
|
|
|
|
###################################
|
|
|
|
### MAIN ###
|
|
|
|
###################################
|
|
|
|
|
|
|
|
|
|
|
|
validate_config
|
|
|
|
echo "${SD_BORDER}${nl_}"
|
|
|
|
echo -n "Are you happy with these settings? yes/no (no): "
|
2019-04-13 18:31:24 +02:00
|
|
|
read -r ANSWER
|
|
|
|
if [ "x$ANSWER" != "xyes" ] ; then
|
2006-10-07 20:50:15 +02:00
|
|
|
echo "${nl_}Rerun make to fix the configuration options.${nl_}"
|
2013-11-16 11:00:16 +01:00
|
|
|
exit
|
2006-08-29 20:16:27 +02:00
|
|
|
fi
|
|
|
|
echo "${nl_}${SD_BORDER}${nl_}"
|
|
|
|
|
|
|
|
# Load additional modules or configuration files based on global settings
|
|
|
|
# compare module
|
|
|
|
if [[ "$COMPARE" = "y" ]]; then
|
2019-04-13 18:31:24 +02:00
|
|
|
load_file "${COMMON_DIR}/libs/func_compare.sh" 'Loading compare module'
|
2006-08-29 20:16:27 +02:00
|
|
|
fi
|
|
|
|
#
|
2020-05-01 16:24:32 +02:00
|
|
|
# save module
|
|
|
|
if [[ "$SAVE_CH5" = "y" ]]; then
|
|
|
|
load_file "${COMMON_DIR}/libs/func_save.sh" 'Loading save module'
|
|
|
|
fi
|
|
|
|
#
|
2006-08-29 20:16:27 +02:00
|
|
|
# optimize module
|
|
|
|
if [[ "$OPTIMIZE" != "0" ]]; then
|
2019-04-13 18:31:24 +02:00
|
|
|
load_file optimize/optimize_functions 'Loading optimization module'
|
2006-08-29 20:16:27 +02:00
|
|
|
#
|
|
|
|
# optimize configurations
|
2019-04-13 18:31:24 +02:00
|
|
|
load_file optimize/opt_config 'Loading optimization config'
|
2013-11-16 23:35:25 +01:00
|
|
|
# The number of parallel jobs is taken from configuration now
|
2019-04-13 18:31:24 +02:00
|
|
|
# shellcheck disable=SC2034
|
2020-06-05 12:18:27 +02:00
|
|
|
JH_MAKEFLAGS="-j${N_PARALLEL}"
|
2006-08-29 20:16:27 +02:00
|
|
|
# Validate optimize settings, if required
|
|
|
|
validate_opt_settings
|
|
|
|
fi
|
|
|
|
#
|
|
|
|
|
2006-10-19 19:27:18 +02:00
|
|
|
if [[ "$REBUILD_MAKEFILE" = "n" ]] ; then
|
2006-08-29 20:16:27 +02:00
|
|
|
|
2017-08-09 15:51:40 +02:00
|
|
|
# If requested, clean the build directory
|
2006-10-18 21:28:47 +02:00
|
|
|
clean_builddir
|
2006-08-29 20:16:27 +02:00
|
|
|
|
2006-10-18 21:28:47 +02:00
|
|
|
if [[ ! -d $JHALFSDIR ]]; then
|
2019-04-13 18:31:24 +02:00
|
|
|
sudo mkdir -p "$JHALFSDIR"
|
2021-06-30 16:03:51 +02:00
|
|
|
# Do not assume there is a group named as $USER, do not use
|
|
|
|
# $USER:$USER...
|
|
|
|
sudo chown "$USER" "$JHALFSDIR"
|
2006-10-18 21:28:47 +02:00
|
|
|
fi
|
2006-12-15 11:53:10 +01:00
|
|
|
|
2017-08-09 15:51:40 +02:00
|
|
|
# Create $BUILDDIR/sources even though it could be created by get_sources()
|
2006-10-18 21:28:47 +02:00
|
|
|
if [[ ! -d $BUILDDIR/sources ]]; then
|
2019-04-13 18:31:24 +02:00
|
|
|
sudo mkdir -p "$BUILDDIR/sources"
|
|
|
|
sudo chmod a+wt "$BUILDDIR/sources"
|
2006-10-18 21:28:47 +02:00
|
|
|
fi
|
2017-08-09 15:51:40 +02:00
|
|
|
|
|
|
|
# Create the log directory
|
2006-10-18 21:28:47 +02:00
|
|
|
if [[ ! -d $LOGDIR ]]; then
|
2019-04-13 18:31:24 +02:00
|
|
|
mkdir "$LOGDIR"
|
2006-10-18 21:28:47 +02:00
|
|
|
fi
|
2019-04-13 18:31:24 +02:00
|
|
|
true >"$LOGDIR/$LOG"
|
2017-08-09 15:51:40 +02:00
|
|
|
|
|
|
|
# Copy common helper files
|
2019-04-13 18:31:24 +02:00
|
|
|
cp "$COMMON_DIR"/{makefile-functions,progress_bar.sh} "$JHALFSDIR/"
|
2017-08-09 15:51:40 +02:00
|
|
|
|
|
|
|
# Copy needed stylesheets
|
2019-04-13 18:31:24 +02:00
|
|
|
cp "$COMMON_DIR"/{packages.xsl,chroot.xsl,kernfs.xsl} "$JHALFSDIR/"
|
2017-08-09 15:51:40 +02:00
|
|
|
|
2006-12-15 11:53:10 +01:00
|
|
|
export XSL=$JHALFSDIR/${XSL}
|
2006-10-18 21:28:47 +02:00
|
|
|
|
2017-08-09 15:51:40 +02:00
|
|
|
# Copy packageManager.xml, if needed
|
2017-03-19 15:54:28 +01:00
|
|
|
[[ "$PKGMNGT" = "y" ]] && [[ "$PROGNAME" = "lfs" ]] && {
|
2020-07-06 07:23:47 +02:00
|
|
|
sed s@BOOK@"$BOOK"@ "$PKGMNGTDIR/packageManager.xml" > \
|
|
|
|
"$JHALFSDIR/"packageManager.xml
|
2019-04-13 18:31:24 +02:00
|
|
|
cp "$PKGMNGTDIR/packInstall.sh" "$JHALFSDIR/"
|
2017-03-19 15:54:28 +01:00
|
|
|
}
|
2017-08-09 15:51:40 +02:00
|
|
|
|
|
|
|
# Copy urls.xsl, if needed
|
2019-04-13 18:31:24 +02:00
|
|
|
[[ "$GETPKG" = "y" ]] && cp "$COMMON_DIR/urls.xsl" "$JHALFSDIR/"
|
2017-08-09 15:51:40 +02:00
|
|
|
|
2018-01-12 11:42:36 +01:00
|
|
|
# Always create the test-log directory to allow user to "uncomment" test
|
|
|
|
# instructions
|
2019-04-13 18:31:24 +02:00
|
|
|
install -d -m 1777 "$TESTLOGDIR"
|
2017-08-09 15:51:40 +02:00
|
|
|
|
|
|
|
# Create the installed-files directory, if needed
|
2019-04-13 18:31:24 +02:00
|
|
|
[[ "$INSTALL_LOG" = "y" ]] && [[ ! -d $FILELOGDIR ]] && install -d -m 1777 "$FILELOGDIR"
|
2017-08-09 15:51:40 +02:00
|
|
|
|
|
|
|
# Prepare report creation, if needed
|
2006-10-18 21:28:47 +02:00
|
|
|
if [[ "$REPORT" = "y" ]]; then
|
2019-04-13 18:31:24 +02:00
|
|
|
cp $COMMON_DIR/create-sbu_du-report.sh "$JHALFSDIR/"
|
2012-02-02 00:29:37 +01:00
|
|
|
# After making sure that all looks sane, dump the settings to a file
|
2006-10-18 21:28:47 +02:00
|
|
|
# This file will be used to create the REPORT header
|
2019-04-13 18:31:24 +02:00
|
|
|
validate_config >"$JHALFSDIR/jhalfs.config"
|
2006-10-18 21:28:47 +02:00
|
|
|
fi
|
2017-08-09 15:51:40 +02:00
|
|
|
|
|
|
|
# Copy optimize files, if needed
|
2019-04-13 18:31:24 +02:00
|
|
|
[[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override "$JHALFSDIR/"
|
2017-08-09 15:51:40 +02:00
|
|
|
|
|
|
|
# Copy compare files, if needed
|
2006-12-15 11:53:10 +01:00
|
|
|
if [[ "$COMPARE" = "y" ]]; then
|
2019-04-13 18:31:24 +02:00
|
|
|
mkdir -p "$JHALFSDIR/extras"
|
|
|
|
cp extras/* "$JHALFSDIR/extras"
|
2006-12-15 11:53:10 +01:00
|
|
|
fi
|
2017-08-09 15:51:40 +02:00
|
|
|
|
|
|
|
# Copy custom tools config files, if requested
|
2006-12-15 11:53:10 +01:00
|
|
|
if [[ "${CUSTOM_TOOLS}" = "y" ]]; then
|
|
|
|
echo "Copying custom tool scripts to $JHALFSDIR"
|
2019-04-13 18:31:24 +02:00
|
|
|
mkdir -p "$JHALFSDIR/custom-commands"
|
|
|
|
cp -f custom/config/* "$JHALFSDIR/custom-commands"
|
2006-12-15 11:53:10 +01:00
|
|
|
fi
|
2017-08-09 15:51:40 +02:00
|
|
|
|
2017-08-10 10:10:43 +02:00
|
|
|
# Download or updates the book source
|
|
|
|
# Note that all customization to $JHALFSDIR have to be done before this.
|
|
|
|
# But the LFS book is needed for BLFS tools.
|
|
|
|
get_book
|
|
|
|
extract_commands
|
|
|
|
echo "${SD_BORDER}${nl_}"
|
2019-04-13 18:31:24 +02:00
|
|
|
cd "$CWD" # the functions above change directory
|
2017-08-10 10:10:43 +02:00
|
|
|
|
2017-08-09 15:51:40 +02:00
|
|
|
# Install blfs-tool, if requested.
|
2006-10-18 21:28:47 +02:00
|
|
|
if [[ "${BLFS_TOOL}" = "y" ]] ; then
|
2013-12-15 11:10:25 +01:00
|
|
|
echo Installing BLFS book and tools
|
2019-04-13 18:31:24 +02:00
|
|
|
install_blfs_tools 2>&1 | tee -a "$LOGDIR/$LOG"
|
2013-10-30 16:44:46 +01:00
|
|
|
[[ ${PIPESTATUS[0]} != 0 ]] && exit 1
|
2006-10-18 21:28:47 +02:00
|
|
|
fi
|
|
|
|
|
2006-08-29 20:18:06 +02:00
|
|
|
fi
|
|
|
|
|
2019-04-13 18:31:24 +02:00
|
|
|
# shellcheck disable=SC2034
|
2006-10-19 19:27:18 +02:00
|
|
|
if [[ "$REBUILD_MAKEFILE" = "y" ]] ; then
|
2020-07-10 15:26:23 +02:00
|
|
|
# Sanity check: users tend to tick "rebuild Makefile"
|
|
|
|
# without generating one first. Check we have one:
|
|
|
|
if [ ! -f $MKFILE ]; then
|
|
|
|
set -e
|
|
|
|
error_message "You cannot \"rebuild Makefile\" without first building one"
|
|
|
|
fi
|
|
|
|
# When regenerating the Makefile, we need to know also the
|
|
|
|
# canonical book version
|
2022-03-01 21:09:30 +01:00
|
|
|
VERSION=$(grep 'echo.*lfs-release' "$JHALFSDIR/prbook.xml" | sed 's/.*echo[ ]*\([^ ]*\).*/\1/')
|
2006-10-19 19:27:18 +02:00
|
|
|
fi
|
|
|
|
|
2006-08-29 20:16:27 +02:00
|
|
|
build_Makefile
|
2006-12-15 11:53:10 +01:00
|
|
|
|
2006-08-29 20:16:27 +02:00
|
|
|
echo "${SD_BORDER}${nl_}"
|
|
|
|
|
2013-04-04 23:13:02 +02:00
|
|
|
# Check for build prerequisites.
|
|
|
|
echo
|
2019-04-13 18:31:24 +02:00
|
|
|
cd "$CWD"
|
2013-04-04 23:13:02 +02:00
|
|
|
check_prerequisites
|
|
|
|
echo "${SD_BORDER}${nl_}"
|
|
|
|
# All is well, run the build (if requested)
|
2006-08-29 20:16:27 +02:00
|
|
|
run_make
|