added --script querying
authorewt <devnull@localhost>
Mon, 15 Apr 1996 22:21:30 +0000 (22:21 +0000)
committerewt <devnull@localhost>
Mon, 15 Apr 1996 22:21:30 +0000 (22:21 +0000)
CVS patchset: 544
CVS date: 1996/04/15 22:21:30

query.c
query.h

diff --git a/query.c b/query.c
index d96982c..b0f44a2 100644 (file)
--- a/query.c
+++ b/query.c
@@ -27,6 +27,7 @@ static void printFileInfo(char * name, unsigned int size, unsigned short mode,
                          unsigned int mtime, unsigned short rdev,
                          char * owner, char * group, int uid, int gid,
                          char * linkto);
+static void printScript(Header h, char * label, int tag);
 
 static char * defaultQueryFormat = 
            "Name        : %-27{NAME} Distribution: %{DISTRIBUTION}\n"
@@ -278,6 +279,23 @@ static void printHeader(Header h, int queryFlags, char * queryFormat) {
                if (fileGroupList) free(fileGroupList);
            }
        }
+
+       if (queryFlags & QUERY_FOR_SCRIPTS) {
+           printScript(h, "preinstall script:\n", RPMTAG_PREIN);
+           printScript(h, "postinstall script:\n", RPMTAG_POSTIN);
+           printScript(h, "preuninstall script:\n", RPMTAG_PREUN);
+           printScript(h, "preuninstall script:\n", RPMTAG_POSTUN);
+       }
+    }
+}
+
+static void printScript(Header h, char * label, int tag) {
+    int type, count;
+    char * script;
+
+    if (getEntry(h, tag, &type, (void **) &script, &count)) {
+       printf("%s", label);
+       printf("%s\n", script);
     }
 }
 
diff --git a/query.h b/query.h
index 1964fa5..e4d11a9 100644 (file)
--- a/query.h
+++ b/query.h
@@ -7,11 +7,12 @@ enum querysources { QUERY_PATH, QUERY_PACKAGE, QUERY_ALL, QUERY_SPATH,
                    QUERY_SPACKAGE, QUERY_RPM, QUERY_SRPM, QUERY_GROUP,
                    QUERY_SGROUP };
 
-#define QUERY_FOR_INFO 1
-#define QUERY_FOR_LIST 2
-#define QUERY_FOR_STATE 4
-#define QUERY_FOR_DOCS 8
-#define QUERY_FOR_CONFIG 16
+#define QUERY_FOR_INFO                 (1 << 0)
+#define QUERY_FOR_LIST         (1 << 1)
+#define QUERY_FOR_STATE                (1 << 2)
+#define QUERY_FOR_DOCS         (1 << 3)
+#define QUERY_FOR_CONFIG       (1 << 4)
+#define QUERY_FOR_SCRIPTS      (1 << 5)
 
 int doQuery(char * prefix, enum querysources source, int queryFlags, 
             char * arg, char * queryFormat);