build-system: configurable number directory components to be strip

The tar command is called with the option --strip-components. Till now
the value was 1 and hardcoded. In some cases more or less components
must be removed. This can now be configured in the YAML file.
This commit is contained in:
2024-04-16 15:32:43 +02:00
parent 474ca36af0
commit 58f6a2ed4e
3 changed files with 29 additions and 10 deletions
+3
View File
@@ -17,6 +17,9 @@
* Option '--clean-install' added. If this option is set, the
module is removed before building, if the module already
exist. (issue #247)
* The number of directory components to be removed while
un-taring can now be configured in the YAML configuration
file. If not specified, 1 is used as default. (issue #251)
## Version 1.1.18
### modulecmd
+17 -9
View File
@@ -18,6 +18,7 @@ declare -r _DOCDIR='share/doc'
declare -a SOURCE_URLS=()
declare -a SOURCE_SHA256_SUMS=()
declare -a SOURCE_NAMES=()
declare -a SOURCE_STRIP_DIRS=()
declare -A SOURCE_UNPACK_DIRS=()
declare -a CONFIGURE_ARGS=()
declare -a PATCH_FILES=()
@@ -398,11 +399,6 @@ pbuild::set_download_url() {
std::info \
"Using ${FUNCNAME} is deprecated with YAML module configuration files."
fi
pbuild.set_urls "$@"
}
readonly -f pbuild::set_download_url
pbuild.set_urls(){
local -i _i=${#SOURCE_URLS[@]}
SOURCE_URLS[_i]=$1
if (( $# > 1 )); then
@@ -410,6 +406,15 @@ pbuild.set_urls(){
else
SOURCE_NAMES[$_i]="${1##*/}"
fi
SOURCE_STRIP_DIRS[_i]='1'
}
readonly -f pbuild::set_download_url
pbuild.set_urls(){
local -i _i=${#SOURCE_URLS[@]}
SOURCE_URLS[_i]="$1"
SOURCE_NAMES[$_i]="$2"
SOURCE_STRIP_DIRS[_i]="$3"
}
#..............................................................................
@@ -495,7 +500,8 @@ readonly -f pbuild::set_default_patch_strip
pbuild::unpack(){
local -r file="$1"
local -r dir="${2:-${SRC_DIR}}"
${tar} --directory="${dir}" -xv --strip-components 1 -f "${file}"
local -r strip="${3:-1}"
${tar} --directory="${dir}" -xv --strip-components "${strip}" -f "${file}"
}
#..............................................................................
@@ -601,10 +607,11 @@ pbuild::prep() {
unpack() {
local -r file="$1"
local -r dir="${2:-${SRC_DIR}}"
local -r dir="$2"
local -r strip="$3"
{
mkdir -p "${dir}"
pbuild::unpack "${file}" "${dir}"
pbuild::unpack "${file}" "${dir}" "${strip}"
} || {
${rm} -f "${file}"
std::die 4 \
@@ -657,7 +664,8 @@ pbuild::prep() {
else
dir="${SRC_DIR}"
fi
unpack "${source_fname}" "${dir}"
local strip_dirs="${SOURCE_STRIP_DIRS[i]}"
unpack "${source_fname}" "${dir}" "${strip_dirs}"
done
patch_sources
# create build directory
+9 -1
View File
@@ -1143,6 +1143,7 @@ build_modules_yaml_v1(){
std::die 3 "error parsing YAML configuration"
local url=''
local fname=''
local strip_dirs=''
while read key value; do
key=${key:0:-1}
case "${key}" in
@@ -1152,6 +1153,10 @@ build_modules_yaml_v1(){
name )
fname=$(envsubst <<<"${value}")
;;
strip_dirs )
strip_dirs="${value}"
# :FIXME: add check for unsigned int!
;;
* )
std::die 3 "Invalid key in list of URLs -- ${key}"
;;
@@ -1160,7 +1165,10 @@ build_modules_yaml_v1(){
std::die 3 "URL missing!"
fi
done <<<"${url_yaml}"
pbuild.set_urls "${url}" "${fname}"
[[ -z "${url}" ]] && std::die 3 "url missing in:\n${yaml}"
[[ -z "${fname}" ]] && fname="${url##*/}"
[[ -z "${strip_dirs}" ]] && strip_dirs=1
pbuild.set_urls "${url}" "${fname}" "${strip_dirs}"
done
}