mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
helpers2.1: change source patches location + raise an error instead of a warning when a patch fails to apply on CI
Co-authored-by: Félix Piédallu <felix@piedallu.me>
This commit is contained in:
parent
3f973669fc
commit
a48bfa67de
1 changed files with 20 additions and 18 deletions
|
@ -8,11 +8,7 @@
|
||||||
# | arg: --keep= - Space-separated list of files/folders that will be backup/restored in $dest_dir, such as a config file you don't want to overwrite. For example 'conf.json secrets.json logs' (no trailing `/` for folders)
|
# | arg: --keep= - Space-separated list of files/folders that will be backup/restored in $dest_dir, such as a config file you don't want to overwrite. For example 'conf.json secrets.json logs' (no trailing `/` for folders)
|
||||||
# | arg: --full_replace= - Remove previous sources before installing new sources (can be 1 or 0, default to 0)
|
# | arg: --full_replace= - Remove previous sources before installing new sources (can be 1 or 0, default to 0)
|
||||||
#
|
#
|
||||||
# ##### New 'sources' resources
|
# This helper will read infos from the 'sources' resources in the `manifest.toml` of the app
|
||||||
#
|
|
||||||
# (See also the resources documentation which may be more complete?)
|
|
||||||
#
|
|
||||||
# This helper will read infos from the 'sources' resources in the manifest.toml of the app
|
|
||||||
# and expect a structure like:
|
# and expect a structure like:
|
||||||
#
|
#
|
||||||
# ```toml
|
# ```toml
|
||||||
|
@ -22,7 +18,9 @@
|
||||||
# sha256 = "0123456789abcdef" # The sha256 sum of the asset obtained from the URL
|
# sha256 = "0123456789abcdef" # The sha256 sum of the asset obtained from the URL
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
# ##### Optional flags
|
# (See also the resources documentation which may be more complete?)
|
||||||
|
#
|
||||||
|
# ##### Optional flags in the 'sources' resource
|
||||||
#
|
#
|
||||||
# ```text
|
# ```text
|
||||||
# format = "tar.gz"/xz/bz2 # automatically guessed from the extension of the URL, but can be set explicitly. Will use `tar` to extract
|
# format = "tar.gz"/xz/bz2 # automatically guessed from the extension of the URL, but can be set explicitly. Will use `tar` to extract
|
||||||
|
@ -60,7 +58,8 @@
|
||||||
# - Uncompress the archive to `$dest_dir`.
|
# - Uncompress the archive to `$dest_dir`.
|
||||||
# - If `in_subdir` is true, the first level directory of the archive will be removed.
|
# - If `in_subdir` is true, the first level directory of the archive will be removed.
|
||||||
# - If `in_subdir` is a numeric value, the N first level directories will be removed.
|
# - If `in_subdir` is a numeric value, the N first level directories will be removed.
|
||||||
# - Patches named `patches/${src_id}-*.patch` will be applied to `$dest_dir`
|
# - Patches named `patches/${src_id}/*.patch` will be applied to `$dest_dir`
|
||||||
|
# - Apply sane default permissions (see _ynh_apply_default_permissions)
|
||||||
ynh_setup_source() {
|
ynh_setup_source() {
|
||||||
# ============ Argument parsing =============
|
# ============ Argument parsing =============
|
||||||
local -A args_array=([d]=dest_dir= [s]=source_id= [k]=keep= [r]=full_replace)
|
local -A args_array=([d]=dest_dir= [s]=source_id= [k]=keep= [r]=full_replace)
|
||||||
|
@ -222,18 +221,21 @@ ynh_setup_source() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Apply patches
|
# Apply patches
|
||||||
if [ -d "$YNH_APP_BASEDIR/patches/" ]; then
|
local patches_folder=$(realpath "$YNH_APP_BASEDIR/patches/$source_id")
|
||||||
local patches_folder=$(realpath $YNH_APP_BASEDIR/patches/)
|
if [ -d "$patches_folder" ]; then
|
||||||
# Check if any file matching the pattern exists, cf https://stackoverflow.com/a/34195247
|
|
||||||
if compgen -G "$patches_folder/${source_id}-*.patch" >/dev/null; then
|
|
||||||
pushd "$dest_dir"
|
pushd "$dest_dir"
|
||||||
for p in $patches_folder/${source_id}-*.patch; do
|
for patchfile in "$patches_folder/"*.patch; do
|
||||||
echo $p
|
echo "Applying $patchfile"
|
||||||
patch --strip=1 <$p || ynh_print_warn "Packagers /!\\ patch $p failed to apply"
|
if ! patch --strip=1 < "$patchfile"; then
|
||||||
|
if ynh_in_ci_tests; then
|
||||||
|
ynh_die "Patch $patchfile failed to apply!"
|
||||||
|
else
|
||||||
|
ynh_print_warn "Warn your packagers /!\\ Patch $patchfile failed to apply"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Keep files to be backup/restored at the end of the helper
|
# Keep files to be backup/restored at the end of the helper
|
||||||
# Assuming $dest_dir already exists
|
# Assuming $dest_dir already exists
|
||||||
|
|
Loading…
Add table
Reference in a new issue