summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm-4.11.2/rpm-scriptetexechelp.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/rpm/rpm-4.11.2/rpm-scriptetexechelp.patch')
-rw-r--r--meta/recipes-devtools/rpm/rpm-4.11.2/rpm-scriptetexechelp.patch194
1 files changed, 194 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rpm/rpm-4.11.2/rpm-scriptetexechelp.patch b/meta/recipes-devtools/rpm/rpm-4.11.2/rpm-scriptetexechelp.patch
new file mode 100644
index 0000000000..9333dea441
--- /dev/null
+++ b/meta/recipes-devtools/rpm/rpm-4.11.2/rpm-scriptetexechelp.patch
@@ -0,0 +1,194 @@
1Upstream-Status: Inappropriate [OE-Core]
2
3Signed-off-by: Saul Wold <sgw@linux.intel.com>
4Signed-off-by: Ronan Le Martret <ronan.lemartret@open.eurogiciel.org>
5
6
7Index: rpm-4.11.2/lib/psm.c
8===================================================================
9--- rpm-4.11.2.orig/lib/psm.c
10+++ rpm-4.11.2/lib/psm.c
11@@ -421,7 +421,8 @@ static rpmRC runScript(rpmpsm psm, ARGV_
12
13 rpmswEnter(rpmtsOp(psm->ts, RPMTS_OP_SCRIPTLETS), 0);
14 rc = rpmScriptRun(script, arg1, arg2, sfd,
15- prefixes, warn_only, selinux);
16+ prefixes, warn_only, selinux, rpmtsRootDir(psm->ts) );
17+
18 rpmswExit(rpmtsOp(psm->ts, RPMTS_OP_SCRIPTLETS), 0);
19
20 /* Map warn-only errors to "notfound" for script stop callback */
21@@ -958,15 +959,49 @@ static rpmRC rpmpsmStage(rpmpsm psm, pkg
22 case PSM_DESTROY:
23 break;
24 case PSM_SCRIPT: /* Run current package scriptlets. */
25+#ifdef RPM_VENDOR_OE
26+ {
27+ const char * scriptletWrapper = rpmExpand("%{?_cross_scriptlet_wrapper}", NULL);
28+ if (scriptletWrapper && *scriptletWrapper)
29+ (void) rpmChrootOut();
30+#endif
31+
32 rc = runInstScript(psm);
33+#ifdef RPM_VENDOR_OE
34+ if (scriptletWrapper && *scriptletWrapper)
35+ (void) rpmChrootIn();
36+ }
37+#endif
38 break;
39 case PSM_TRIGGERS:
40 /* Run triggers in other package(s) this package sets off. */
41+#ifdef RPM_VENDOR_OE
42+ {
43+ const char * scriptletWrapper = rpmExpand("%{?_cross_scriptlet_wrapper}", NULL);
44+ if (scriptletWrapper && *scriptletWrapper)
45+ (void) rpmChrootOut();
46+#endif
47 rc = runTriggers(psm);
48+#ifdef RPM_VENDOR_OE
49+ if (scriptletWrapper && *scriptletWrapper)
50+ (void) rpmChrootIn();
51+ }
52+#endif
53 break;
54 case PSM_IMMED_TRIGGERS:
55 /* Run triggers in this package other package(s) set off. */
56+#ifdef RPM_VENDOR_OE
57+ {
58+ const char * scriptletWrapper = rpmExpand("%{?_cross_scriptlet_wrapper}", NULL);
59+ if (scriptletWrapper && *scriptletWrapper)
60+ (void) rpmChrootOut();
61+#endif
62 rc = runImmedTriggers(psm);
63+#ifdef RPM_VENDOR_OE
64+ if (scriptletWrapper && *scriptletWrapper)
65+ (void) rpmChrootIn();
66+ }
67+#endif
68 break;
69
70 case PSM_RPMDB_ADD: {
71Index: rpm-4.11.2/lib/rpmscript.c
72===================================================================
73--- rpm-4.11.2.orig/lib/rpmscript.c
74+++ rpm-4.11.2/lib/rpmscript.c
75@@ -92,7 +92,7 @@ static rpmRC runLuaScript(int selinux, A
76 static const char * const SCRIPT_PATH = "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin";
77
78 static void doScriptExec(int selinux, ARGV_const_t argv, ARGV_const_t prefixes,
79- FD_t scriptFd, FD_t out)
80+ FD_t scriptFd, FD_t out, char * rootDir )
81 {
82 int pipes[2];
83 int flag;
84@@ -158,13 +158,12 @@ static void doScriptExec(int selinux, AR
85 setenv("RPM_INSTALL_PREFIX", *pf, 1);
86 }
87 }
88-
89- if (chdir("/") == 0) {
90+ if (chdir(rootDir) == 0) {
91 /* XXX Don't mtrace into children. */
92 unsetenv("MALLOC_CHECK_");
93
94 /* Permit libselinux to do the scriptlet exec. */
95- if (selinux == 1) {
96+ if (selinux == 1) {
97 xx = rpm_execcon(0, argv[0], argv, environ);
98 }
99
100@@ -175,12 +174,12 @@ static void doScriptExec(int selinux, AR
101 _exit(127); /* exit 127 for compatibility with bash(1) */
102 }
103
104-static char * writeScript(const char *cmd, const char *script)
105+static char * writeScript(const char *cmd, const char *script, char * rootDir)
106 {
107 char *fn = NULL;
108 size_t slen = strlen(script);
109 int ok = 0;
110- FD_t fd = rpmMkTempFile("/", &fn);
111+ FD_t fd = rpmMkTempFile(rootDir, &fn);
112
113 if (Ferror(fd))
114 goto exit;
115@@ -204,7 +203,7 @@ exit:
116 */
117 static rpmRC runExtScript(int selinux, ARGV_const_t prefixes,
118 const char *sname, rpmlogLvl lvl, FD_t scriptFd,
119- ARGV_t * argvp, const char *script, int arg1, int arg2)
120+ ARGV_t * argvp, const char *script, int arg1, int arg2,char * rootDir)
121 {
122 FD_t out = NULL;
123 char * fn = NULL;
124@@ -215,7 +214,7 @@ static rpmRC runExtScript(int selinux, A
125 rpmlog(RPMLOG_DEBUG, "%s: scriptlet start\n", sname);
126
127 if (script) {
128- fn = writeScript(*argvp[0], script);
129+ fn = writeScript(*argvp[0], script, rootDir);
130 if (fn == NULL) {
131 rpmlog(RPMLOG_ERR,
132 _("Couldn't create temporary file for %s: %s\n"),
133@@ -258,7 +257,7 @@ static rpmRC runExtScript(int selinux, A
134 } else if (pid == 0) {/* Child */
135 rpmlog(RPMLOG_DEBUG, "%s: execv(%s) pid %d\n",
136 sname, *argvp[0], (unsigned)getpid());
137- doScriptExec(selinux, *argvp, prefixes, scriptFd, out);
138+ doScriptExec(selinux, *argvp, prefixes, scriptFd, out, rootDir);
139 }
140
141 do {
142@@ -297,13 +296,27 @@ exit:
143 }
144
145 rpmRC rpmScriptRun(rpmScript script, int arg1, int arg2, FD_t scriptFd,
146- ARGV_const_t prefixes, int warn_only, int selinux)
147+ ARGV_const_t prefixes, int warn_only, int selinux, char * rootDir)
148 {
149 ARGV_t args = NULL;
150 rpmlogLvl lvl = warn_only ? RPMLOG_WARNING : RPMLOG_ERR;
151 rpmRC rc;
152-
153- if (script == NULL) return RPMRC_OK;
154+#ifdef RPM_VENDOR_OE
155+ const char * scriptletWrapper = rpmExpand("%{?_cross_scriptlet_wrapper}", NULL);
156+#endif
157+
158+ if (script == NULL) return RPMRC_OK;
159+#ifdef RPM_VENDOR_OE
160+ if (scriptletWrapper && *scriptletWrapper) {
161+ argvAdd(&args, scriptletWrapper);
162+
163+ if ( rootDir ) {
164+ argvAdd(&args, rootDir);
165+ } else {
166+ argvAdd(&args, "/");
167+ }
168+ }
169+#endif
170
171 /* construct a new argv as we can't modify the one from header */
172 if (script->args) {
173@@ -315,7 +328,7 @@ rpmRC rpmScriptRun(rpmScript script, int
174 if (rstreq(args[0], "<lua>")) {
175 rc = runLuaScript(selinux, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2);
176 } else {
177- rc = runExtScript(selinux, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2);
178+ rc = runExtScript(selinux, prefixes, script->descr, lvl, scriptFd, &args, script->body, arg1, arg2, rootDir);
179 }
180 argvFree(args);
181
182Index: rpm-4.11.2/lib/rpmscript.h
183===================================================================
184--- rpm-4.11.2.orig/lib/rpmscript.h
185+++ rpm-4.11.2/lib/rpmscript.h
186@@ -29,7 +29,7 @@ rpmScript rpmScriptFree(rpmScript script
187
188 RPM_GNUC_INTERNAL
189 rpmRC rpmScriptRun(rpmScript script, int arg1, int arg2, FD_t scriptFd,
190- ARGV_const_t prefixes, int warn_only, int selinux);
191+ ARGV_const_t prefixes, int warn_only, int selinux, char * rootDir);
192
193 RPM_GNUC_INTERNAL
194 rpmTagVal rpmScriptTag(rpmScript script);