2000-08-28 03:18:25 +08:00
|
|
|
/** \ingroup rpmbuild
|
|
|
|
* \file build/parseScript.c
|
2000-01-25 04:02:32 +08:00
|
|
|
* Parse install-time script section from spec file.
|
|
|
|
*/
|
|
|
|
|
1998-07-26 05:00:26 +08:00
|
|
|
#include "system.h"
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2008-02-03 22:24:07 +08:00
|
|
|
#include <rpm/header.h>
|
2007-12-08 20:02:32 +08:00
|
|
|
#include <rpm/rpmbuild.h>
|
|
|
|
#include <rpm/rpmlog.h>
|
1998-07-31 06:09:42 +08:00
|
|
|
|
2007-11-23 18:37:54 +08:00
|
|
|
#include "rpmio/rpmlua.h"
|
2010-03-11 18:06:49 +08:00
|
|
|
#include "lib/rpmscript.h" /* script flags */
|
2004-03-17 05:58:25 +08:00
|
|
|
|
2008-01-30 23:05:29 +08:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
|
2001-01-11 22:13:04 +08:00
|
|
|
/**
|
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
static int addTriggerIndex(Package pkg, const char *file,
|
2010-03-11 18:06:49 +08:00
|
|
|
const char *script, const char *prog, rpmscriptFlags flags)
|
1999-04-02 06:26:44 +08:00
|
|
|
{
|
2001-06-04 21:55:58 +08:00
|
|
|
struct TriggerFileEntry *tfe;
|
1999-04-02 06:26:44 +08:00
|
|
|
struct TriggerFileEntry *list = pkg->triggerFiles;
|
|
|
|
struct TriggerFileEntry *last = NULL;
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
while (list) {
|
|
|
|
last = list;
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
2001-09-25 05:53:14 +08:00
|
|
|
if (last)
|
1999-04-02 06:26:44 +08:00
|
|
|
index = last->index + 1;
|
|
|
|
|
2001-09-25 05:53:14 +08:00
|
|
|
tfe = xcalloc(1, sizeof(*tfe));
|
1999-04-02 06:26:44 +08:00
|
|
|
|
2001-06-04 21:55:58 +08:00
|
|
|
tfe->fileName = (file) ? xstrdup(file) : NULL;
|
|
|
|
tfe->script = (script && *script != '\0') ? xstrdup(script) : NULL;
|
|
|
|
tfe->prog = xstrdup(prog);
|
2010-03-11 18:06:49 +08:00
|
|
|
tfe->flags = flags;
|
2001-06-04 21:55:58 +08:00
|
|
|
tfe->index = index;
|
|
|
|
tfe->next = NULL;
|
1999-04-02 06:26:44 +08:00
|
|
|
|
2001-09-25 05:53:14 +08:00
|
|
|
if (last)
|
2001-06-04 21:55:58 +08:00
|
|
|
last->next = tfe;
|
2001-09-25 05:53:14 +08:00
|
|
|
else
|
2001-06-04 21:55:58 +08:00
|
|
|
pkg->triggerFiles = tfe;
|
1999-04-02 06:26:44 +08:00
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
1998-03-21 06:38:00 +08:00
|
|
|
/* %trigger is a strange combination of %pre and Requires: behavior */
|
|
|
|
/* We can handle it by parsing the args before "--" in parseScript. */
|
1999-06-17 23:44:47 +08:00
|
|
|
/* We then pass the remaining arguments to parseRCPOT, along with */
|
1998-03-21 06:38:00 +08:00
|
|
|
/* an index we just determined. */
|
|
|
|
|
2007-09-21 20:23:02 +08:00
|
|
|
int parseScript(rpmSpec spec, int parsePart)
|
1998-01-13 05:31:29 +08:00
|
|
|
{
|
|
|
|
/* There are a few options to scripts: */
|
|
|
|
/* <pkg> */
|
|
|
|
/* -n <pkg> */
|
|
|
|
/* -p <sh> */
|
|
|
|
/* -p "<sh> <args>..." */
|
|
|
|
/* -f <file> */
|
|
|
|
|
|
|
|
char *p;
|
1999-10-28 07:18:10 +08:00
|
|
|
const char **progArgv = NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
int progArgc;
|
2007-12-14 21:17:59 +08:00
|
|
|
const char *partname = NULL;
|
2008-02-05 23:42:19 +08:00
|
|
|
rpmTag reqtag = 0;
|
|
|
|
rpmTag tag = 0;
|
2008-01-30 22:04:40 +08:00
|
|
|
rpmsenseFlags tagflags = 0;
|
2008-02-05 23:42:19 +08:00
|
|
|
rpmTag progtag = 0;
|
2010-03-11 18:06:49 +08:00
|
|
|
rpmTag flagtag = 0;
|
|
|
|
rpmscriptFlags scriptFlags = 0;
|
1998-01-13 05:31:29 +08:00
|
|
|
int flag = PART_SUBNAME;
|
|
|
|
Package pkg;
|
2000-11-12 19:11:49 +08:00
|
|
|
StringBuf sb = NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
int nextPart;
|
1998-03-21 06:38:00 +08:00
|
|
|
int index;
|
2008-05-05 16:53:48 +08:00
|
|
|
char * reqargs = NULL;
|
1998-03-05 00:51:06 +08:00
|
|
|
|
2008-05-05 15:56:55 +08:00
|
|
|
int res = PART_ERROR; /* assume failure */
|
1998-01-13 05:31:29 +08:00
|
|
|
int rc, argc;
|
1998-04-03 02:31:12 +08:00
|
|
|
int arg;
|
1999-10-28 07:18:10 +08:00
|
|
|
const char **argv = NULL;
|
1998-01-13 05:31:29 +08:00
|
|
|
poptContext optCon = NULL;
|
2008-12-09 19:47:50 +08:00
|
|
|
const char *name = NULL;
|
|
|
|
const char *prog = "/bin/sh";
|
|
|
|
const char *file = NULL;
|
2010-03-11 18:06:49 +08:00
|
|
|
int expand = 0;
|
2010-03-11 19:34:17 +08:00
|
|
|
int qformat = 0;
|
2008-12-09 19:47:50 +08:00
|
|
|
struct poptOption optionsTable[] = {
|
|
|
|
{ NULL, 'p', POPT_ARG_STRING, &prog, 'p', NULL, NULL},
|
|
|
|
{ NULL, 'n', POPT_ARG_STRING, &name, 'n', NULL, NULL},
|
|
|
|
{ NULL, 'f', POPT_ARG_STRING, &file, 'f', NULL, NULL},
|
2010-03-11 18:06:49 +08:00
|
|
|
{ NULL, 'e', POPT_ARG_NONE, &expand, 'e', NULL, NULL},
|
|
|
|
{ NULL, 'q', POPT_ARG_NONE, &qformat, 'q', NULL, NULL},
|
2008-12-09 19:47:50 +08:00
|
|
|
{ 0, 0, 0, 0, 0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
switch (parsePart) {
|
|
|
|
case PART_PRE:
|
|
|
|
tag = RPMTAG_PREIN;
|
2000-11-12 19:11:49 +08:00
|
|
|
tagflags = RPMSENSE_SCRIPT_PRE;
|
1998-01-13 05:31:29 +08:00
|
|
|
progtag = RPMTAG_PREINPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_PREINFLAGS;
|
1998-01-13 05:31:29 +08:00
|
|
|
partname = "%pre";
|
|
|
|
break;
|
|
|
|
case PART_POST:
|
|
|
|
tag = RPMTAG_POSTIN;
|
2000-11-12 19:11:49 +08:00
|
|
|
tagflags = RPMSENSE_SCRIPT_POST;
|
1998-01-13 05:31:29 +08:00
|
|
|
progtag = RPMTAG_POSTINPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_POSTINFLAGS;
|
1998-01-13 05:31:29 +08:00
|
|
|
partname = "%post";
|
|
|
|
break;
|
|
|
|
case PART_PREUN:
|
|
|
|
tag = RPMTAG_PREUN;
|
2000-11-12 19:11:49 +08:00
|
|
|
tagflags = RPMSENSE_SCRIPT_PREUN;
|
1998-01-13 05:31:29 +08:00
|
|
|
progtag = RPMTAG_PREUNPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_PREUNFLAGS;
|
1998-01-13 05:31:29 +08:00
|
|
|
partname = "%preun";
|
|
|
|
break;
|
|
|
|
case PART_POSTUN:
|
|
|
|
tag = RPMTAG_POSTUN;
|
2000-11-12 19:11:49 +08:00
|
|
|
tagflags = RPMSENSE_SCRIPT_POSTUN;
|
1998-01-13 05:31:29 +08:00
|
|
|
progtag = RPMTAG_POSTUNPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_POSTUNFLAGS;
|
1998-01-13 05:31:29 +08:00
|
|
|
partname = "%postun";
|
|
|
|
break;
|
2004-03-17 05:58:25 +08:00
|
|
|
case PART_PRETRANS:
|
|
|
|
tag = RPMTAG_PRETRANS;
|
2010-03-29 13:58:27 +08:00
|
|
|
tagflags = RPMSENSE_PRETRANS;
|
2004-03-17 05:58:25 +08:00
|
|
|
progtag = RPMTAG_PRETRANSPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_PRETRANSFLAGS;
|
2004-03-17 05:58:25 +08:00
|
|
|
partname = "%pretrans";
|
|
|
|
break;
|
|
|
|
case PART_POSTTRANS:
|
|
|
|
tag = RPMTAG_POSTTRANS;
|
|
|
|
tagflags = 0;
|
|
|
|
progtag = RPMTAG_POSTTRANSPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_POSTTRANSFLAGS;
|
2004-03-17 05:58:25 +08:00
|
|
|
partname = "%posttrans";
|
|
|
|
break;
|
1998-01-13 05:31:29 +08:00
|
|
|
case PART_VERIFYSCRIPT:
|
1999-04-21 03:17:23 +08:00
|
|
|
tag = RPMTAG_VERIFYSCRIPT;
|
2000-11-12 19:11:49 +08:00
|
|
|
tagflags = RPMSENSE_SCRIPT_VERIFY;
|
1998-01-13 05:31:29 +08:00
|
|
|
progtag = RPMTAG_VERIFYSCRIPTPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_VERIFYSCRIPTFLAGS;
|
1998-01-13 05:31:29 +08:00
|
|
|
partname = "%verifyscript";
|
1998-03-21 06:38:00 +08:00
|
|
|
break;
|
2008-01-09 17:11:49 +08:00
|
|
|
case PART_TRIGGERPREIN:
|
|
|
|
tag = RPMTAG_TRIGGERSCRIPTS;
|
|
|
|
tagflags = 0;
|
|
|
|
reqtag = RPMTAG_TRIGGERPREIN;
|
|
|
|
progtag = RPMTAG_TRIGGERSCRIPTPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_TRIGGERSCRIPTFLAGS;
|
2008-01-09 17:11:49 +08:00
|
|
|
partname = "%triggerprein";
|
|
|
|
break;
|
1998-03-21 06:38:00 +08:00
|
|
|
case PART_TRIGGERIN:
|
|
|
|
tag = RPMTAG_TRIGGERSCRIPTS;
|
2000-11-12 19:11:49 +08:00
|
|
|
tagflags = 0;
|
1998-03-21 06:38:00 +08:00
|
|
|
reqtag = RPMTAG_TRIGGERIN;
|
|
|
|
progtag = RPMTAG_TRIGGERSCRIPTPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_TRIGGERSCRIPTFLAGS;
|
1998-04-02 00:02:05 +08:00
|
|
|
partname = "%triggerin";
|
1998-03-21 06:38:00 +08:00
|
|
|
break;
|
|
|
|
case PART_TRIGGERUN:
|
|
|
|
tag = RPMTAG_TRIGGERSCRIPTS;
|
2000-11-12 19:11:49 +08:00
|
|
|
tagflags = 0;
|
1998-03-21 06:38:00 +08:00
|
|
|
reqtag = RPMTAG_TRIGGERUN;
|
|
|
|
progtag = RPMTAG_TRIGGERSCRIPTPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_TRIGGERSCRIPTFLAGS;
|
1998-03-21 06:38:00 +08:00
|
|
|
partname = "%triggerun";
|
|
|
|
break;
|
1998-04-02 00:02:05 +08:00
|
|
|
case PART_TRIGGERPOSTUN:
|
|
|
|
tag = RPMTAG_TRIGGERSCRIPTS;
|
2000-11-12 19:11:49 +08:00
|
|
|
tagflags = 0;
|
1998-04-02 00:02:05 +08:00
|
|
|
reqtag = RPMTAG_TRIGGERPOSTUN;
|
|
|
|
progtag = RPMTAG_TRIGGERSCRIPTPROG;
|
2010-03-11 18:06:49 +08:00
|
|
|
flagtag = RPMTAG_TRIGGERSCRIPTFLAGS;
|
1998-04-02 00:02:05 +08:00
|
|
|
partname = "%triggerpostun";
|
|
|
|
break;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1998-03-21 06:38:00 +08:00
|
|
|
if (tag == RPMTAG_TRIGGERSCRIPTS) {
|
|
|
|
/* break line into two */
|
|
|
|
p = strstr(spec->line, "--");
|
|
|
|
if (!p) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: triggers must have --: %s\n"),
|
1998-03-21 06:38:00 +08:00
|
|
|
spec->lineNum, spec->line);
|
2008-05-05 15:56:55 +08:00
|
|
|
return PART_ERROR;
|
1998-03-21 06:38:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
*p = '\0';
|
2008-05-05 16:53:48 +08:00
|
|
|
reqargs = xstrdup(p + 2);
|
1998-03-21 06:38:00 +08:00
|
|
|
}
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
if ((rc = poptParseArgvString(spec->line, &argc, &argv))) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Error parsing %s: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, partname, poptStrerror(rc));
|
2008-05-05 16:53:48 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
|
|
|
|
while ((arg = poptGetNextOpt(optCon)) > 0) {
|
2001-01-04 10:24:14 +08:00
|
|
|
switch (arg) {
|
|
|
|
case 'p':
|
2004-03-17 05:58:25 +08:00
|
|
|
if (prog[0] == '<') {
|
|
|
|
if (prog[strlen(prog)-1] != '>') {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR,
|
2004-03-17 05:58:25 +08:00
|
|
|
_("line %d: internal script must end "
|
|
|
|
"with \'>\': %s\n"), spec->lineNum, prog);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
} else if (prog[0] != '/') {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR,
|
1998-09-28 06:03:52 +08:00
|
|
|
_("line %d: script program must begin "
|
2001-01-16 07:09:42 +08:00
|
|
|
"with \'/\': %s\n"), spec->lineNum, prog);
|
2000-11-12 19:11:49 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
2007-09-12 05:03:27 +08:00
|
|
|
break;
|
2001-01-04 10:24:14 +08:00
|
|
|
case 'n':
|
1998-01-13 05:31:29 +08:00
|
|
|
flag = PART_NAME;
|
2007-09-12 05:03:27 +08:00
|
|
|
break;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg < -1) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Bad option %s: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum,
|
|
|
|
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
|
|
|
|
spec->line);
|
2000-11-12 19:11:49 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
1998-03-21 06:38:00 +08:00
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
if (poptPeekArg(optCon)) {
|
1999-10-28 07:18:10 +08:00
|
|
|
if (name == NULL)
|
1998-01-13 05:31:29 +08:00
|
|
|
name = poptGetArg(optCon);
|
|
|
|
if (poptPeekArg(optCon)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Too many names: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum,
|
|
|
|
spec->line);
|
2000-11-12 19:11:49 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lookupPackage(spec, name, flag, &pkg)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Package does not exist: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, spec->line);
|
2000-11-12 19:11:49 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
1998-03-21 06:38:00 +08:00
|
|
|
if (tag != RPMTAG_TRIGGERSCRIPTS) {
|
|
|
|
if (headerIsEntry(pkg->header, progtag)) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Second %s\n"),
|
1998-03-21 06:38:00 +08:00
|
|
|
spec->lineNum, partname);
|
2000-11-12 19:11:49 +08:00
|
|
|
goto exit;
|
1998-03-21 06:38:00 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((rc = poptParseArgvString(prog, &progArgc, &progArgv))) {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR, _("line %d: Error parsing %s: %s\n"),
|
1998-01-13 05:31:29 +08:00
|
|
|
spec->lineNum, partname, poptStrerror(rc));
|
2000-11-12 19:11:49 +08:00
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
2001-01-04 10:24:14 +08:00
|
|
|
|
2010-03-11 18:06:49 +08:00
|
|
|
scriptFlags |= expand ? RPMSCRIPT_EXPAND : 0;
|
|
|
|
scriptFlags |= qformat ? RPMSCRIPT_QFORMAT : 0;
|
|
|
|
|
1998-01-13 05:31:29 +08:00
|
|
|
sb = newStringBuf();
|
1998-05-21 01:05:26 +08:00
|
|
|
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
|
1998-01-13 05:31:29 +08:00
|
|
|
nextPart = PART_NONE;
|
2008-05-05 15:56:55 +08:00
|
|
|
} else if (rc < 0) {
|
|
|
|
goto exit;
|
1998-01-13 05:31:29 +08:00
|
|
|
} else {
|
|
|
|
while (! (nextPart = isPart(spec->line))) {
|
1998-01-14 11:32:44 +08:00
|
|
|
appendStringBuf(sb, spec->line);
|
1998-05-21 01:05:26 +08:00
|
|
|
if ((rc = readLine(spec, STRIP_NOTHING)) > 0) {
|
1998-01-13 05:31:29 +08:00
|
|
|
nextPart = PART_NONE;
|
|
|
|
break;
|
2008-05-05 15:56:55 +08:00
|
|
|
} else if (rc < 0) {
|
2000-11-12 19:11:49 +08:00
|
|
|
goto exit;
|
2008-05-05 15:56:55 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
stripTrailingBlanksStringBuf(sb);
|
|
|
|
p = getStringBuf(sb);
|
|
|
|
|
2007-05-16 21:16:45 +08:00
|
|
|
#ifdef WITH_LUA
|
2009-08-31 16:08:05 +08:00
|
|
|
if (rstreq(progArgv[0], "<lua>")) {
|
2004-03-25 03:47:11 +08:00
|
|
|
rpmlua lua = NULL; /* Global state. */
|
2004-03-17 05:58:25 +08:00
|
|
|
if (rpmluaCheckScript(lua, p, partname) != RPMRC_OK) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
(void) rpmlibNeedsFeature(pkg->header,
|
|
|
|
"BuiltinLuaScripts", "4.2.2-1");
|
2007-05-16 21:16:45 +08:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
if (progArgv[0][0] == '<') {
|
2007-11-19 22:25:24 +08:00
|
|
|
rpmlog(RPMLOG_ERR,
|
2004-03-17 05:58:25 +08:00
|
|
|
_("line %d: unsupported internal script: %s\n"),
|
|
|
|
spec->lineNum, progArgv[0]);
|
|
|
|
goto exit;
|
|
|
|
} else {
|
2010-08-25 20:06:47 +08:00
|
|
|
(void) addReqProv(pkg->header, RPMTAG_REQUIRENAME,
|
2004-10-10 02:23:00 +08:00
|
|
|
progArgv[0], NULL, (tagflags | RPMSENSE_INTERP), 0);
|
2004-03-17 05:58:25 +08:00
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2010-03-11 18:06:49 +08:00
|
|
|
if (scriptFlags) {
|
|
|
|
rpmlibNeedsFeature(pkg->header, "ScriptletExpansion", "4.9.0-1");
|
|
|
|
}
|
|
|
|
|
1998-03-21 06:38:00 +08:00
|
|
|
/* Trigger script insertion is always delayed in order to */
|
|
|
|
/* get the index right. */
|
|
|
|
if (tag == RPMTAG_TRIGGERSCRIPTS) {
|
|
|
|
/* Add file/index/prog triple to the trigger file list */
|
2010-03-11 18:06:49 +08:00
|
|
|
index = addTriggerIndex(pkg, file, p, progArgv[0], scriptFlags);
|
1998-03-21 06:38:00 +08:00
|
|
|
|
|
|
|
/* Generate the trigger tags */
|
2000-11-12 19:11:49 +08:00
|
|
|
if ((rc = parseRCPOT(spec, pkg, reqargs, reqtag, index, tagflags)))
|
|
|
|
goto exit;
|
1998-03-21 06:38:00 +08:00
|
|
|
} else {
|
2008-06-18 18:13:22 +08:00
|
|
|
struct rpmtd_s td;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX Ancient rpm uses STRING, not STRING_ARRAY type here. Construct
|
|
|
|
* the td manually and preserve legacy compat for now...
|
|
|
|
*/
|
|
|
|
rpmtdReset(&td);
|
|
|
|
td.tag = progtag;
|
|
|
|
td.count = progArgc;
|
2008-06-18 21:14:36 +08:00
|
|
|
if (progArgc == 1) {
|
|
|
|
td.data = (void *) *progArgv;
|
2008-06-18 18:13:22 +08:00
|
|
|
td.type = RPM_STRING_TYPE;
|
2008-06-18 21:14:36 +08:00
|
|
|
} else {
|
2001-06-16 02:53:06 +08:00
|
|
|
(void) rpmlibNeedsFeature(pkg->header,
|
|
|
|
"ScriptletInterpreterArgs", "4.0.3-1");
|
2008-06-18 21:14:36 +08:00
|
|
|
td.data = progArgv;
|
2008-06-18 18:13:22 +08:00
|
|
|
td.type = RPM_STRING_ARRAY_TYPE;
|
2001-06-16 02:53:06 +08:00
|
|
|
}
|
2008-06-18 18:13:22 +08:00
|
|
|
headerPut(pkg->header, &td, HEADERPUT_DEFAULT);
|
2001-01-04 10:24:14 +08:00
|
|
|
|
2008-06-18 18:13:22 +08:00
|
|
|
if (*p != '\0') {
|
2008-06-19 20:47:04 +08:00
|
|
|
headerPutString(pkg->header, tag, p);
|
2008-06-18 18:13:22 +08:00
|
|
|
}
|
2010-03-11 18:06:49 +08:00
|
|
|
if (scriptFlags) {
|
|
|
|
headerPutUint32(pkg->header, flagtag, &scriptFlags, 1);
|
|
|
|
}
|
2000-11-12 19:11:49 +08:00
|
|
|
|
1998-03-21 06:38:00 +08:00
|
|
|
if (file) {
|
|
|
|
switch (parsePart) {
|
|
|
|
case PART_PRE:
|
1999-09-21 11:22:53 +08:00
|
|
|
pkg->preInFile = xstrdup(file);
|
1998-03-21 06:38:00 +08:00
|
|
|
break;
|
|
|
|
case PART_POST:
|
1999-09-21 11:22:53 +08:00
|
|
|
pkg->postInFile = xstrdup(file);
|
1998-03-21 06:38:00 +08:00
|
|
|
break;
|
|
|
|
case PART_PREUN:
|
1999-09-21 11:22:53 +08:00
|
|
|
pkg->preUnFile = xstrdup(file);
|
1998-03-21 06:38:00 +08:00
|
|
|
break;
|
|
|
|
case PART_POSTUN:
|
1999-09-21 11:22:53 +08:00
|
|
|
pkg->postUnFile = xstrdup(file);
|
1998-03-21 06:38:00 +08:00
|
|
|
break;
|
2004-03-17 05:58:25 +08:00
|
|
|
case PART_PRETRANS:
|
|
|
|
pkg->preTransFile = xstrdup(file);
|
|
|
|
break;
|
|
|
|
case PART_POSTTRANS:
|
|
|
|
pkg->postTransFile = xstrdup(file);
|
|
|
|
break;
|
1998-03-21 06:38:00 +08:00
|
|
|
case PART_VERIFYSCRIPT:
|
1999-09-21 11:22:53 +08:00
|
|
|
pkg->verifyFile = xstrdup(file);
|
1998-03-21 06:38:00 +08:00
|
|
|
break;
|
|
|
|
}
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|
|
|
|
}
|
2008-05-05 15:56:55 +08:00
|
|
|
res = nextPart;
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2000-11-12 19:11:49 +08:00
|
|
|
exit:
|
2008-05-05 16:53:48 +08:00
|
|
|
free(reqargs);
|
2001-05-06 03:28:32 +08:00
|
|
|
sb = freeStringBuf(sb);
|
2001-04-29 09:05:43 +08:00
|
|
|
progArgv = _free(progArgv);
|
|
|
|
argv = _free(argv);
|
2001-05-06 03:28:32 +08:00
|
|
|
optCon = poptFreeContext(optCon);
|
1998-01-13 05:31:29 +08:00
|
|
|
|
2008-05-05 15:56:55 +08:00
|
|
|
return res;
|
1998-01-13 05:31:29 +08:00
|
|
|
}
|