blob: 93d870443c7992f04a4e008b857cbbcff34f0dae [file] [log] [blame]
From 24229971492515b64c81e8c6392e5dfbdc22b44c Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Wed, 26 Aug 2015 16:25:45 +0300
Subject: [PATCH 3/5] Our pre/postinsts expect $D to be set when running in a
sysroot and don't expect a chroot. This matches up our system expectations
with what dpkg does.
Upstream-Status: Inappropriate [OE Specific]
RP 2011/12/07
ALIMON 2016/05/26
ALIMON 2017/02/21
---
src/script.c | 44 +++-----------------------------------------
1 file changed, 3 insertions(+), 41 deletions(-)
diff --git a/src/script.c b/src/script.c
index 2f252ae..768a9d1 100644
--- a/src/script.c
+++ b/src/script.c
@@ -97,48 +97,10 @@ setexecute(const char *path, struct stat *stab)
static const char *
maintscript_pre_exec(struct command *cmd)
{
- const char *admindir = dpkg_db_get_dir();
- const char *changedir;
- size_t instdirlen = strlen(instdir);
-
- if (instdirlen > 0 && fc_script_chrootless)
- changedir = instdir;
- else
- changedir = "/";
-
- if (instdirlen > 0 && !fc_script_chrootless) {
- if (strncmp(admindir, instdir, instdirlen) != 0)
- ohshit(_("admindir must be inside instdir for dpkg to work properly"));
- if (setenv("DPKG_ADMINDIR", admindir + instdirlen, 1) < 0)
- ohshite(_("unable to setenv for subprocesses"));
- if (setenv("DPKG_ROOT", "", 1) < 0)
- ohshite(_("unable to setenv for subprocesses"));
-
- if (chroot(instdir))
- ohshite(_("failed to chroot to '%.250s'"), instdir);
+ if (*instdir) {
+ setenv("D", instdir, 1);
}
- /* Switch to a known good directory to give the maintainer script
- * a saner environment, also needed after the chroot(). */
- if (chdir(changedir))
- ohshite(_("failed to chdir to '%.255s'"), changedir);
- if (debug_has_flag(dbg_scripts)) {
- struct varbuf args = VARBUF_INIT;
- const char **argv = cmd->argv;
-
- while (*++argv) {
- varbuf_add_char(&args, ' ');
- varbuf_add_str(&args, *argv);
- }
- varbuf_end_str(&args);
- debug(dbg_scripts, "fork/exec %s (%s )", cmd->filename,
- args.buf);
- varbuf_destroy(&args);
- }
- if (instdirlen == 0 || fc_script_chrootless)
- return cmd->filename;
-
- assert(strlen(cmd->filename) >= instdirlen);
- return cmd->filename + instdirlen;
+ return cmd->filename;
}
/**
--
2.1.4