From 81ecf5e7b9c9c66f99cfba2411f7b82ae2ef6c81 Mon Sep 17 00:00:00 2001 From: Dan Dye Date: Thu, 16 Feb 2017 20:26:55 +0000 Subject: [PATCH 1/5] paramters for scriptlets --- makepkg.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/makepkg.sh b/makepkg.sh index 67d69b2..73b9969 100755 --- a/makepkg.sh +++ b/makepkg.sh @@ -2248,11 +2248,68 @@ run_fpm() { else local vendor_param="--vendor \"$RPM_VENDOR\"" fi - if [[ "$install" = "" ]]; then +# +# arch - https://wiki.archlinux.org/index.php/PKGBUILD +# +# pre_install - The script is run right before files are extracted. One argument is passed: new package version. +# post_install - The script is run right after files are extracted. One argument is passed: new package version. +# pre_upgrade - The script is run right before files are extracted. Two arguments are passed in the following order: new package version, old package version. +# post_upgrade - The script is run after files are extracted. Two arguments are passed in the following order: new package version, old package version. +# pre_remove - The script is run right before files are removed. One argument is passed: old package version. +# post_remove - The script is run right after files are removed. One argument is passed: old package version. +# +# fpm - https://github.com/jordansissel/fpm/wiki +# +# --post-install FILE (DEPRECATED, use --after-install) A script to be run after package installation +# --pre-install FILE (DEPRECATED, use --before-install) A script to be run before package installation +# --post-uninstall FILE (DEPRECATED, use --after-remove) A script to be run after package removal +# --pre-uninstall FILE (DEPRECATED, use --before-remove) A script to be run before package removal +# --after-install FILE A script to be run after package installation +# --before-install FILE A script to be run before package installation +# --after-remove FILE A script to be run after package removal +# --before-remove FILE A script to be run before package removal +# --after-upgrade FILE A script to be run after package upgrade. If not specified, --before-install, --after-install, --before-remove, and --after-remove will behave in a backwards-compatible manner (they will not be upgrade-case aware). Currently only supports deb and rpm packages. +# --before-upgrade FILE A script to be run before package upgrade. If not specified, --before-install, --after-install, --before-remove, and --after-remove will behave in a backwards-compatible manner (they will not be upgrade-case aware). Currently only supports deb and rpm packages. +# +# rpm - https://fedoraproject.org/wiki/Packaging:Scriptlets +# +# %pretrans install upgrade +# %pre install upgrade +# %post install upgrade +# %preun upgrade uninstall +# %postun upgrade uninstall +# %posttrans install upgrade + + if [[ "$pre_install" = "" ]]; then + local before_install_param='' + else + local before_install_param="--before-install \"${startdir}/${pre_install}\"" + fi + if [[ "$post_install" = "" ]]; then local after_install_param='' else - local after_install_param="--after-install \"${startdir}/${install}\"" + local after_install_param="--after-install \"${startdir}/${post_install}\"" + if [[ "$pre_upgrade" = "" ]]; then + local before_upgrade_param='' + else + local before_upgrade_param="--before-upgrade \"${startdir}/${pre_upgrade}\"" + fi + if [[ "$post_upgrade" = "" ]]; then + local after_upgrade_param='' + else + local after_upgrade_param="--after-upgrade \"${startdir}/${post_upgrade}\"" + fi + if [[ "$pre_remove" = "" ]]; then + local before_remove_param='' + else + local before_remove_param="--post-remove \"${startdir}/${pre_remove}\"" + fi + if [[ "$post_remove" = "" ]]; then + local after_remove_param='' + else + local after_remove_param="--after-remove \"${startdir}/${post_remove}\"" fi + local nm=$1; shift local cmd="fpm -s dir -t rpm --force -a $fpm_arch" cmd="$cmd $rpm_dist_param" @@ -2270,7 +2327,12 @@ run_fpm() { cmd="$cmd --iteration \"$pkgrel\"" cmd="$cmd $epoch_param" cmd="$cmd -C \"$pkgdir\"" # chdir here for contents + cmd="$cmd $before_install_param" cmd="$cmd $after_install_param" + cmd="$cmd $before_upgrade_param" + cmd="$cmd $after_upgrade_param" + cmd="$cmd $before_remove_param" + cmd="$cmd $after_remove_param" for item in "${backup[@]}"; do cmd="$cmd --config-files \"$item\"" done From 0b6ecbd3712982fc6bc219c2dc98f870e6c1d19e Mon Sep 17 00:00:00 2001 From: Dan Dye Date: Thu, 16 Feb 2017 23:10:27 +0000 Subject: [PATCH 2/5] scriptlet params and build artifacts --- makepkg.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/makepkg.sh b/makepkg.sh index 73b9969..65c54f4 100755 --- a/makepkg.sh +++ b/makepkg.sh @@ -1,7 +1,7 @@ #!/bin/bash # # minimal adaptation of archlinux's 'makepkg' for centos/rhel via fpm -# original: +# original: # https://projects.archlinux.org/pacman.git/tree/scripts/makepkg.sh.in # @@ -2289,6 +2289,7 @@ run_fpm() { local after_install_param='' else local after_install_param="--after-install \"${startdir}/${post_install}\"" + fi if [[ "$pre_upgrade" = "" ]]; then local before_upgrade_param='' else @@ -2314,7 +2315,7 @@ run_fpm() { local cmd="fpm -s dir -t rpm --force -a $fpm_arch" cmd="$cmd $rpm_dist_param" cmd="$cmd --rpm-os linux" - # cmd="$cmd --debug-workspace" # skips cleanup of /tmp and allows inspection of SPECFILE + cmd="$cmd --debug-workspace" # skips cleanup of /tmp and allows inspection of SPECFILE cmd="$cmd --rpm-auto-add-directories" cmd="$cmd --package \"$PKGDEST\"" # output path cmd="$cmd $maintainer_param" @@ -2340,9 +2341,18 @@ run_fpm() { cmd="$cmd -d \"$item\"" done cmd="$cmd --rpm-use-file-permissions --rpm-user root --rpm-group root" + cmd="$cmd --workdir=/tmp/${pkgver}-${pkgrel}/" cmd="$cmd $@" - # echo $cmd # for debugging + # Create tarball of Build Artifacts: + # 1. command used to call fpm + # 2. fpm temp dir (contains SPECFILE for rpm) + mkdir /tmp/${pkgver}-${pkgrel}/ + echo $cmd > /tmp/${pkgver}-${pkgrel}/fpm_cmd_${pgkname}_${pkgver}_${pkgrel}.txt eval $cmd + tar -czvf ../../fpm_build_artifacts_${pkgver}-${pkgrel}.tar.gz \ + /tmp/${pkgver}-${pkgrel}/ \ + ../../PKGBUILD + } # get back to our src directory so we can begin with sources From c31c51342fb9701ca269c739604444c8af93f1a6 Mon Sep 17 00:00:00 2001 From: Dan Dye Date: Tue, 21 Feb 2017 15:37:11 +0000 Subject: [PATCH 3/5] added fpmargs array for --rpm-attr --- makepkg.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/makepkg.sh b/makepkg.sh index 65c54f4..da056c6 100755 --- a/makepkg.sh +++ b/makepkg.sh @@ -2340,7 +2340,12 @@ run_fpm() { for item in "${depends[@]}"; do cmd="$cmd -d \"$item\"" done - cmd="$cmd --rpm-use-file-permissions --rpm-user root --rpm-group root" + cmd="$cmd --rpm-use-file-permissions" # affects mode only (not owner/group) + cmd="$cmd --rpm-user root" # overrides use-file-permissions + cmd="$cmd --rpm-group root" + for item in "${fpmargs[@]}"; do # created for --rpm-attr + cmd="${cmd} ${item}"; + done cmd="$cmd --workdir=/tmp/${pkgver}-${pkgrel}/" cmd="$cmd $@" # Create tarball of Build Artifacts: From 75cba8374f10d1e12e126fd0e38990183b2834d9 Mon Sep 17 00:00:00 2001 From: Dan Dye Date: Thu, 23 Feb 2017 20:37:11 +0000 Subject: [PATCH 4/5] reduce verbosity of build artifact tarring --- makepkg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepkg.sh b/makepkg.sh index da056c6..68baa45 100755 --- a/makepkg.sh +++ b/makepkg.sh @@ -2354,7 +2354,7 @@ run_fpm() { mkdir /tmp/${pkgver}-${pkgrel}/ echo $cmd > /tmp/${pkgver}-${pkgrel}/fpm_cmd_${pgkname}_${pkgver}_${pkgrel}.txt eval $cmd - tar -czvf ../../fpm_build_artifacts_${pkgver}-${pkgrel}.tar.gz \ + tar -czf ../../fpm_build_artifacts_${pkgver}-${pkgrel}.tar.gz \ /tmp/${pkgver}-${pkgrel}/ \ ../../PKGBUILD From 5d7055636ca316bfdb8f7d31b9feaf0e7ea5926d Mon Sep 17 00:00:00 2001 From: Dan Dye Date: Fri, 24 Feb 2017 17:35:38 +0000 Subject: [PATCH 5/5] disable debug-workspace fpm arg --- makepkg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepkg.sh b/makepkg.sh index 68baa45..7d0a0e8 100755 --- a/makepkg.sh +++ b/makepkg.sh @@ -2315,7 +2315,7 @@ run_fpm() { local cmd="fpm -s dir -t rpm --force -a $fpm_arch" cmd="$cmd $rpm_dist_param" cmd="$cmd --rpm-os linux" - cmd="$cmd --debug-workspace" # skips cleanup of /tmp and allows inspection of SPECFILE + # cmd="$cmd --debug-workspace" # skips cleanup of /tmp and allows inspection of SPECFILE cmd="$cmd --rpm-auto-add-directories" cmd="$cmd --package \"$PKGDEST\"" # output path cmd="$cmd $maintainer_param"