Commit e09e8908 authored by gsell's avatar gsell
Browse files

Merge branch '51-option-system-is-broken' into 'master'

Resolve "option --system is broken"

Closes #51

See merge request !21
parents eb488b22 58359b83
......@@ -76,59 +76,48 @@ declare bootstrap='no'
#..............................................................................
# global variables
declare force_rebuild='no'
pbuild.force_rebuild() {
force_rebuild="$1"
declare -gr force_rebuild="$1"
}
declare dry_run='no'
pbuild.dry_run() {
dry_run="$1"
declare -gr dry_run="$1"
}
declare enable_cleanup_build='yes'
pbuild.enable_cleanup_build() {
enable_cleanup_build="$1"
declare -gr enable_cleanup_build="$1"
}
declare enable_cleanup_src='yes'
pbuild.enable_cleanup_src() {
enable_cleanup_src="$1"
declare -gr enable_cleanup_src="$1"
}
declare build_target='all'
pbuild.build_target() {
build_target="$1"
declare -gr build_target="$1"
}
declare opt_update_modulefiles='no'
pbuild.update_modulefiles() {
opt_update_modulefiles="$1"
declare -gr opt_update_modulefiles="$1"
}
# number of parallel make jobs
declare -i JOBS=3
pbuild.jobs() {
JOBS="$1"
declare -gr JOBS="$1"
}
declare system=$(uname -s)
pbuild.system() {
system="$1"
declare -gr system="$1"
}
declare TEMP_DIR="${PMODULES_TMPDIR:-/var/tmp/${USER}}"
pbuild.temp_dir() {
TEMP_DIR="$1"
declare -gr TEMP_DIR="$1"
}
declare PMODULES_DISTFILESDIR="${PMODULES_ROOT}/var/distfiles"
pbuild.pmodules_distfilesdir() {
PMODULES_DISTFILESDIR="$1"
declare -gr PMODULES_DISTFILESDIR="$1"
}
declare verbose='no'
pbuild.verbose() {
verbose='yes'
declare -gr verbose="$1"
}
# module name including path in hierarchy and version
......@@ -156,10 +145,7 @@ declare -r _DOCDIR='share/doc'
# install prefix of module.
declare -x PREFIX=''
# :FIXME:
# OS is still used in some build-scripts. We have to implement a getter
# and use this getter in the build-scripts.
declare -r OS="${system}"
declare -r OS=$(uname -s)
##############################################################################
......@@ -206,7 +192,9 @@ set_full_module_name_and_prefix() {
echo "$*"
}
[[ -n ${GROUP} ]] || std::die 1 "${module_name}/${module_version}: group not set."
[[ -n ${GROUP} ]] || std::die 1 \
"${module_name}/${module_version}:" \
"group not set."
# build module name
# :FIXME: this should be read from a configuration file
......@@ -327,12 +315,10 @@ pbuild::use_cc() {
pbuild::pre_prep() {
:
}
eval "pbuild::pre_prep_${system}() { :; }"
pbuild::post_prep() {
:
}
eval "pbuild::post_prep_${system}() { :; }"
###############################################################################
#
......@@ -488,7 +474,6 @@ pbuild::add_patch() {
PATCH_FILES+=( "$1" )
PATCH_STRIPS+=( "$2" )
}
eval "pbuild::add_patch_${system}() { pbuild::add_patch \"\$@\"; }"
pbuild::set_default_patch_strip() {
[[ -n "$1" ]] || \
......@@ -509,7 +494,6 @@ pbuild::use_flag() {
pbuild::pre_configure() {
:
}
eval "pbuild::pre_configure_${system}() { :; }"
pbuild::set_configure_args() {
CONFIGURE_ARGS+=( "$@" )
......@@ -575,12 +559,10 @@ pbuild::configure() {
pbuild::post_configure() {
:
}
eval "pbuild::post_configure_${system}() { :; }"
pbuild::pre_compile() {
:
}
eval "pbuild::pre_compile_${system}() { :; }"
pbuild::compile() {
make -j${JOBS}
......@@ -589,12 +571,10 @@ pbuild::compile() {
pbuild::post_compile() {
:
}
eval "pbuild::post_compile_${system}() { :; }"
pbuild::pre_install() {
:
}
eval "pbuild::pre_install_${system}() { :; }"
pbuild::install() {
make install
......@@ -636,8 +616,6 @@ pbuild::install_shared_libs() {
pbuild::post_install() {
:
}
eval "pbuild::post_install_${system}() { :; }"
#
# The 'do it all' function.
......
#!/bin/bash
eval "pbuild::pre_prep_${system}() { :; }"
eval "pbuild::pre_prep_${OS}() { :; }"
eval "pbuild::post_prep_${system}() { :; }"
eval "pbuild::post_prep_${OS}() { :; }"
eval "pbuild::add_patch_${system}() { pbuild::add_patch \"\$@\"; }"
eval "pbuild::add_patch_${OD}() { pbuild::add_patch \"\$@\"; }"
eval "pbuild::pre_configure_${system}() { :; }"
eval "pbuild::pre_configure_${OS}() { :; }"
eval "pbuild::post_configure_${system}() { :; }"
eval "pbuild::post_configure_${OS}() { :; }"
eval "pbuild::pre_compile_${system}() { :; }"
eval "pbuild::pre_compile_${OS}() { :; }"
eval "pbuild::post_compile_${system}() { :; }"
eval "pbuild::post_compile_${OS}() { :; }"
eval "pbuild::pre_install_${system}() { :; }"
eval "pbuild::pre_install_${OS}() { :; }"
eval "pbuild::post_install_${system}() { :; }"
eval "pbuild::post_install_${OS}() { :; }"
......@@ -271,6 +271,31 @@ There is NO WARRANTY, to the extent permitted by law."
done
}
std.get_os_release_linux() {
source /etc/os-release
case "${ID}" in
science | rhel | centos | fedora )
echo "rhel${VERSION_ID%.*}"
;;
* )
echo "Unknown"
exit 1
;;
esac
}
std.get_os_release_macos() {
VERSION_ID=$(sw_vers -productVersion)
echo "macOS${VERSION_ID%.*}"
}
std::get_os_release() {
local -r OS=$(uname -s)
local -A func_map;
func_map['Linux']=std.get_os_release_linux
func_map['Darwin']=std.get_os_release_macos
${func_map[${OS}]}
}
# Local Variables:
# mode: sh
# sh-basic-offset: 8
......
#!/usr/bin/env bash --
#!/usr/bin/env bash
#
# The following build specific variables are set and used in libpbuild.bash:
# ARGS
......@@ -21,11 +21,11 @@ PATH+=":${mydir}"
PATH+=":${mydir}/../lib:${mydir}/../config"
source libstd.bash || {
echo "Oops: library '$_' cannot be loaded!" 1>&2; exit 3;
echo "Oops: cannot source library -- '$_'" 1>&2; exit 3;
}
source libpbuild.bash || \
std::die 3 "Oops: Cannot source library -- '$_'"
std::die 3 "Oops: cannot source library -- '$_'"
# save arguments, (still) required for building dependencies
declare -r ARGS="$@"
......@@ -127,30 +127,40 @@ MISCELLANEOUS OPTIONS:
declare -a versions=()
declare opt_all_variants='no'
declare opt_bootstrap='no'
declare opt_build_config='modbuild.conf'
declare opt_build_target='all'
declare opt_distfiles_dir="${PMODULES_ROOT}/var/distfiles"
declare opt_dry_run='no'
declare opt_enable_cleanup_build='yes'
declare opt_enable_cleanup_src='yes'
declare opt_force_rebuild='no'
declare -i opt_jobs=3
declare opt_update_modulefiles='no'
declare opt_system=''
declare opt_temp_dir="${PMODULES_TMPDIR:-/var/tmp/${USER}}"
declare opt_verbose='no'
# array collecting all modules specified on the command line via '--with=module'
declare -a opt_with_modules=()
declare build_config='modbuild.conf'
declare system="$(uname -s)"
parse_args() {
while (( $# > 0 )); do
case $1 in
-j )
pbuild.jobs "$2"
opt_jobs="$2"
shift
;;
--jobs=[0-9]* )
pbuild.jobs "${1/--jobs=}"
opt_jobs="${1/--jobs=}"
;;
-v | --verbose )
trap 'echo "$BASH_COMMAND"' DEBUG
pbuild.verbose 'yes'
opt_verbose='yes'
;;
--debug )
set -x
;;
-f | --force-rebuild )
pbuild.force_rebuild 'yes'
opt_force_rebuild='yes'
;;
-\? | -h | --help )
usage
......@@ -159,57 +169,55 @@ parse_args() {
std::die 0 "\nPmodules version ${VERSION}\nCopyright GNU GPL v2\n"
;;
--dry-run )
pbuild.dry_run 'yes'
opt_dry_run='yes'
;;
--config )
build_config="$2"
opt_build_config="$2"
shift 1
;;
--config=* )
build_config="${1#*=}"
opt_build_config="${1#*=}"
;;
--enable-cleanup )
pbuild.enable_cleanup_build 'yes'
pbuild.enable_cleanup_src 'yes'
opt_enable_cleanup_build 'yes'
opt_enable_cleanup_src 'yes'
;;
--disable-cleanup )
pbuild.enable_cleanup_build 'no'
pbuild.enable_cleanup_src 'no'
opt_enable_cleanup_build 'no'
opt_enable_cleanup_src 'no'
;;
--enable-cleanup-build )
pbuild.enable_cleanup_build 'yes'
opt_enable_cleanup_build 'yes'
;;
--disable-cleanup-build )
pbuild.enable_cleanup_build 'no'
opt_enable_cleanup_build 'no'
;;
--enable-cleanup-src )
pbuild.enable_cleanup_src 'yes'
opt_enable_cleanup_src 'yes'
;;
--disable-cleanup-src )
pbuild.enable_cleanup_src 'no'
opt_enable_cleanup_src 'no'
;;
--distdir )
pbuild.pmodules_distfilesdir "$2"
opt_distfiles_dir "$2"
shift
;;
--distdir=* )
pbuild.pmodules_distfilesdir "${1/--distdir=}"
opt_distfiles_dir "${1/--distdir=}"
;;
--tmpdir )
pbuild.temp_dir "$2"
opt_temp_dir="$2"
shift
;;
--tmpdir=* )
pbuilf.temp_dir "${1/--tmpdir=}"
opt_temp_dir="${1/--tmpdir=}"
;;
--system )
system=".$2"
pbuild.system "${system}"
opt_system="$2"
shift
;;
--system=* )
system=".${1/*=}"
pbuild.system "${system}"
opt_system="${1/*=}"
;;
--with )
opt_with_modules+=( "$2" )
......@@ -220,13 +228,13 @@ parse_args() {
opt_with_modules+=( ${m} )
;;
--prep | --configure | --compile | --install | --all )
pbuild.build_target ${1:2}
opt_build_target=${1:2}
;;
--bootstrap )
opt_bootstrap='yes'
;;
--update-modulefiles )
pbuild.update_modulefiles 'yes'
opt_update_modulefiles='yes'
;;
-- )
:
......@@ -263,10 +271,13 @@ find_variants_files(){
shopt -q nullglob || :
local -i nullglob_set=$?
shopt -s nullglob
local files=( "${BUILDBLOCK_DIR}"/*/variants.${system} )
local files=( "${BUILDBLOCK_DIR}"/*/variants.${opt_system} )
files+=( "${BUILDBLOCK_DIR}"/*/variants.$(uname -s) )
local f
for f in "${BUILDBLOCK_DIR}"/*/variants; do
[[ -e "${f}.${system}" ]] || files+=( "$f" )
[[ -e "${f}.${opt_system}" ]] \
|| [[ -e "${f}.$(uname -s)" ]] \
|| files+=( "$f" )
done
(( nullglob_set == 1 )) && shopt -u nullglob
std::upvar "$1" "${files[@]}"
......@@ -373,6 +384,25 @@ build_modules() {
parse_args "$@"
if [[ -z "${opt_system}" ]]; then
opt_system=$(std::get_os_release)
fi
pbuild.jobs "${opt_jobs}"
pbuild.force_rebuild "${opt_force_rebuild}"
pbuild.build_target "${opt_build_target}"
pbuild.dry_run "${opt_dry_run}"
pbuild.enable_cleanup_build "${opt_enable_cleanup_build}"
pbuild.enable_cleanup_src "${opt_enable_cleanup_src}"
pbuild.pmodules_distfilesdir "${opt_distfiles_dir}"
pbuild.update_modulefiles "${opt_update_modulefiles}"
pbuild.temp_dir "${opt_temp_dir}"
pbuild.system "${opt_system}"
pbuild.verbose "${opt_verbose}"
source libpbuild_dyn.bash || \
std::die 3 "Oops: cannot source library -- '$_'"
# source build configuration,
# must be done before sourcing libpbuild!
if [[ "${opt_bootstrap}" == 'yes' ]]; then
......@@ -380,8 +410,8 @@ if [[ "${opt_bootstrap}" == 'yes' ]]; then
else
test -d "${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}" && PATH+=":$_"
fi
source "${build_config}" || \
std::die 3 "Oops: Cannot source configuration file -- '${build_config}'"
source "${opt_build_config}" || \
std::die 3 "Oops: Cannot source configuration file -- '$_'"
declare -r BUILD_SCRIPT
declare -r BUILDBLOCK_DIR
......
......@@ -313,6 +313,7 @@ pmodules::install() {
install -m 0644 "${SRC_DIR}/libpmodules.bash" "${PMODULES_HOME}/lib"
install -m 0644 "${SRC_DIR}/libpbuild.bash" "${PMODULES_HOME}/lib"
install -m 0644 "${SRC_DIR}/libpbuild_dyn.bash" "${PMODULES_HOME}/lib"
install -m 0644 "${SRC_DIR}/libstd.bash" "${PMODULES_HOME}/lib"
install -m 0755 -d "${PMODULES_HOME}/lib/Pmodules"
install -m 0644 "${SRC_DIR}/libmodules.tcl" "${PMODULES_HOME}/lib/Pmodules"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment