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
|
|
|
|
2023-05-24 10:46:14 +02:00
|
|
|
Copyright (C) 2005-2023, 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
|
|
|
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}
|
2023-11-15 18:04:05 +01:00
|
|
|
ALL_CORES=${ALL_CORES:=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
|
|
|
|
|
2006-08-29 20:16:27 +02:00
|
|
|
# Set the document location...
|
2022-03-30 14:26:41 +02:00
|
|
|
BOOK=${BOOK:=$JHALFSDIR/book-source}
|
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-08-19 12:38:59 +02:00
|
|
|
declare -r REPO=https://git.linuxfromscratch.org/lfs.git
|
2006-10-05 22:25:52 +02:00
|
|
|
declare -r LOG=000-masterscript.log
|
2022-03-30 14:49:43 +02:00
|
|
|
declare -r COMMANDS=lfs-commands
|
2006-10-05 22:25:52 +02:00
|
|
|
|
2006-08-29 20:16:27 +02:00
|
|
|
# Set true internal variables
|
|
|
|
COMMON_DIR="common"
|
2022-03-30 17:45:35 +02:00
|
|
|
PACKAGE_DIR=LFS
|
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_}"
|
2013-11-16 23:35:25 +01:00
|
|
|
BLFS_BRANCH=${BLFS_BRANCH:-n}
|
2022-04-01 10:26:17 +02:00
|
|
|
BLFS_WORKING_COPY=${BLFS_WORKING_COPY:-n}
|
|
|
|
if [[ "${BLFS_WORKING_COPY}" = "y" ]] &&
|
|
|
|
[[ ! -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
|
|
|
|
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
|
2022-05-07 20:40:27 +02:00
|
|
|
# the optimize_functions file is needed for wrt_makeflags even
|
|
|
|
# if optimize=0, because we need to pass NINJAJOBS=1
|
|
|
|
load_file optimize/optimize_functions 'Loading optimization module'
|
2006-08-29 20:16:27 +02:00
|
|
|
if [[ "$OPTIMIZE" != "0" ]]; then
|
|
|
|
#
|
|
|
|
# optimize configurations
|
2019-04-13 18:31:24 +02:00
|
|
|
load_file optimize/opt_config 'Loading optimization config'
|
2006-08-29 20:16:27 +02:00
|
|
|
# Validate optimize settings, if required
|
|
|
|
validate_opt_settings
|
|
|
|
fi
|
2023-11-15 18:04:05 +01:00
|
|
|
# Parallelization is outside optimization, because it is now in the book
|
|
|
|
if [[ "$ALL_CORES" = "n" ]]; then
|
|
|
|
# shellcheck disable=SC2034
|
|
|
|
JH_MAKEFLAGS="-j${N_PARALLEL}"
|
|
|
|
fi
|
2006-08-29 20:16:27 +02:00
|
|
|
#
|
|
|
|
|
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
|
2023-11-15 18:19:14 +01:00
|
|
|
cp "$COMMON_DIR"/{makefile-functions,progress_bar.sh,run-in-cgroup.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/"
|
2022-03-13 13:16:59 +01:00
|
|
|
cp "$PACKAGE_DIR/$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
|
2022-03-30 17:45:35 +02:00
|
|
|
[[ "$PKGMNGT" = "y" ]] && {
|
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
|