blob: 4020a3109267e843df7f2026539ee94bcb1b173f [file] [log] [blame]
Brad Bishopd5ae7d92018-06-14 09:52:03 -07001From a89daa75ac970d8e247edc762d1181e9a5b0c5d0 Mon Sep 17 00:00:00 2001
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Tue, 17 Jan 2017 14:07:17 +0200
4Subject: [PATCH] When cross-installing, execute package scriptlets without
5 chrooting into destination rootfs
6
7This is triggered only when RPM_NO_CHROOT_FOR_SCRIPTS environment variable is defined.
8Otherwise they will trigger an explosion of failures, obviously.
9
Brad Bishopd5ae7d92018-06-14 09:52:03 -070010Amended 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 Bishop6e60e8b2018-02-01 10:27:11 -050025Upstream-Status: Inappropriate [oe-core specific]
26Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
27---
Brad Bishopd5ae7d92018-06-14 09:52:03 -070028 lib/rpmscript.c | 11 ++++++++---
29 1 file changed, 8 insertions(+), 3 deletions(-)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030
31diff --git a/lib/rpmscript.c b/lib/rpmscript.c
Brad Bishopd5ae7d92018-06-14 09:52:03 -070032index cc98c4885..f8bd3df04 100644
Brad Bishop6e60e8b2018-02-01 10:27:11 -050033--- a/lib/rpmscript.c
34+++ b/lib/rpmscript.c
Brad Bishopd5ae7d92018-06-14 09:52:03 -070035@@ -394,8 +394,7 @@ exit:
36 Fclose(out); /* XXX dup'd STDOUT_FILENO */
37
38 if (fn) {
39- if (!rpmIsDebug())
40- unlink(fn);
41+ unlink(fn);
42 free(fn);
43 }
44 free(mline);
45@@ -428,7 +427,13 @@ rpmRC rpmScriptRun(rpmScript script, int arg1, int arg2, FD_t scriptFd,
Brad Bishop6e60e8b2018-02-01 10:27:11 -050046
47 if (rc != RPMRC_FAIL) {
48 if (script_type & RPMSCRIPTLET_EXEC) {
49- rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc);
50+ if (getenv("RPM_NO_CHROOT_FOR_SCRIPTS") != NULL) {
51+ rpmChrootOut();
52+ rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc);
53+ rpmChrootIn();
54+ } else {
55+ rc = runExtScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc);
56+ }
57 } else {
58 rc = runLuaScript(plugins, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, &script->nextFileFunc);
59 }
60--
612.11.0
62