Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [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 |
| 11 | ALIMON 2016/05/26 |
| 12 | ALIMON 2017/02/21 |
| 13 | --- |
| 14 | src/script.c | 44 +++----------------------------------------- |
| 15 | 1 file changed, 3 insertions(+), 41 deletions(-) |
| 16 | |
| 17 | diff --git a/src/script.c b/src/script.c |
| 18 | index 2f252ae..768a9d1 100644 |
| 19 | --- a/src/script.c |
| 20 | +++ b/src/script.c |
| 21 | @@ -97,48 +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; |
| 27 | - size_t instdirlen = strlen(instdir); |
| 28 | - |
| 29 | - if (instdirlen > 0 && fc_script_chrootless) |
| 30 | - changedir = instdir; |
| 31 | - else |
| 32 | - changedir = "/"; |
| 33 | - |
| 34 | - if (instdirlen > 0 && !fc_script_chrootless) { |
| 35 | - if (strncmp(admindir, instdir, instdirlen) != 0) |
| 36 | - ohshit(_("admindir must be inside instdir for dpkg to work properly")); |
| 37 | - if (setenv("DPKG_ADMINDIR", admindir + instdirlen, 1) < 0) |
| 38 | - ohshite(_("unable to setenv for subprocesses")); |
| 39 | - if (setenv("DPKG_ROOT", "", 1) < 0) |
| 40 | - ohshite(_("unable to setenv for subprocesses")); |
| 41 | - |
| 42 | - if (chroot(instdir)) |
| 43 | - ohshite(_("failed to chroot to '%.250s'"), instdir); |
| 44 | + if (*instdir) { |
| 45 | + setenv("D", instdir, 1); |
| 46 | } |
| 47 | - /* Switch to a known good directory to give the maintainer script |
| 48 | - * a saner environment, also needed after the chroot(). */ |
| 49 | - if (chdir(changedir)) |
| 50 | - ohshite(_("failed to chdir to '%.255s'"), changedir); |
| 51 | - if (debug_has_flag(dbg_scripts)) { |
| 52 | - struct varbuf args = VARBUF_INIT; |
| 53 | - const char **argv = cmd->argv; |
| 54 | - |
| 55 | - while (*++argv) { |
| 56 | - varbuf_add_char(&args, ' '); |
| 57 | - varbuf_add_str(&args, *argv); |
| 58 | - } |
| 59 | - varbuf_end_str(&args); |
| 60 | - debug(dbg_scripts, "fork/exec %s (%s )", cmd->filename, |
| 61 | - args.buf); |
| 62 | - varbuf_destroy(&args); |
| 63 | - } |
| 64 | - if (instdirlen == 0 || fc_script_chrootless) |
| 65 | - return cmd->filename; |
| 66 | - |
| 67 | - assert(strlen(cmd->filename) >= instdirlen); |
| 68 | - return cmd->filename + instdirlen; |
| 69 | + return cmd->filename; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | -- |
| 74 | 2.1.4 |
| 75 | |