|
Lubos Kardos |
659760 |
From d18fdd7f8964d01b4dfc39bf84133695cff5a13a Mon Sep 17 00:00:00 2001
|
|
Lubos Kardos |
659760 |
From: Lubos Kardos <lkardos@redhat.com>
|
|
Lubos Kardos |
659760 |
Date: Thu, 6 Aug 2015 14:28:25 +0200
|
|
Lubos Kardos |
659760 |
Subject: [PATCH] Add --filetriggers option to show info about file triggers.
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
---
|
|
Lubos Kardos |
659760 |
lib/rpmtag.h | 4 ++
|
|
Lubos Kardos |
659760 |
lib/tagexts.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++-----
|
|
Lubos Kardos |
659760 |
rpmpopt.in | 8 ++++
|
|
Lubos Kardos |
659760 |
tests/rpmgeneral.at | 4 ++
|
|
Lubos Kardos |
659760 |
4 files changed, 113 insertions(+), 10 deletions(-)
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
diff --git a/lib/rpmtag.h b/lib/rpmtag.h
|
|
Lubos Kardos |
659760 |
index ac6ee64..94c0655 100644
|
|
Lubos Kardos |
659760 |
--- a/lib/rpmtag.h
|
|
Lubos Kardos |
659760 |
+++ b/lib/rpmtag.h
|
|
Lubos Kardos |
659760 |
@@ -352,6 +352,10 @@ typedef enum rpmTag_e {
|
|
Lubos Kardos |
659760 |
RPMTAG_REMOVEPATHPOSTFIXES = 5083, /* s internal */
|
|
Lubos Kardos |
659760 |
RPMTAG_FILETRIGGERPRIORITIES = 5084, /* i[] */
|
|
Lubos Kardos |
659760 |
RPMTAG_TRANSFILETRIGGERPRIORITIES = 5085, /* i[] */
|
|
Lubos Kardos |
659760 |
+ RPMTAG_FILETRIGGERCONDS = 5086, /* s[] extension */
|
|
Lubos Kardos |
659760 |
+ RPMTAG_FILETRIGGERTYPE = 5087, /* s[] extension */
|
|
Lubos Kardos |
659760 |
+ RPMTAG_TRANSFILETRIGGERCONDS = 5088, /* s[] extension */
|
|
Lubos Kardos |
659760 |
+ RPMTAG_TRANSFILETRIGGERTYPE = 5089, /* s[] extension */
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
RPMTAG_FIRSTFREE_TAG /*!< internal */
|
|
Lubos Kardos |
659760 |
} rpmTag;
|
|
Lubos Kardos |
659760 |
diff --git a/lib/tagexts.c b/lib/tagexts.c
|
|
Lubos Kardos |
659760 |
index fa3fe72..69f3c24 100644
|
|
Lubos Kardos |
659760 |
--- a/lib/tagexts.c
|
|
Lubos Kardos |
659760 |
+++ b/lib/tagexts.c
|
|
Lubos Kardos |
659760 |
@@ -191,6 +191,12 @@ exit:
|
|
Lubos Kardos |
659760 |
return rc;
|
|
Lubos Kardos |
659760 |
}
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
+typedef enum tMode_e {
|
|
Lubos Kardos |
659760 |
+ NORMALTRIGGER = 0,
|
|
Lubos Kardos |
659760 |
+ FILETRIGGER = 1,
|
|
Lubos Kardos |
659760 |
+ TRANSFILETRIGGER = 2,
|
|
Lubos Kardos |
659760 |
+} tMode;
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
/**
|
|
Lubos Kardos |
659760 |
* Retrieve trigger info.
|
|
Lubos Kardos |
659760 |
* @param h header
|
|
Lubos Kardos |
659760 |
@@ -198,22 +204,49 @@ exit:
|
|
Lubos Kardos |
659760 |
* @param hgflags header get flags
|
|
Lubos Kardos |
659760 |
* @return 1 on success
|
|
Lubos Kardos |
659760 |
*/
|
|
Lubos Kardos |
659760 |
-static int triggercondsTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
+static int triggercondsTagFor(tMode mode, Header h, rpmtd td,
|
|
Lubos Kardos |
659760 |
+ headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
{
|
|
Lubos Kardos |
659760 |
uint32_t * indices;
|
|
Lubos Kardos |
659760 |
int i, j;
|
|
Lubos Kardos |
659760 |
char ** conds;
|
|
Lubos Kardos |
659760 |
struct rpmtd_s nametd, indextd, flagtd, versiontd, scripttd;
|
|
Lubos Kardos |
659760 |
int hgeflags = HEADERGET_MINMEM;
|
|
Lubos Kardos |
659760 |
+ rpmTagVal triggername, triggerindex, triggerflags;
|
|
Lubos Kardos |
659760 |
+ rpmTagVal triggerversion, triggerscripts;
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
+ switch (mode) {
|
|
Lubos Kardos |
659760 |
+ case NORMALTRIGGER:
|
|
Lubos Kardos |
659760 |
+ triggername = RPMTAG_TRIGGERNAME;
|
|
Lubos Kardos |
659760 |
+ triggerindex = RPMTAG_TRIGGERINDEX;
|
|
Lubos Kardos |
659760 |
+ triggerflags = RPMTAG_TRIGGERFLAGS;
|
|
Lubos Kardos |
659760 |
+ triggerversion = RPMTAG_TRIGGERVERSION;
|
|
Lubos Kardos |
659760 |
+ triggerscripts = RPMTAG_TRIGGERSCRIPTS;
|
|
Lubos Kardos |
659760 |
+ break;
|
|
Lubos Kardos |
659760 |
+ case FILETRIGGER:
|
|
Lubos Kardos |
659760 |
+ triggername = RPMTAG_FILETRIGGERNAME;
|
|
Lubos Kardos |
659760 |
+ triggerindex = RPMTAG_FILETRIGGERINDEX;
|
|
Lubos Kardos |
659760 |
+ triggerflags = RPMTAG_FILETRIGGERFLAGS;
|
|
Lubos Kardos |
659760 |
+ triggerversion = RPMTAG_FILETRIGGERVERSION;
|
|
Lubos Kardos |
659760 |
+ triggerscripts = RPMTAG_FILETRIGGERSCRIPTS;
|
|
Lubos Kardos |
659760 |
+ break;
|
|
Lubos Kardos |
659760 |
+ case TRANSFILETRIGGER:
|
|
Lubos Kardos |
659760 |
+ triggername = RPMTAG_TRANSFILETRIGGERNAME;
|
|
Lubos Kardos |
659760 |
+ triggerindex = RPMTAG_TRANSFILETRIGGERINDEX;
|
|
Lubos Kardos |
659760 |
+ triggerflags = RPMTAG_TRANSFILETRIGGERFLAGS;
|
|
Lubos Kardos |
659760 |
+ triggerversion = RPMTAG_TRANSFILETRIGGERVERSION;
|
|
Lubos Kardos |
659760 |
+ triggerscripts = RPMTAG_TRANSFILETRIGGERSCRIPTS;
|
|
Lubos Kardos |
659760 |
+ break;
|
|
Lubos Kardos |
659760 |
+ }
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
- if (!headerGet(h, RPMTAG_TRIGGERNAME, &nametd, hgeflags)) {
|
|
Lubos Kardos |
659760 |
+ if (!headerGet(h, triggername, &nametd, hgeflags)) {
|
|
Lubos Kardos |
659760 |
return 0;
|
|
Lubos Kardos |
659760 |
}
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
- headerGet(h, RPMTAG_TRIGGERINDEX, &indextd, hgeflags);
|
|
Lubos Kardos |
659760 |
- headerGet(h, RPMTAG_TRIGGERFLAGS, &flagtd, hgeflags);
|
|
Lubos Kardos |
659760 |
- headerGet(h, RPMTAG_TRIGGERVERSION, &versiontd, hgeflags);
|
|
Lubos Kardos |
659760 |
- headerGet(h, RPMTAG_TRIGGERSCRIPTS, &scripttd, hgeflags);
|
|
Lubos Kardos |
659760 |
+ headerGet(h, triggerindex, &indextd, hgeflags);
|
|
Lubos Kardos |
659760 |
+ headerGet(h, triggerflags, &flagtd, hgeflags);
|
|
Lubos Kardos |
659760 |
+ headerGet(h, triggerversion, &versiontd, hgeflags);
|
|
Lubos Kardos |
659760 |
+ headerGet(h, triggerscripts, &scripttd, hgeflags);
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
td->type = RPM_STRING_ARRAY_TYPE;
|
|
Lubos Kardos |
659760 |
td->flags = RPMTD_ALLOCED | RPMTD_PTR_ALLOCED;
|
|
Lubos Kardos |
659760 |
@@ -262,6 +295,21 @@ static int triggercondsTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
return 1;
|
|
Lubos Kardos |
659760 |
}
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
+static int triggercondsTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
+{
|
|
Lubos Kardos |
659760 |
+ return triggercondsTagFor(NORMALTRIGGER, h, td, hgflags);
|
|
Lubos Kardos |
659760 |
+}
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
+static int filetriggercondsTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
+{
|
|
Lubos Kardos |
659760 |
+ return triggercondsTagFor(FILETRIGGER, h, td, hgflags);
|
|
Lubos Kardos |
659760 |
+}
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
+static int transfiletriggercondsTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
+{
|
|
Lubos Kardos |
659760 |
+ return triggercondsTagFor(TRANSFILETRIGGER, h, td, hgflags);
|
|
Lubos Kardos |
659760 |
+}
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
/**
|
|
Lubos Kardos |
659760 |
* Retrieve trigger type info.
|
|
Lubos Kardos |
659760 |
* @param h header
|
|
Lubos Kardos |
659760 |
@@ -269,18 +317,38 @@ static int triggercondsTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
* @param hgflags header get flags
|
|
Lubos Kardos |
659760 |
* @return 1 on success
|
|
Lubos Kardos |
659760 |
*/
|
|
Lubos Kardos |
659760 |
-static int triggertypeTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
+static int triggertypeTagFor(tMode mode, Header h, rpmtd td,
|
|
Lubos Kardos |
659760 |
+ headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
{
|
|
Lubos Kardos |
659760 |
int i;
|
|
Lubos Kardos |
659760 |
char ** conds;
|
|
Lubos Kardos |
659760 |
struct rpmtd_s indices, flags, scripts;
|
|
Lubos Kardos |
659760 |
+ rpmTagVal triggerindex, triggerflags, triggerscripts;
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
+ switch (mode) {
|
|
Lubos Kardos |
659760 |
+ case NORMALTRIGGER:
|
|
Lubos Kardos |
659760 |
+ triggerindex = RPMTAG_TRIGGERINDEX;
|
|
Lubos Kardos |
659760 |
+ triggerflags = RPMTAG_TRIGGERFLAGS;
|
|
Lubos Kardos |
659760 |
+ triggerscripts = RPMTAG_TRIGGERSCRIPTS;
|
|
Lubos Kardos |
659760 |
+ break;
|
|
Lubos Kardos |
659760 |
+ case FILETRIGGER:
|
|
Lubos Kardos |
659760 |
+ triggerindex = RPMTAG_FILETRIGGERINDEX;
|
|
Lubos Kardos |
659760 |
+ triggerflags = RPMTAG_FILETRIGGERFLAGS;
|
|
Lubos Kardos |
659760 |
+ triggerscripts = RPMTAG_FILETRIGGERSCRIPTS;
|
|
Lubos Kardos |
659760 |
+ break;
|
|
Lubos Kardos |
659760 |
+ case TRANSFILETRIGGER:
|
|
Lubos Kardos |
659760 |
+ triggerindex = RPMTAG_TRANSFILETRIGGERINDEX;
|
|
Lubos Kardos |
659760 |
+ triggerflags = RPMTAG_TRANSFILETRIGGERFLAGS;
|
|
Lubos Kardos |
659760 |
+ triggerscripts = RPMTAG_TRANSFILETRIGGERSCRIPTS;
|
|
Lubos Kardos |
659760 |
+ break;
|
|
Lubos Kardos |
659760 |
+ }
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
- if (!headerGet(h, RPMTAG_TRIGGERINDEX, &indices, HEADERGET_MINMEM)) {
|
|
Lubos Kardos |
659760 |
+ if (!headerGet(h, triggerindex, &indices, HEADERGET_MINMEM)) {
|
|
Lubos Kardos |
659760 |
return 0;
|
|
Lubos Kardos |
659760 |
}
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
- headerGet(h, RPMTAG_TRIGGERFLAGS, &flags, HEADERGET_MINMEM);
|
|
Lubos Kardos |
659760 |
- headerGet(h, RPMTAG_TRIGGERSCRIPTS, &scripts, HEADERGET_MINMEM);
|
|
Lubos Kardos |
659760 |
+ headerGet(h, triggerflags, &flags, HEADERGET_MINMEM);
|
|
Lubos Kardos |
659760 |
+ headerGet(h, triggerscripts, &scripts, HEADERGET_MINMEM);
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
td->flags = RPMTD_ALLOCED | RPMTD_PTR_ALLOCED;
|
|
Lubos Kardos |
659760 |
td->count = rpmtdCount(&scripts);
|
|
Lubos Kardos |
659760 |
@@ -316,6 +384,21 @@ static int triggertypeTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
return 1;
|
|
Lubos Kardos |
659760 |
}
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
+static int triggertypeTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
+{
|
|
Lubos Kardos |
659760 |
+ return triggertypeTagFor(NORMALTRIGGER, h, td, hgflags);
|
|
Lubos Kardos |
659760 |
+}
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
+static int filetriggertypeTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
+{
|
|
Lubos Kardos |
659760 |
+ return triggertypeTagFor(FILETRIGGER, h, td, hgflags);
|
|
Lubos Kardos |
659760 |
+}
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
+static int transfiletriggertypeTag(Header h, rpmtd td, headerGetFlags hgflags)
|
|
Lubos Kardos |
659760 |
+{
|
|
Lubos Kardos |
659760 |
+ return triggertypeTagFor(TRANSFILETRIGGER, h, td, hgflags);
|
|
Lubos Kardos |
659760 |
+}
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
/**
|
|
Lubos Kardos |
659760 |
* Retrieve installed file paths.
|
|
Lubos Kardos |
659760 |
* @param h header
|
|
Lubos Kardos |
659760 |
@@ -873,7 +956,11 @@ static const struct headerTagFunc_s rpmHeaderTagExtensions[] = {
|
|
Lubos Kardos |
659760 |
{ RPMTAG_FILEPROVIDE, fileprovideTag },
|
|
Lubos Kardos |
659760 |
{ RPMTAG_FILEREQUIRE, filerequireTag },
|
|
Lubos Kardos |
659760 |
{ RPMTAG_TRIGGERCONDS, triggercondsTag },
|
|
Lubos Kardos |
659760 |
+ { RPMTAG_FILETRIGGERCONDS, filetriggercondsTag },
|
|
Lubos Kardos |
659760 |
+ { RPMTAG_TRANSFILETRIGGERCONDS, transfiletriggercondsTag },
|
|
Lubos Kardos |
659760 |
{ RPMTAG_TRIGGERTYPE, triggertypeTag },
|
|
Lubos Kardos |
659760 |
+ { RPMTAG_FILETRIGGERTYPE, filetriggertypeTag },
|
|
Lubos Kardos |
659760 |
+ { RPMTAG_TRANSFILETRIGGERTYPE, transfiletriggertypeTag },
|
|
Lubos Kardos |
659760 |
{ RPMTAG_LONGFILESIZES, longfilesizesTag },
|
|
Lubos Kardos |
659760 |
{ RPMTAG_LONGARCHIVESIZE, longarchivesizeTag },
|
|
Lubos Kardos |
659760 |
{ RPMTAG_LONGSIZE, longsizeTag },
|
|
Lubos Kardos |
659760 |
diff --git a/rpmpopt.in b/rpmpopt.in
|
|
Lubos Kardos |
659760 |
index 48c5c55..d930862 100644
|
|
Lubos Kardos |
659760 |
--- a/rpmpopt.in
|
|
Lubos Kardos |
659760 |
+++ b/rpmpopt.in
|
|
Lubos Kardos |
659760 |
@@ -115,6 +115,14 @@ rpm alias --triggerscripts --qf '\
|
|
Lubos Kardos |
659760 |
rpm alias --triggers --triggerscripts \
|
|
Lubos Kardos |
659760 |
--POPTdesc=$"list trigger scriptlets from package(s)"
|
|
Lubos Kardos |
659760 |
|
|
Lubos Kardos |
659760 |
+rpm alias --filetriggerscripts --qf '\
|
|
Lubos Kardos |
659760 |
+[filetrigger%{FILETRIGGERTYPE} scriptlet (using %{FILETRIGGERSCRIPTPROG}) -- \
|
|
Lubos Kardos |
659760 |
+%{FILETRIGGERCONDS}\n%{FILETRIGGERSCRIPTS}\n]\
|
|
Lubos Kardos |
659760 |
+[transfiletrigger%{TRANSFILETRIGGERTYPE} scriptlet (using %{TRANSFILETRIGGERSCRIPTPROG}) -- \
|
|
Lubos Kardos |
659760 |
+%{TRANSFILETRIGGERCONDS}\n%{TRANSFILETRIGGERSCRIPTS}\n]'
|
|
Lubos Kardos |
659760 |
+rpm alias --filetriggers --filetriggerscripts \
|
|
Lubos Kardos |
659760 |
+ --POPTdesc=$"list filetrigger scriptlets from package(s)"
|
|
Lubos Kardos |
659760 |
+
|
|
Lubos Kardos |
659760 |
rpm alias --last --qf '%|INSTALLTIME?{%{INSTALLTIME}}:{000000000}| %{NVRA} %|INSTALLTIME?{%{INSTALLTIME:date}}:{(not installed)}|\n' \
|
|
Lubos Kardos |
659760 |
--pipe "LC_NUMERIC=C sort -r -n | sed 's,^[0-9]\+ ,,' | awk '{printf(\"%-45s %-s\n\", $1, substr($0,length($1)+2))}' " \
|
|
Lubos Kardos |
659760 |
--POPTdesc=$"list package(s) by install time, most recent first"
|
|
Lubos Kardos |
659760 |
diff --git a/tests/rpmgeneral.at b/tests/rpmgeneral.at
|
|
Lubos Kardos |
659760 |
index 312f43b..ac21a40 100644
|
|
Lubos Kardos |
659760 |
--- a/tests/rpmgeneral.at
|
|
Lubos Kardos |
659760 |
+++ b/tests/rpmgeneral.at
|
|
Lubos Kardos |
659760 |
@@ -115,6 +115,7 @@ FILERDEVS
|
|
Lubos Kardos |
659760 |
FILEREQUIRE
|
|
Lubos Kardos |
659760 |
FILESIZES
|
|
Lubos Kardos |
659760 |
FILESTATES
|
|
Lubos Kardos |
659760 |
+FILETRIGGERCONDS
|
|
Lubos Kardos |
659760 |
FILETRIGGERFLAGS
|
|
Lubos Kardos |
659760 |
FILETRIGGERINDEX
|
|
Lubos Kardos |
659760 |
FILETRIGGERNAME
|
|
Lubos Kardos |
659760 |
@@ -122,6 +123,7 @@ FILETRIGGERPRIORITIES
|
|
Lubos Kardos |
659760 |
FILETRIGGERSCRIPTFLAGS
|
|
Lubos Kardos |
659760 |
FILETRIGGERSCRIPTPROG
|
|
Lubos Kardos |
659760 |
FILETRIGGERSCRIPTS
|
|
Lubos Kardos |
659760 |
+FILETRIGGERTYPE
|
|
Lubos Kardos |
659760 |
FILETRIGGERVERSION
|
|
Lubos Kardos |
659760 |
FILEUSERNAME
|
|
Lubos Kardos |
659760 |
FILEVERIFYFLAGS
|
|
Lubos Kardos |
659760 |
@@ -256,6 +258,7 @@ SUPPLEMENTNAME
|
|
Lubos Kardos |
659760 |
SUPPLEMENTNEVRS
|
|
Lubos Kardos |
659760 |
SUPPLEMENTS
|
|
Lubos Kardos |
659760 |
SUPPLEMENTVERSION
|
|
Lubos Kardos |
659760 |
+TRANSFILETRIGGERCONDS
|
|
Lubos Kardos |
659760 |
TRANSFILETRIGGERFLAGS
|
|
Lubos Kardos |
659760 |
TRANSFILETRIGGERINDEX
|
|
Lubos Kardos |
659760 |
TRANSFILETRIGGERNAME
|
|
Lubos Kardos |
659760 |
@@ -263,6 +266,7 @@ TRANSFILETRIGGERPRIORITIES
|
|
Lubos Kardos |
659760 |
TRANSFILETRIGGERSCRIPTFLAGS
|
|
Lubos Kardos |
659760 |
TRANSFILETRIGGERSCRIPTPROG
|
|
Lubos Kardos |
659760 |
TRANSFILETRIGGERSCRIPTS
|
|
Lubos Kardos |
659760 |
+TRANSFILETRIGGERTYPE
|
|
Lubos Kardos |
659760 |
TRANSFILETRIGGERVERSION
|
|
Lubos Kardos |
659760 |
TRIGGERCONDS
|
|
Lubos Kardos |
659760 |
TRIGGERFLAGS
|
|
Lubos Kardos |
659760 |
--
|
|
Lubos Kardos |
659760 |
1.9.3
|
|
Lubos Kardos |
659760 |
|