[yocto] [PATCH] libopkg: Add disable_intercepts option to opkg.conf

Haris Okanovic haris.okanovic at ni.com
Wed Jan 6 15:07:01 PST 2016


When set, this option disables interception and deferral of certain
utilities (E.g. depmod, ldconfig) when called from maintainer scripts
(E.g. postinst). Disabled by default to maintain old behavior.

Append "option disable_intercepts 1" to opkg.conf to set it.

Testing:
 * Installed package containing postinst script and verified
   intercept prep/finalize does not run via DEBUG output.
 * Ran `make check` with option set in the test suite's opkg.conf,
   no additional failures.

Yocto bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8837

Signed-off-by: Haris Okanovic <haris.okanovic at ni.com>
Cc: Alejandro del Castillo <alejandro.delcastillo at ni.com>
Cc: Paul Barker <paul at paulbarker.me.uk>
---
 libopkg/opkg_cmd.c  | 22 ++++++++++++++--------
 libopkg/opkg_conf.c |  1 +
 libopkg/opkg_conf.h |  1 +
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c
index 050e6ec..ff3dcc0 100644
--- a/libopkg/opkg_cmd.c
+++ b/libopkg/opkg_cmd.c
@@ -328,7 +328,7 @@ static int opkg_configure_packages(char *pkg_name)
     pkg_vec_t *all, *ordered, *visited;
     unsigned int i;
     pkg_t *pkg;
-    opkg_intercept_t ic;
+    opkg_intercept_t ic = NULL;
     int r, err = 0;
 
     if (opkg_config->offline_root && !opkg_config->force_postinstall) {
@@ -352,10 +352,13 @@ static int opkg_configure_packages(char *pkg_name)
         opkg_recurse_pkgs_in_order(pkg, all, visited, ordered);
     }
 
-    ic = opkg_prep_intercepts();
-    if (ic == NULL) {
-        err = -1;
-        goto error;
+    if (!opkg_config->disable_intercepts) {
+        ic = opkg_prep_intercepts();
+        if (ic == NULL) {
+            err = -1;
+            goto error;
+        }
+        opkg_msg(DEBUG, "Intercepts enabled; statedir=\"%s\"\n", ic->statedir);
     }
 
     for (i = 0; i < ordered->len; i++) {
@@ -379,9 +382,12 @@ static int opkg_configure_packages(char *pkg_name)
         }
     }
 
-    r = opkg_finalize_intercepts(ic);
-    if (r != 0)
-        err = -1;
+    if (!opkg_config->disable_intercepts) {
+        opkg_msg(DEBUG, "Finalizing intercepts\n");
+        r = opkg_finalize_intercepts(ic);
+        if (r != 0)
+            err = -1;
+    }
 
  error:
     pkg_vec_free(all);
diff --git a/libopkg/opkg_conf.c b/libopkg/opkg_conf.c
index f52a4db..2d2f4f7 100644
--- a/libopkg/opkg_conf.c
+++ b/libopkg/opkg_conf.c
@@ -85,6 +85,7 @@ static opkg_option_t options[] = {
     {"overwrite_no_owner", OPKG_OPT_TYPE_BOOL, &_conf.overwrite_no_owner},
     {"combine", OPKG_OPT_TYPE_BOOL, &_conf.combine},
     {"cache_local_files", OPKG_OPT_TYPE_BOOL, &_conf.cache_local_files},
+    {"disable_intercepts", OPKG_OPT_TYPE_BOOL, &_conf.disable_intercepts},
 #if defined(HAVE_OPENSSL)
     {"signature_ca_file", OPKG_OPT_TYPE_STRING, &_conf.signature_ca_file},
     {"signature_ca_path", OPKG_OPT_TYPE_STRING, &_conf.signature_ca_path},
diff --git a/libopkg/opkg_conf.h b/libopkg/opkg_conf.h
index 7460ca2..5421044 100644
--- a/libopkg/opkg_conf.h
+++ b/libopkg/opkg_conf.h
@@ -107,6 +107,7 @@ typedef struct opkg_conf {
     int volatile_cache;
     int combine;
     int cache_local_files;
+    int disable_intercepts;
     int host_cache_dir;
 
     /* ssl options: used only when opkg is configured with '--enable-curl',
-- 
2.6.2




More information about the yocto mailing list