Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | From 24229971492515b64c81e8c6392e5dfbdc22b44c Mon Sep 17 00:00:00 2001 |
| 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Wed, 26 Aug 2015 16:25:45 +0300 |
| 4 | Subject: [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 | |
| 8 | Upstream-Status: Inappropriate [OE Specific] |
| 9 | |
| 10 | RP 2011/12/07 |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 11 | ALIMON 2016/05/26 |
| 12 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | --- |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 14 | src/script.c | 39 +++------------------------------------ |
| 15 | 1 file changed, 3 insertions(+), 36 deletions(-) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | |
| 17 | diff --git a/src/script.c b/src/script.c |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 18 | index 3c88be8..ce66a86 100644 |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 19 | --- a/src/script.c |
| 20 | +++ b/src/script.c |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 21 | @@ -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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | - 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 34 | - if (setenv("DPKG_ROOT", "", 1) < 0) |
| 35 | - ohshite(_("unable to setenv for subprocesses")); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | - |
| 37 | - if (chroot(instdir)) |
| 38 | - ohshite(_("failed to chroot to '%.250s'"), instdir); |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 39 | + if (*instdir) { |
| 40 | + setenv("D", instdir, 1); |
| 41 | } |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 42 | - /* Switch to a known good directory to give the maintainer script |
| 43 | - * a saner environment, also needed after the chroot(). */ |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 44 | - if (chdir(changedir)) |
| 45 | - ohshite(_("failed to chdir to '%.255s'"), changedir); |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | - 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame^] | 58 | - } |
| 59 | - if (!instdirl || fc_script_chrootless) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 60 | - return cmd->filename; |
| 61 | - |
| 62 | - assert(strlen(cmd->filename) >= instdirl); |
| 63 | - return cmd->filename + instdirl; |
| 64 | + return cmd->filename; |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | -- |
| 69 | 2.1.4 |
| 70 | |