summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorniemeyer <devnull@localhost>2004-03-16 21:58:25 +0000
committerniemeyer <devnull@localhost>2004-03-16 21:58:25 +0000
commit73260d956c54a3d95aa7d367c09ed3e2cb2a2a00 (patch)
tree420516b3d6568f1e09364f6fd59c6c1849da0b43 /build
parent55f77d61d72a3993436db9a8eefec9eaa7fb61ae (diff)
downloadrpm-73260d956c54a3d95aa7d367c09ed3e2cb2a2a00.tar.gz
- Implemented support for internal Lua scripts.
- Implemented %pretrans and %posttrans script slots. Changed files: Makefile.am configure.ac build/pack.c build/parseScript.c build/parseSpec.c build/rpmbuild.h build/rpmspec.h lib/Makefile.am lib/psm.c lib/rpmlib.h lib/rpmlibprov.c lib/rpmts.c lib/rpmts.h lib/transaction.c Added files: lib/rpmlua.c lib/rpmlua.h lua/* CVS patchset: 7175 CVS date: 2004/03/16 21:58:25
Diffstat (limited to 'build')
-rw-r--r--build/pack.c14
-rw-r--r--build/parseScript.c50
-rw-r--r--build/parseSpec.c4
-rw-r--r--build/rpmbuild.h18
-rw-r--r--build/rpmspec.h4
5 files changed, 80 insertions, 10 deletions
diff --git a/build/pack.c b/build/pack.c
index ec1728f31..f02d2ee2b 100644
--- a/build/pack.c
+++ b/build/pack.c
@@ -230,6 +230,13 @@ static int processScriptFiles(Spec spec, Package pkg)
return RPMERR_BADFILENAME;
}
}
+ if (pkg->preTransFile) {
+ if (addFileToTag(spec, pkg->preTransFile, pkg->header, RPMTAG_PRETRANS)) {
+ rpmError(RPMERR_BADFILENAME,
+ _("Could not open PreIn file: %s\n"), pkg->preTransFile);
+ return RPMERR_BADFILENAME;
+ }
+ }
if (pkg->postInFile) {
if (addFileToTag(spec, pkg->postInFile, pkg->header, RPMTAG_POSTIN)) {
rpmError(RPMERR_BADFILENAME,
@@ -244,6 +251,13 @@ static int processScriptFiles(Spec spec, Package pkg)
return RPMERR_BADFILENAME;
}
}
+ if (pkg->postTransFile) {
+ if (addFileToTag(spec, pkg->postTransFile, pkg->header, RPMTAG_POSTTRANS)) {
+ rpmError(RPMERR_BADFILENAME,
+ _("Could not open PostUn file: %s\n"), pkg->postTransFile);
+ return RPMERR_BADFILENAME;
+ }
+ }
if (pkg->verifyFile) {
if (addFileToTag(spec, pkg->verifyFile, pkg->header,
RPMTAG_VERIFYSCRIPT)) {
diff --git a/build/parseScript.c b/build/parseScript.c
index 4e30f1382..03634c0bd 100644
--- a/build/parseScript.c
+++ b/build/parseScript.c
@@ -8,6 +8,8 @@
#include "rpmbuild.h"
#include "debug.h"
+#include <rpmlua.h>
+
/*@access StringBuf@*/ /* XXX compared with NULL */
/*@access poptContext @*/ /* compared with NULL */
@@ -129,6 +131,18 @@ int parseScript(Spec spec, int parsePart)
progtag = RPMTAG_POSTUNPROG;
partname = "%postun";
break;
+ case PART_PRETRANS:
+ tag = RPMTAG_PRETRANS;
+ tagflags = 0;
+ progtag = RPMTAG_PRETRANSPROG;
+ partname = "%pretrans";
+ break;
+ case PART_POSTTRANS:
+ tag = RPMTAG_POSTTRANS;
+ tagflags = 0;
+ progtag = RPMTAG_POSTTRANSPROG;
+ partname = "%posttrans";
+ break;
case PART_VERIFYSCRIPT:
tag = RPMTAG_VERIFYSCRIPT;
tagflags = RPMSENSE_SCRIPT_VERIFY;
@@ -182,7 +196,15 @@ int parseScript(Spec spec, int parsePart)
while ((arg = poptGetNextOpt(optCon)) > 0) {
switch (arg) {
case 'p':
- if (prog[0] != '/') {
+ if (prog[0] == '<') {
+ if (prog[strlen(prog)-1] != '>') {
+ rpmError(RPMERR_BADSPEC,
+ _("line %d: internal script must end "
+ "with \'>\': %s\n"), spec->lineNum, prog);
+ rc = RPMERR_BADSPEC;
+ goto exit;
+ }
+ } else if (prog[0] != '/') {
rpmError(RPMERR_BADSPEC,
_("line %d: script program must begin "
"with \'/\': %s\n"), spec->lineNum, prog);
@@ -261,7 +283,25 @@ int parseScript(Spec spec, int parsePart)
stripTrailingBlanksStringBuf(sb);
p = getStringBuf(sb);
- (void) addReqProv(spec, pkg->header, (tagflags | RPMSENSE_INTERP), progArgv[0], NULL, 0);
+ if (!strcmp(progArgv[0], "<lua>")) {
+ rpmlua lua = rpmluaNew();
+ if (rpmluaCheckScript(lua, p, partname) != RPMRC_OK) {
+ rpmluaFree(lua);
+ rc = RPMERR_BADSPEC;
+ goto exit;
+ }
+ rpmluaFree(lua);
+ (void) rpmlibNeedsFeature(pkg->header,
+ "BuiltinLuaScripts", "4.2.2-1");
+ } else if (progArgv[0][0] == '<') {
+ rpmError(RPMERR_BADSPEC,
+ _("line %d: unsupported internal script: %s\n"),
+ spec->lineNum, progArgv[0]);
+ rc = RPMERR_BADSPEC;
+ goto exit;
+ } else {
+ (void) addReqProv(spec, pkg->header, (tagflags | RPMSENSE_INTERP), progArgv[0], NULL, 0);
+ }
/* Trigger script insertion is always delayed in order to */
/* get the index right. */
@@ -300,6 +340,12 @@ int parseScript(Spec spec, int parsePart)
case PART_POSTUN:
pkg->postUnFile = xstrdup(file);
break;
+ case PART_PRETRANS:
+ pkg->preTransFile = xstrdup(file);
+ break;
+ case PART_POSTTRANS:
+ pkg->postTransFile = xstrdup(file);
+ break;
case PART_VERIFYSCRIPT:
pkg->verifyFile = xstrdup(file);
break;
diff --git a/build/parseSpec.c b/build/parseSpec.c
index 82c7098f6..a7e4d5037 100644
--- a/build/parseSpec.c
+++ b/build/parseSpec.c
@@ -30,6 +30,8 @@ static struct PartRec {
{ PART_CLEAN, 0, "%clean"},
{ PART_PREUN, 0, "%preun"},
{ PART_POSTUN, 0, "%postun"},
+ { PART_PRETRANS, 0, "%pretrans"},
+ { PART_POSTTRANS, 0, "%posttrans"},
{ PART_PRE, 0, "%pre"},
{ PART_POST, 0, "%post"},
{ PART_FILES, 0, "%files"},
@@ -475,6 +477,8 @@ int parseSpec(rpmts ts, const char *specFile, const char *rootURL,
case PART_POST:
case PART_PREUN:
case PART_POSTUN:
+ case PART_PRETRANS:
+ case PART_POSTTRANS:
case PART_VERIFYSCRIPT:
case PART_TRIGGERIN:
case PART_TRIGGERUN:
diff --git a/build/rpmbuild.h b/build/rpmbuild.h
index a6a918364..66d670064 100644
--- a/build/rpmbuild.h
+++ b/build/rpmbuild.h
@@ -62,14 +62,16 @@ typedef enum rpmParseState_e {
PART_POST = 9, /*!< */
PART_PREUN = 10, /*!< */
PART_POSTUN = 11, /*!< */
- PART_DESCRIPTION = 12, /*!< */
- PART_CHANGELOG = 13, /*!< */
- PART_TRIGGERIN = 14, /*!< */
- PART_TRIGGERUN = 15, /*!< */
- PART_VERIFYSCRIPT = 16, /*!< */
- PART_BUILDARCHITECTURES= 17,/*!< */
- PART_TRIGGERPOSTUN = 18, /*!< */
- PART_LAST = 19 /*!< */
+ PART_PRETRANS = 12, /*!< */
+ PART_POSTTRANS = 13, /*!< */
+ PART_DESCRIPTION = 14, /*!< */
+ PART_CHANGELOG = 15, /*!< */
+ PART_TRIGGERIN = 16, /*!< */
+ PART_TRIGGERUN = 17, /*!< */
+ PART_VERIFYSCRIPT = 18, /*!< */
+ PART_BUILDARCHITECTURES= 19,/*!< */
+ PART_TRIGGERPOSTUN = 20, /*!< */
+ PART_LAST = 21 /*!< */
} rpmParseState;
#define STRIP_NOTHING 0
diff --git a/build/rpmspec.h b/build/rpmspec.h
index ab71084e2..ce58dca84 100644
--- a/build/rpmspec.h
+++ b/build/rpmspec.h
@@ -195,6 +195,10 @@ struct Package_s {
/*@only@*/
const char * postUnFile; /*!< %postun scriptlet. */
/*@only@*/
+ const char * preTransFile; /*!< %pretrans scriptlet. */
+/*@only@*/
+ const char * postTransFile; /*!< %posttrans scriptlet. */
+/*@only@*/
const char * verifyFile; /*!< %verifyscript scriptlet. */
/*@only@*/