[enh] Allow to dig deeper into an archive with ynh_setup_source

This commit is contained in:
Maniack Crudelis 2019-01-28 00:42:56 +01:00 committed by GitHub
parent 0bc8300b88
commit 63d62b4f7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -118,6 +118,8 @@ ynh_backup_before_upgrade () {
# SOURCE_FORMAT=tar.gz # SOURCE_FORMAT=tar.gz
# # (Optional) Put false if sources are directly in the archive root # # (Optional) Put false if sources are directly in the archive root
# # default: true # # default: true
# # Instead of true, SOURCE_IN_SUBDIR could be the number of sub directories
# # to remove.
# SOURCE_IN_SUBDIR=false # SOURCE_IN_SUBDIR=false
# # (Optionnal) Name of the local archive (offline setup support) # # (Optionnal) Name of the local archive (offline setup support)
# # default: ${src_id}.${src_format} # # default: ${src_id}.${src_format}
@ -136,6 +138,8 @@ ynh_backup_before_upgrade () {
# If it's ok, the source archive will be uncompressed in $dest_dir. If the # If it's ok, the source archive will be uncompressed in $dest_dir. If the
# SOURCE_IN_SUBDIR is true, the first level directory of the archive will be # SOURCE_IN_SUBDIR is true, the first level directory of the archive will be
# removed. # removed.
# If SOURCE_IN_SUBDIR is a numeric value, 2 for example, the 2 first level
# directories will be removed
# #
# Finally, patches named sources/patches/${src_id}-*.patch and extra files in # Finally, patches named sources/patches/${src_id}-*.patch and extra files in
# sources/extra_files/$src_id will be applied to dest_dir # sources/extra_files/$src_id will be applied to dest_dir
@ -200,8 +204,14 @@ ynh_setup_source () {
fi fi
else else
local strip="" local strip=""
if $src_in_subdir ; then if [ "$src_in_subdir" != "false" ]
strip="--strip-components 1" then
if [ "$src_in_subdir" == "true" ]; then
local sub_dirs=1
else
local sub_dirs="$src_in_subdir"
fi
strip="--strip-components $sub_dirs"
fi fi
if [[ "$src_format" =~ ^tar.gz|tar.bz2|tar.xz$ ]] ; then if [[ "$src_format" =~ ^tar.gz|tar.bz2|tar.xz$ ]] ; then
tar -xf $src_filename -C "$dest_dir" $strip tar -xf $src_filename -C "$dest_dir" $strip