mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-06-27 01:53:08 +02:00
build-system: support for different unpackers added
This commit is contained in:
+32
-3
@@ -19,6 +19,7 @@ declare -a SOURCE_URLS=()
|
||||
declare -a SOURCE_SHA256_SUMS=()
|
||||
declare -a SOURCE_NAMES=()
|
||||
declare -a SOURCE_STRIP_DIRS=()
|
||||
declare -a SOURCE_UNPACKER=()
|
||||
declare -A SOURCE_UNPACK_DIRS=()
|
||||
declare -ax CONFIGURE_ARGS=()
|
||||
declare -a PATCH_FILES=()
|
||||
@@ -424,6 +425,7 @@ pbuild.set_urls(){
|
||||
SOURCE_URLS[_i]="$1"
|
||||
SOURCE_NAMES[$_i]="$2"
|
||||
SOURCE_STRIP_DIRS[_i]="$3"
|
||||
SOURCE_UNPACKER[_i]="$4"
|
||||
}
|
||||
|
||||
#..............................................................................
|
||||
@@ -495,6 +497,9 @@ readonly -f pbuild.add_patch_files
|
||||
#..............................................................................
|
||||
#
|
||||
pbuild::set_default_patch_strip() {
|
||||
[[ ${opt_yaml} == 'yes' ]] && \
|
||||
std::info \
|
||||
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
|
||||
[[ -n "$1" ]] || \
|
||||
std::die 1 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
@@ -510,7 +515,29 @@ pbuild::unpack(){
|
||||
local -r file="$1"
|
||||
local -r dir="${2:-${SRC_DIR}}"
|
||||
local -r strip="${3:-1}"
|
||||
${tar} --directory="${dir}" -xv --strip-components "${strip}" -f "${file}"
|
||||
local -r unpacker="${4:-${tar}}"
|
||||
case "${unpacker}" in
|
||||
tar )
|
||||
${tar} \
|
||||
--directory="${dir}" \
|
||||
-xv \
|
||||
--strip-components "${strip}" \
|
||||
-f "${file}"
|
||||
;;
|
||||
7z )
|
||||
${sevenz} \
|
||||
x \
|
||||
-y \
|
||||
-o"${dir}" \
|
||||
"${file}"
|
||||
;;
|
||||
none )
|
||||
:
|
||||
;;
|
||||
* )
|
||||
std::die 1 "Unsupportet tool for unpacking -- '${unpacker}'"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#..............................................................................
|
||||
@@ -618,9 +645,10 @@ pbuild::prep() {
|
||||
local -r file="$1"
|
||||
local -r dir="$2"
|
||||
local -r strip="$3"
|
||||
local -r unpacker="$4"
|
||||
{
|
||||
mkdir -p "${dir}"
|
||||
pbuild::unpack "${file}" "${dir}" "${strip}"
|
||||
pbuild::unpack "${file}" "${dir}" "${strip}" "${unpacker}"
|
||||
} || {
|
||||
${rm} -f "${file}"
|
||||
std::die 4 \
|
||||
@@ -674,7 +702,8 @@ pbuild::prep() {
|
||||
dir="${SRC_DIR}"
|
||||
fi
|
||||
local strip_dirs="${SOURCE_STRIP_DIRS[i]}"
|
||||
unpack "${source_fname}" "${dir}" "${strip_dirs}"
|
||||
local unpacker="${SOURCE_UNPACKER[i]}"
|
||||
unpack "${source_fname}" "${dir}" "${strip_dirs}" "${unpacker}"
|
||||
done
|
||||
patch_sources
|
||||
# create build directory
|
||||
|
||||
+59
-20
@@ -28,10 +28,10 @@ declare -r MODULECMD="${PMODULES_HOME}/bin/modulecmd"
|
||||
std::die 1 "Oops: modulecmd binary not available!"
|
||||
|
||||
std::def_cmds "${mydir}/../libexec" \
|
||||
'yq'
|
||||
'sevenz' 'yq'
|
||||
|
||||
std::def_cmds '/usr/bin:/bin:/usr/sbin:/sbin' \
|
||||
'awk' 'base64' 'cat' 'cp' 'find' 'getopt' 'grep' \
|
||||
'awk' 'base64' 'cat' 'cp' 'envsubst' 'find' 'getopt' 'grep' \
|
||||
'install' 'logger' 'make' 'mkdir' 'mktemp' 'patch' 'pwd' \
|
||||
'rm' 'rmdir' 'sort' 'tar' 'tee' 'uname'
|
||||
|
||||
@@ -1213,46 +1213,84 @@ build_modules_yaml_v1(){
|
||||
"${@:4}"
|
||||
}
|
||||
|
||||
die_parsing(){
|
||||
std::die 3 "error parsing YAML:\n----\n$1\n----"
|
||||
}
|
||||
|
||||
die_invalid_value(){
|
||||
std::die 3 "Invalid value for key '$3' in $2 -- '$4'\n----\n$1\n----"
|
||||
}
|
||||
|
||||
die_invalid_key(){
|
||||
std::die 3 "Invalid key '$3' in $2\n----\n$1\n----"
|
||||
}
|
||||
|
||||
die_missing_key(){
|
||||
std::die 3 "Key '$3' missing in $2\n----\n$1\n----"
|
||||
}
|
||||
|
||||
local -A Unpackers=([tar]="tar" [7z]="7z")
|
||||
set_urls() {
|
||||
local -- yaml="$1"
|
||||
local -i l=0
|
||||
l=$( ${yq} -Ne e '.|length' <<<"${yaml}" 2>/dev/null) || \
|
||||
std::die 3 "error parsing YAML configuration"
|
||||
die_parsing "{yaml}"
|
||||
local -i i=0
|
||||
local -- url_yaml=''
|
||||
for ((i=0; i<l; i++)); do
|
||||
url_yaml=$(${yq} -Ne e ".[$i]" <<<"${yaml}" 2>/dev/null) || \
|
||||
std::die 3 "error parsing YAML configuration"
|
||||
die_parsing "{yaml}"
|
||||
local url=''
|
||||
local fname=''
|
||||
local strip_dirs=''
|
||||
local unpacker=''
|
||||
local key=''
|
||||
local value=''
|
||||
while read key value; do
|
||||
key=${key:0:-1}
|
||||
case "${key}" in
|
||||
url )
|
||||
url=$(envsubst <<<"${value}")
|
||||
url=$(${envsubst} <<<"${value}")
|
||||
;;
|
||||
name )
|
||||
fname=$(envsubst <<<"${value}")
|
||||
fname=$(${envsubst} <<<"${value}")
|
||||
;;
|
||||
strip_dirs )
|
||||
[[ ${value} =~ ^[0-9]+$ ]] || \
|
||||
die_invalid_value \
|
||||
"${url_yaml}" \
|
||||
'list of URLS' \
|
||||
'strip_dirs' \
|
||||
"${value}"
|
||||
strip_dirs="${value}"
|
||||
# :FIXME: add check for unsigned int!
|
||||
;;
|
||||
unpacker )
|
||||
[[ -v Unpackers[${value}] ]] || \
|
||||
die_invalid_value \
|
||||
"${url_yaml}" \
|
||||
'list of URLs' \
|
||||
'unpacker' \
|
||||
"${value}"
|
||||
unpacker="${value}"
|
||||
;;
|
||||
;;
|
||||
* )
|
||||
std::die 3 "Invalid key in list of URLs -- ${key}"
|
||||
die_invalid_key \
|
||||
"${url_yaml}" \
|
||||
'list of URLs' \
|
||||
"${key}"
|
||||
;;
|
||||
esac
|
||||
if [[ -z ${url} ]]; then
|
||||
std::die 3 "URL missing!"
|
||||
fi
|
||||
done <<<"${url_yaml}"
|
||||
[[ -z "${url}" ]] && std::die 3 "url missing in:\n${yaml}"
|
||||
[[ -z "${url}" ]] && \
|
||||
die_missing_key \
|
||||
"${url_yaml}" \
|
||||
'list of URLs' \
|
||||
'url'
|
||||
[[ -z "${fname}" ]] && fname="${url##*/}"
|
||||
[[ -z "${strip_dirs}" ]] && strip_dirs=1
|
||||
pbuild.set_urls "${url}" "${fname}" "${strip_dirs}"
|
||||
[[ -z "${unpacker}" ]] && unpacker='tar'
|
||||
pbuild.set_urls "${url}" "${fname}" "${strip_dirs}" "${unpacker}"
|
||||
done
|
||||
}
|
||||
|
||||
@@ -1272,19 +1310,19 @@ build_modules_yaml_v1(){
|
||||
local -- yaml="$1"
|
||||
local -i l=0
|
||||
l=$( ${yq} -Ne e '.|length' <<<"${yaml}" 2>/dev/null) || \
|
||||
std::die 3 "error parsing YAML configuration"
|
||||
die_parsing "${yaml}"
|
||||
local -i i=0
|
||||
local -- fname=''
|
||||
local -- pkgs_yaml=''
|
||||
for ((i=0; i<l; i++)); do
|
||||
pkgs_yaml=$(${yq} -Ne e ".[$i]" <<<"${yaml}" 2>/dev/null) || \
|
||||
std::die 3 "error parsing YAML configuration"
|
||||
die_parsing "${yaml}"
|
||||
local -- pkg_name=''
|
||||
local -- pkg_version=''
|
||||
local -a pkg_build_args=()
|
||||
local -a keys=()
|
||||
keys=( $( ${yq} -e ".|keys().[]" <<<"${pkgs_yaml}" 2>/dev/null )) || \
|
||||
std::die 3 "Oops: retrieving keys from:\n${yaml_input}"
|
||||
die_parsing "${pkgs_yaml}"
|
||||
local -- key=''
|
||||
for key in "${keys[@]}"; do
|
||||
case ${key,,} in
|
||||
@@ -1300,9 +1338,10 @@ build_modules_yaml_v1(){
|
||||
readarray -t pkg_build_args <<< "${value}"
|
||||
;;
|
||||
* )
|
||||
std::die 3 "%s -- %s\n%s" \
|
||||
"Invalid key in configuration" \
|
||||
"${key}" "${yaml_input}"
|
||||
die_invalid_key \
|
||||
"${pkgs_yaml}" \
|
||||
"in subpackage '$i'" \
|
||||
"${key}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@@ -1341,7 +1380,7 @@ build_modules_yaml_v1(){
|
||||
std::info " Systems to build on: ${systems[@]}"
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
P="${module_name}"
|
||||
parse_version "${module_version}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user