1From dd11ed66640f79143e42d778b58fdd5a61fb5836 Mon Sep 17 00:00:00 2001 2From: Alexander Kanavin <alex.kanavin@gmail.com> 3Date: Wed, 26 Aug 2015 16:25:45 +0300 4Subject: [PATCH] Our pre/postinsts expect $D to be set when running in a 5 sysroot and don't expect a chroot. This matches up our system expectations 6 with what dpkg does. 7 8Upstream-Status: Inappropriate [OE Specific] 9 10RP 2011/12/07 11ALIMON 2016/05/26 12ALIMON 2017/02/21 13KKang 2019/02/20 14--- 15 src/main/script.c | 54 +++-------------------------------------------- 16 1 file changed, 3 insertions(+), 51 deletions(-) 17 18diff --git a/src/main/script.c b/src/main/script.c 19index abe65b6..0edb8f1 100644 20--- a/src/main/script.c 21+++ b/src/main/script.c 22@@ -96,58 +96,10 @@ setexecute(const char *path, struct stat *stab) 23 static const char * 24 maintscript_pre_exec(struct command *cmd) 25 { 26- const char *admindir = dpkg_db_get_dir(); 27- const char *changedir; 28- size_t instdirlen = strlen(instdir); 29- 30- if (instdirlen > 0 && in_force(FORCE_SCRIPT_CHROOTLESS)) 31- changedir = instdir; 32- else 33- changedir = "/"; 34- 35- if (instdirlen > 0 && !in_force(FORCE_SCRIPT_CHROOTLESS)) { 36- int rc; 37- 38- if (strncmp(admindir, instdir, instdirlen) != 0) 39- ohshit(_("admindir must be inside instdir for dpkg to work properly")); 40- if (setenv("DPKG_ADMINDIR", admindir + instdirlen, 1) < 0) 41- ohshite(_("unable to setenv for subprocesses")); 42- if (setenv("DPKG_ROOT", "", 1) < 0) 43- ohshite(_("unable to setenv for subprocesses")); 44- 45- rc = chroot(instdir); 46- if (rc && in_force(FORCE_NON_ROOT) && errno == EPERM) 47- ohshit(_("not enough privileges to change root " 48- "directory with --force-not-root, consider " 49- "using --force-script-chrootless?")); 50- else if (rc) 51- ohshite(_("failed to chroot to '%.250s'"), instdir); 52- } 53- /* Switch to a known good directory to give the maintainer script 54- * a saner environment, also needed after the chroot(). */ 55- if (chdir(changedir)) 56- ohshite(_("failed to chdir to '%.255s'"), changedir); 57- if (debug_has_flag(dbg_scripts)) { 58- struct varbuf args = VARBUF_INIT; 59- const char **argv = cmd->argv; 60- 61- while (*++argv) { 62- varbuf_add_char(&args, ' '); 63- varbuf_add_str(&args, *argv); 64- } 65- varbuf_end_str(&args); 66- debug(dbg_scripts, "fork/exec %s (%s )", cmd->filename, 67- args.buf); 68- varbuf_destroy(&args); 69+ if (*instdir) { 70+ setenv("D", instdir, 1); 71 } 72- if (instdirlen == 0 || in_force(FORCE_SCRIPT_CHROOTLESS)) 73- return cmd->filename; 74- 75- if (strlen(cmd->filename) < instdirlen) 76- internerr("maintscript name '%s' length < instdir length %zd", 77- cmd->filename, instdirlen); 78- 79- return cmd->filename + instdirlen; 80+ return cmd->filename; 81 } 82 83 /** 84-- 852.25.1 86 87