blob: 80504ce8b9bb8fb96529053bd750f5ae16eb7455 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001From 24229971492515b64c81e8c6392e5dfbdc22b44c 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 3/5] 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
Patrick Williamsc0f7c042017-02-23 20:41:17 -060011ALIMON 2016/05/26
12
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013---
Patrick Williamsc0f7c042017-02-23 20:41:17 -060014 src/script.c | 39 +++------------------------------------
15 1 file changed, 3 insertions(+), 36 deletions(-)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016
17diff --git a/src/script.c b/src/script.c
Patrick Williamsc0f7c042017-02-23 20:41:17 -060018index 3c88be8..ce66a86 100644
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019--- a/src/script.c
20+++ b/src/script.c
Patrick Williamsc0f7c042017-02-23 20:41:17 -060021@@ -97,43 +97,10 @@ setexecute(const char *path, struct stat *stab)
22 static const char *
23 maintscript_pre_exec(struct command *cmd)
24 {
25- const char *admindir = dpkg_db_get_dir();
26- const char *changedir = fc_script_chrootless ? instdir : "/";
27- size_t instdirl = strlen(instdir);
28-
29- if (*instdir && !fc_script_chrootless) {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030- if (strncmp(admindir, instdir, instdirl) != 0)
31- ohshit(_("admindir must be inside instdir for dpkg to work properly"));
32- if (setenv("DPKG_ADMINDIR", admindir + instdirl, 1) < 0)
33- ohshite(_("unable to setenv for subprocesses"));
Patrick Williamsc0f7c042017-02-23 20:41:17 -060034- if (setenv("DPKG_ROOT", "", 1) < 0)
35- ohshite(_("unable to setenv for subprocesses"));
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036-
37- if (chroot(instdir))
38- ohshite(_("failed to chroot to '%.250s'"), instdir);
Patrick Williamsc0f7c042017-02-23 20:41:17 -060039+ if (*instdir) {
40+ setenv("D", instdir, 1);
41 }
Patrick Williamsc124f4f2015-09-15 14:41:29 -050042- /* Switch to a known good directory to give the maintainer script
43- * a saner environment, also needed after the chroot(). */
Patrick Williamsc0f7c042017-02-23 20:41:17 -060044- if (chdir(changedir))
45- ohshite(_("failed to chdir to '%.255s'"), changedir);
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046- if (debug_has_flag(dbg_scripts)) {
47- struct varbuf args = VARBUF_INIT;
48- const char **argv = cmd->argv;
49-
50- while (*++argv) {
51- varbuf_add_char(&args, ' ');
52- varbuf_add_str(&args, *argv);
53- }
54- varbuf_end_str(&args);
55- debug(dbg_scripts, "fork/exec %s (%s )", cmd->filename,
56- args.buf);
57- varbuf_destroy(&args);
Patrick Williamsc0f7c042017-02-23 20:41:17 -060058- }
59- if (!instdirl || fc_script_chrootless)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060- return cmd->filename;
61-
62- assert(strlen(cmd->filename) >= instdirl);
63- return cmd->filename + instdirl;
64+ return cmd->filename;
65 }
66
67 /**
68--
692.1.4
70