summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Riomar <henrik.riomar@gmail.com>2017-12-29 21:10:44 +0100
committerTimo Teräs <timo.teras@iki.fi>2018-01-03 14:20:58 +0200
commit23cb10477537a2bbf40ac06a61046f75f2b160c5 (patch)
tree2a9f983f1e03ee1becb32783b57bf5e90fb2e9c8
parent99e7bb93dfff2f43987b81ce7600ad8fbd0ce64c (diff)
downloadapk-tools-23cb10477537a2bbf40ac06a61046f75f2b160c5.tar.gz
apk-tools-23cb10477537a2bbf40ac06a61046f75f2b160c5.tar.bz2
apk-tools-23cb10477537a2bbf40ac06a61046f75f2b160c5.tar.xz
apk-tools-23cb10477537a2bbf40ac06a61046f75f2b160c5.zip
add new flag --no-commit-hooks
This flag skips running hook scripts This flag *must* be used during initramfs tmpfs initial install. The reason that this new flag is needed is that the hooks will currently always fail as musl and /bin/sh is missing at this stage on diskless.
-rw-r--r--src/apk.c4
-rw-r--r--src/apk_defines.h1
-rw-r--r--src/commit.c4
3 files changed, 9 insertions, 0 deletions
diff --git a/src/apk.c b/src/apk.c
index 0abc7cc..d4ce396 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -217,6 +217,9 @@ static int option_parse_commit(void *ctx, struct apk_db_options *dbopts, int opt
case 0x113:
apk_flags |= APK_NO_SCRIPTS;
break;
+ case 0x117:
+ apk_flags |= APK_NO_COMMIT_HOOKS;
+ break;
default:
return -ENOTSUP;
}
@@ -228,6 +231,7 @@ static const struct apk_option options_commit[] = {
{ 0x102, "clean-protected", "Do not create .apk-new files in configuration dirs" },
{ 0x111, "overlay-from-stdin", "Read list of overlay files from stdin" },
{ 0x113, "no-scripts", "Do not execute any scripts" },
+ { 0x117, "no-commit-hooks", "Skip pre/post hook scripts (but not other scripts)" },
};
const struct apk_option_group optgroup_commit = {
diff --git a/src/apk_defines.h b/src/apk_defines.h
index c743a31..08a3801 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -77,6 +77,7 @@ extern char **apk_argv;
#define APK_OVERLAY_FROM_STDIN 0x2000
#define APK_NO_SCRIPTS 0x4000
#define APK_NO_CACHE 0x8000
+#define APK_NO_COMMIT_HOOKS 0x00010000
/* default architecture for APK packages. */
#if defined(__x86_64__)
diff --git a/src/commit.c b/src/commit.c
index 0c0bb34..af49f5c 100644
--- a/src/commit.c
+++ b/src/commit.c
@@ -236,6 +236,10 @@ static int run_commit_hook(void *ctx, int dirfd, const char *file)
return 0;
snprintf(fn, sizeof(fn), "etc/apk/commit_hooks.d" "/%s", file);
+ if ((apk_flags & APK_NO_COMMIT_HOOKS) != 0) {
+ apk_message("Skipping: %s %s", fn, commit_hook_str[hook->type]);
+ return 0;
+ }
if (apk_verbosity >= 2) apk_message("Executing: %s %s", fn, commit_hook_str[hook->type]);
if (apk_db_run_script(db, fn, argv) < 0 && hook->type == PRE_COMMIT_HOOK)