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}
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";
189 partname =
"%triggerpretransin";
196 partname =
"%triggerpretransun";
203 partname =
"%triggerposttransin";
210 partname =
"%triggerposttransun";
215 tagflags = RPMSENSE_SCRIPT_SANITYCHECK;
217 partname =
"%sanitycheck";
223 p = strstr(spec->
line,
"--");
231 strcpy(reqargs, p + 2);
234 if ((rc = poptParseArgvString(spec->
line, &argc, &argv))) {
236 spec->
lineNum, partname, poptStrerror(rc));
240 optCon = poptGetContext(NULL, argc, argv,
optionsTable, 0);
241 while ((arg = poptGetNextOpt(optCon)) > 0) {
244 if (
prog[0] ==
'<') {
245 const char * s =
prog;
246 while (s && s[1] && s[1] !=
'>')
250 _(
"line %d: embedded interpreter token must end " 255 }
else if (
prog[0] ==
'%') {
257 }
else if (
prog[0] !=
'/') {
259 _(
"line %d: script program must begin " 274 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
280 if (poptPeekArg(optCon)) {
283 name = poptGetArg(optCon);
285 if (poptPeekArg(optCon)) {
310 if ((rc = poptParseArgvString(
prog, &progArgc, &progArgv))) {
312 spec->
lineNum, partname, poptStrerror(rc));
337 #define SO_EXT "()(64bit)" 343 if (!strcmp(progArgv[0],
"<lua>")) {
350 "BuiltinLuaScripts",
"4.2.2-1");
354 if (!strcmp(progArgv[0],
"<augeas>")) {
356 "BuiltinAugeasScripts",
"5.3-1");
360 if (!strcmp(progArgv[0],
"<ficl>")) {
362 "BuiltinFiclScripts",
"5.2-1");
366 if (!strcmp(progArgv[0],
"<js>")) {
368 "BuiltinJavaScript",
"5.2-1");
371 #ifdef WITH_PERLEMBED 372 if (!strcmp(progArgv[0],
"<perl>")) {
374 "BuiltinPerlScripts",
"5.2-1");
378 #ifdef WITH_PYTHONEMBED 379 if (!strcmp(progArgv[0],
"<python>")) {
381 "BuiltinPythonScripts",
"5.2-1");
385 #ifdef WITH_RUBYEMBED 386 if (!strcmp(progArgv[0],
"<ruby>")) {
388 "BuiltinRubyScripts",
"5.2-1");
393 if (!strcmp(progArgv[0],
"<spook>")) {
395 "BuiltinSpookScripts",
"5.3-1");
399 if (!strcmp(progArgv[0],
"<sql>")) {
401 "BuiltinSqlScripts",
"5.3-1");
405 if (!strcmp(progArgv[0],
"<squirrel>")) {
407 "BuiltinSquirrelScripts",
"5.2-1");
412 if (!strcmp(progArgv[0],
"<tcl>")) {
414 "BuiltinTclScripts",
"5.2-1");
418 if (progArgv[0][0] ==
'<') {
420 _(
"line %d: unsupported internal script: %s\n"),
426 && !strcmp(progArgv[0],
"/bin/sh")))
430 progArgv[0], NULL, (tagflags | RPMSENSE_INTERP), 0);
440 if ((rc =
parseRCPOT(spec, pkg, reqargs, reqtag, index, tagflags)))
446 he->
p.
str = *progArgv;
451 "ScriptletInterpreterArgs",
"4.0.3-1");
454 he->
p.
argv = progArgv;
496 rc = (
rpmRC) nextPart;
500 progArgv =
_free(progArgv);
502 optCon = poptFreeContext(optCon);
rpmiob rpmiobRTrim(rpmiob iob)
Trim trailing white space.
int rpmluaCheckScript(rpmlua _lua, const char *script, const char *name)
rpmParseState isPart(Spec spec)
Check line for section separator, return next parser state.
int parseScript(Spec spec, int parsePart)
Parse %pre et al scriptlets from a spec file.
char * xstrdup(const char *str)
int addReqProv(Spec spec, Header h, rpmTag tagN, const char *N, const char *EVR, rpmsenseFlags Flags, rpmuint32_t index)
Add dependency to header, filtering duplicates.
rpmRC lookupPackage(Spec spec, const char *name, int flag, Package *pkg)
Find sub-package control structure by name.
rpmiob rpmiobFree(rpmiob iob)
Destroy a I/O buffer instance.
static void rpmlog(int code, const char *fmt,...)
rpmiob rpmiobAppend(rpmiob iob, const char *s, size_t nl)
Append string to I/O buffer.
int readLine(Spec spec, rpmStripFlags strip)
Read next line from spec file.
static rpmuint32_t addTriggerIndex(Package pkg, const char *file, const char *script, const char *prog)
Yet Another syslog(3) API clone.
void * xcalloc(size_t nmemb, size_t size)
enum evrFlags_e rpmsenseFlags
struct TriggerFileEntry * triggerFiles
The structure used to store values parsed from a spec file.
struct TriggerFileEntry * next
rpmiob rpmiobNew(size_t len)
Create an I/O buffer.
enum rpmRC_e rpmRC
RPM return codes.
char * rpmiobStr(rpmiob iob)
Return I/O buffer (as string).
This is the only module users of librpmbuild should need to include.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
rpmRC parseRCPOT(Spec spec, Package pkg, const char *field, rpmTag tagN, rpmuint32_t index, rpmsenseFlags tagflags)
Parse dependency relations from spec file and/or autogenerated output buffer.
enum rpmParseState_e rpmParseState
The structure used to store values for a package.
const char * postTransFile
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
static struct poptOption optionsTable[]
const char * preTransFile
const char * sanityCheckFile
int rpmlibNeedsFeature(Header h, const char *feature, const char *featureEVR)
Add rpmlib feature dependency.