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