aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-02-20 10:08:26 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-02-20 10:08:26 +0000
commit1adc6fc5c1af35db8f35bcdb09ccae2657c8b9b6 (patch)
treedf386ef787a371dc25bfd34c938054386a47d06a
parentfbdd725dc4096d4d48ca468f14459870235e4300 (diff)
downloadcpt-1adc6fc5c1af35db8f35bcdb09ccae2657c8b9b6.tar.gz
kiss: Move hooks to function for easy reuse.
This will allow for new hook additions to be single line changes. I don't know how many additional hooks we'll add or what they'll be but it's a good idea regardless. pre-update(?), post-update(?), pre-install(?), etc FossilOrigin-Name: 560d074a7685b115b4b753c6dbc1bf792485bbec3ff0e75fb81729cbbd2f26f1
-rwxr-xr-xkiss18
1 files changed, 10 insertions, 8 deletions
diff --git a/kiss b/kiss
index 4846875..47938e5 100755
--- a/kiss
+++ b/kiss
@@ -80,6 +80,14 @@ pop() {
for i; do [ "$i" = "$del" ] || printf %s " $i "; done
}
+run_hook() {
+ [ "$KISS_HOOK" ] || return 0
+
+ log "$pkg" "Running $1 hook"
+
+ TYPE=$1 PKG=$pkg DEST=$pkg_dir/$pkg . "$KISS_HOOK"
+}
+
pkg_lint() {
# Check that each mandatory file in the package entry exists.
log "$1" "Checking repository files"
@@ -570,10 +578,7 @@ pkg_build() {
log "$pkg" "Starting build"
- if [ "$KISS_HOOK" ]; then
- log "$pkg" "Running pre-build hook"
- TYPE=pre-build PKG=$pkg DEST=$pkg_dir/$pkg . "$KISS_HOOK"
- fi
+ run_hook pre-build
# Call the build script, log the output to the terminal
# and to a file. There's no PIPEFAIL in POSIX shelll so
@@ -600,10 +605,7 @@ pkg_build() {
log "$pkg" "Successfully built package"
- if [ "$KISS_HOOK" ]; then
- log "$pkg" "Running post-build hook"
- TYPE=post-build PKG=$pkg DEST=$pkg_dir/$pkg . "$KISS_HOOK"
- fi
+ run_hook post-build
# Create the manifest file early and make it empty.
# This ensures that the manifest is added to the manifest.