2024-07-03 18:00:33 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o xtrace
|
2018-03-07 23:52:40 +00:00
|
|
|
|
2019-04-02 19:38:19 +00:00
|
|
|
REALMFS_BUILDER_BASE="/usr/share/realmfs-builder"
|
2018-03-10 21:10:50 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# If you're looking for the base lists of packages that are always installed
|
|
|
|
# and modules that are always run, they're defined here in common.inc
|
|
|
|
#
|
2019-04-02 19:38:19 +00:00
|
|
|
source ${REALMFS_BUILDER_BASE}/common.inc
|
2018-03-07 23:52:40 +00:00
|
|
|
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
|
|
fatal "The stage-two.sh script is not running as root."
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
fatal "The stage-two.sh script expects a single argument (configuration file path)"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f ${1} ]; then
|
|
|
|
fatal "Configuration file '${1}' does not exist."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# running module 'utility-library' replaces this function with a more powerful version
|
|
|
|
module() {
|
2019-04-02 19:38:19 +00:00
|
|
|
local modpath=${REALMFS_BUILDER_BASE}/realmfs-modules/${1}
|
2018-03-07 23:52:40 +00:00
|
|
|
[[ -f ${modpath} ]] || fatal "Could not find module '${1}'"
|
|
|
|
source ${modpath}
|
|
|
|
}
|
|
|
|
|
|
|
|
pre_install_packages() {
|
|
|
|
info "Running pre package install modules"
|
|
|
|
for mod in ${PRE_INSTALL_MODULES}; do
|
|
|
|
module ${mod}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
post_install_packages() {
|
|
|
|
info "Running post package install modules"
|
|
|
|
for mod in ${POST_INSTALL_MODULES}; do
|
|
|
|
module ${mod}
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
run_build() {
|
|
|
|
pre_install_packages
|
|
|
|
module install-packages
|
|
|
|
post_install_packages
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# config file imported here
|
|
|
|
source ${1}
|
|
|
|
|
|
|
|
#
|
|
|
|
# Define any of PACKAGES, PRE_INSTALL_MODULES, POST_INSTALL_MODULES in config file
|
|
|
|
# to append to the corresponding BASE list. Also you can override the BASE lists
|
|
|
|
# entirely by setting the variable name in config file.
|
|
|
|
#
|
|
|
|
PACKAGES="${BASE_PACKAGES} ${PACKAGES:-}"
|
|
|
|
PRE_INSTALL_MODULES="${BASE_PRE_INSTALL_MODULES} ${PRE_INSTALL_MODULES:-}"
|
|
|
|
POST_INSTALL_MODULES="${BASE_POST_INSTALL_MODULES} ${POST_INSTALL_MODULES:-}"
|
|
|
|
|
|
|
|
run_build
|