[PATCH] dpkg: Add --no-scripts
Allows installing a package without running maintscripts but still mark
as fully installed
---
man/dpkg.pod | 4 ++++
src/main.c | 3 +++
src/main.h | 1 +
src/script.c | 24 ++++++++++++++++++++++++
4 files changed, 32 insertions(+)
diff --git a/man/dpkg.pod b/man/dpkg.pod
index 712f4608f..a7a1e152b 100644
--- a/man/dpkg.pod
+++ b/man/dpkg.pod
@@ -1023,6 +1023,10 @@ output will be modified to make it easier to parse.
The only currently supported command is B<--version>.
+=item B<--no-scripts>
+
+Skips the running of maintainer scripts but still marks the package as fully installed
+
=item B<--no-pager>
Disables the use of any pager when showing information (since dpkg 1.19.2).
diff --git a/src/main.c b/src/main.c
index 04b5799f8..4ba0eb1cc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -171,6 +171,7 @@ usage(const struct cmdinfo *ci, const char *value)
" --refuse-<thing>[,...] Ditto.\n"
" --abort-after <n> Abort after encountering <n> errors.\n"
" --robot Use machine-readable output on some commands.\n"
+" --no-scripts Do not run any maintainer scripts\n"
"\n"), ADMINDIR);
printf(_(
@@ -198,6 +199,7 @@ static const char printforhelp[] = N_(
"Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !");
int f_robot = 0;
+int f_noscripts = 0;
int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0;
int f_autodeconf=0, f_nodebsig=0;
int f_triggers = 0;
@@ -607,6 +609,7 @@ static const struct cmdinfo cmdinfos[]= {
{ "skip-same-version", 'E', 0, &f_skipsame, NULL, NULL, 1 },
{ "auto-deconfigure", 'B', 0, &f_autodeconf, NULL, NULL, 1 },
{ "robot", 0, 0, &f_robot, NULL, NULL, 1 },
+ { "no-scripts", 0, 0, &f_noscripts, NULL, NULL, 1 },
{ "root", 0, 1, NULL, NULL, set_root, 0 },
{ "abort-after", 0, 1, &errabort, NULL, set_integer, 0 },
{ "admindir", 0, 1, NULL, &admindir, NULL, 0 },
diff --git a/src/main.h b/src/main.h
index e7fe820a7..e45ee3bc2 100644
--- a/src/main.h
+++ b/src/main.h
@@ -124,6 +124,7 @@ enum action {
extern const char *const statusstrings[];
extern int f_robot;
+extern int f_noscripts;
extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
extern int f_autodeconf, f_nodebsig;
extern int f_triggers;
diff --git a/src/script.c b/src/script.c
index abe65b6f7..37397c6c4 100644
--- a/src/script.c
+++ b/src/script.c
@@ -230,6 +230,14 @@ vmaintscript_installed(struct pkginfo *pkg, const char *scriptname,
command_add_arg(&cmd, scriptname);
command_add_argv(&cmd, args);
+ if (f_noscripts) {
+ command_destroy(&cmd);
+ debug(dbg_scripts,
+ "vmaintscript_installed skipping %s",
+ scriptname);
+ free(buf);
+ return 0;
+ }
if (stat(scriptpath, &stab)) {
command_destroy(&cmd);
@@ -306,6 +314,14 @@ maintscript_new(struct pkginfo *pkg, const char *scriptname,
command_add_argv(&cmd, args);
va_end(args);
+ if (f_noscripts) {
+ command_destroy(&cmd);
+ debug(dbg_scripts,
+ "maintscript_new skipping %s",
+ scriptname);
+ free(buf);
+ return 0;
+ }
if (stat(cidir, &stab)) {
command_destroy(&cmd);
@@ -347,6 +363,14 @@ maintscript_fallback(struct pkginfo *pkg,
versiondescribe(&pkg->available.version, vdew_nonambig),
NULL);
+ if (f_noscripts) {
+ debug(dbg_scripts,
+ "maintscript_fallback skipping %s",
+ scriptname);
+ command_destroy(&cmd);
+ free(buf);
+ return 0;
+ }
if (stat(oldscriptpath, &stab)) {
if (errno == ENOENT) {
debug(dbg_scripts,
--
2.31.0
Reply to: