Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 1 | From a89daa75ac970d8e247edc762d1181e9a5b0c5d0 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 2 | From: Alexander Kanavin <alex.kanavin@gmail.com> |
| 3 | Date: Tue, 17 Jan 2017 14:07:17 +0200 |
| 4 | Subject: [PATCH] When cross-installing, execute package scriptlets without |
| 5 | chrooting into destination rootfs |
| 6 | |
| 7 | This is triggered only when RPM_NO_CHROOT_FOR_SCRIPTS environment variable is defined. |
| 8 | Otherwise they will trigger an explosion of failures, obviously. |
| 9 | |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 10 | Amended 2018-07-03 by Olof Johansson <olofjn@axis.com>: |
| 11 | |
| 12 | Remove leaking temporary scriptlet files |
| 13 | |
| 14 | Since we tell dnf to run rpm with debug output, this will result in rpm not |
| 15 | cleaning up written temporary scriptlet files (same flag controls both |
| 16 | behaviors). This wouldn't have been a problem since we normally would use the |
| 17 | target sysroot also for temporary files, but we need to chroot out to be able |
| 18 | to actually run the rpm scriptlets (purpose of this patch), so the temporary |
| 19 | files are written to the host's /var/tmp/ directory, causing a gradual |
| 20 | resource leakage on the host system for every RPM based do_rootfs task |
| 21 | executed. |
| 22 | |
| 23 | Signed-off-by: Olof Johansson <olofjn@axis.com> |
| 24 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 25 | Upstream-Status: Inappropriate [oe-core specific] |
| 26 | Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> |
| 27 | --- |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 28 | lib/rpmscript.c | 11 ++++++++--- |
| 29 | 1 file changed, 8 insertions(+), 3 deletions(-) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 30 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 31 | --- a/lib/rpmscript.c |
| 32 | +++ b/lib/rpmscript.c |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 33 | @@ -17,7 +17,7 @@ |
| 34 | #include "rpmio/rpmio_internal.h" |
| 35 | |
| 36 | #include "lib/rpmplugins.h" /* rpm plugins hooks */ |
| 37 | - |
| 38 | +#include "lib/rpmchroot.h" /* rpmChrootOut */ |
| 39 | #include "debug.h" |
| 40 | |
| 41 | struct scriptNextFileFunc_s { |
| 42 | @@ -391,8 +391,7 @@ exit: |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 43 | Fclose(out); /* XXX dup'd STDOUT_FILENO */ |
| 44 | |
| 45 | if (fn) { |
| 46 | - if (!rpmIsDebug()) |
| 47 | - unlink(fn); |
| 48 | + unlink(fn); |
| 49 | free(fn); |
| 50 | } |
| 51 | free(mline); |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 52 | @@ -426,7 +425,13 @@ rpmRC rpmScriptRun(rpmScript script, int |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 53 | |
| 54 | if (rc != RPMRC_FAIL) { |
| 55 | if (script_type & RPMSCRIPTLET_EXEC) { |
| 56 | - rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc); |
| 57 | + if (getenv("RPM_NO_CHROOT_FOR_SCRIPTS") != NULL) { |
| 58 | + rpmChrootOut(); |
| 59 | + rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc); |
| 60 | + rpmChrootIn(); |
| 61 | + } else { |
| 62 | + rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc); |
| 63 | + } |
| 64 | } else { |
| 65 | rc = runLuaScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc); |
| 66 | } |