11 #define _RPMEVR_INTERNAL
22 const char *script,
const char *
prog)
36 index = last->
index + 1;
41 tfe->
script = (script && *script !=
'\0') ?
xstrdup(script) : NULL;
56 static const char *
name = NULL;
58 static const char *
prog = NULL;
60 static const char *
file = NULL;
63 { NULL,
'p', POPT_ARG_STRING, &
prog,
'p', NULL, NULL},
64 { NULL,
'n', POPT_ARG_STRING, &
name,
'n', NULL, NULL},
65 { NULL,
'f', POPT_ARG_STRING, &
file,
'f', NULL, NULL},
66 { 0, 0, 0, 0, 0, NULL, NULL}
76 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
87 const char **progArgv = NULL;
89 char *partname = NULL;
102 const char **argv = NULL;
103 poptContext optCon = NULL;
116 tagflags = RPMSENSE_SCRIPT_PRE;
122 tagflags = RPMSENSE_SCRIPT_POST;
128 tagflags = RPMSENSE_SCRIPT_PREUN;
134 tagflags = RPMSENSE_SCRIPT_POSTUN;
136 partname =
"%postun";
142 partname =
"%pretrans";
148 partname =
"%posttrans";
152 tagflags = RPMSENSE_SCRIPT_VERIFY;
154 partname =
"%verifyscript";
161 partname =
"%triggerprein";
168 partname =
"%triggerin";
175 partname =
"%triggerun";
182 partname =
"%triggerpostun";
187 tagflags = RPMSENSE_SCRIPT_SANITYCHECK;
189 partname =
"%sanitycheck";
195 p = strstr(spec->
line,
"--");
203 strcpy(reqargs, p + 2);
206 if ((rc = poptParseArgvString(spec->
line, &argc, &argv))) {
208 spec->
lineNum, partname, poptStrerror(rc));
212 optCon = poptGetContext(NULL, argc, argv,
optionsTable, 0);
213 while ((arg = poptGetNextOpt(optCon)) > 0) {
216 if (
prog[0] ==
'<') {
219 _(
"line %d: internal script must end "
224 }
else if (
prog[0] ==
'%') {
226 }
else if (
prog[0] !=
'/') {
228 _(
"line %d: script program must begin "
243 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
249 if (poptPeekArg(optCon)) {
252 name = poptGetArg(optCon);
254 if (poptPeekArg(optCon)) {
279 if ((rc = poptParseArgvString(
prog, &progArgc, &progArgv))) {
281 spec->
lineNum, partname, poptStrerror(rc));
306 if (!strcmp(progArgv[0],
"<lua>")) {
313 "BuiltinLuaScripts",
"4.2.2-1");
317 if (!strcmp(progArgv[0],
"<ficl>")) {
319 "BuiltinFiclScripts",
"5.2-1");
323 if (!strcmp(progArgv[0],
"<js>")) {
325 "BuiltinJavaScript",
"5.2-1");
328 #ifdef WITH_PERLEMBED
329 if (!strcmp(progArgv[0],
"<perl>")) {
331 "BuiltinPerlScripts",
"5.2-1");
334 #ifdef WITH_PYTHONEMBED
335 if (!strcmp(progArgv[0],
"<python>")) {
337 "BuiltinPythonScripts",
"5.2-1");
340 #ifdef WITH_RUBYEMBED
341 if (!strcmp(progArgv[0],
"<ruby>")) {
343 "BuiltinRubyScripts",
"5.2-1");
347 if (!strcmp(progArgv[0],
"<tcl>")) {
349 "BuiltinTclScripts",
"5.2-1");
352 if (progArgv[0][0] ==
'<') {
354 _(
"line %d: unsupported internal script: %s\n"),
360 && !strcmp(progArgv[0],
"/bin/sh")))
364 progArgv[0], NULL, (tagflags | RPMSENSE_INTERP), 0);
374 if ((rc =
parseRCPOT(spec, pkg, reqargs, reqtag, index, tagflags)))
380 he->
p.
str = *progArgv;
385 "ScriptletInterpreterArgs",
"4.0.3-1");
388 he->
p.
argv = progArgv;
430 rc = (
rpmRC) nextPart;
434 progArgv =
_free(progArgv);
436 optCon = poptFreeContext(optCon);