[Rpm-maint] [Suse patch] Check rpm payload format

Panu Matilainen pmatilai at redhat.com
Wed May 23 06:49:54 UTC 2007


On Tue, 22 May 2007, Panu Matilainen wrote:
> And since it's supposed to be consistent, I don't see any problem putting in 
> a specific check for drpm payload (and telling the user it can't be directly 
> installed), similarly to what Suse's patch does.

Thought might just as well add the checking of supported payload format 
into API instead of putting all the details into rpmtsAddInstallElement() 
where it doesn't belong... this acceptable for everybody? :)

 	- Panu -


diff -r 45b8d8cfd07e lib/depends.c
--- a/lib/depends.c	Wed May 23 08:40:22 2007 +0300
+++ b/lib/depends.c	Wed May 23 09:43:18 2007 +0300
@@ -157,6 +157,12 @@ int rpmtsAddInstallElement(rpmts ts, Hea
      xx = hge(h, RPMTAG_OS, NULL, (void **)&os, NULL);
      hcolor = hGetColor(h);
      pkgKey = RPMAL_NOMATCH;
+
+    /* Check for supported payload format */
+    if (headerCheckPayload(h) != RPMRC_OK) {
+	ec = 1;
+	goto exit;
+    }

      /* XXX Always add source headers. */
      isSource = headerIsEntry(h, RPMTAG_SOURCEPACKAGE);
diff -r 45b8d8cfd07e lib/package.c
--- a/lib/package.c	Wed May 23 08:40:22 2007 +0300
+++ b/lib/package.c	Wed May 23 09:42:34 2007 +0300
@@ -1064,4 +1064,36 @@ exit:
      sigh = rpmFreeSignature(sigh);
      return rc;
  }
+
+/**
+ * Check for supported payload format in header.
+ * @param h		header to check
+ * @return		RPMRC_OK if supported, RPMRC_FAIL otherwise
+ */
+rpmRC headerCheckPayload(Header h) {
+    rpmRC rc = RPMRC_FAIL;
+    int xx;
+    const char *payloadfmt = NULL;
+
+    xx = headerGetEntry(h, RPMTAG_PAYLOADFORMAT, NULL, 
+			(void **)&payloadfmt, NULL);
+    if (payloadfmt && strncmp(payloadfmt, "cpio", strlen("cpio")) == 0) {
+	rc = RPMRC_OK;
+    } else {
+        const char *nevra = hGetNEVRA(h, NULL);
+        if (strncmp(payloadfmt, "drpm", strlen("drpm")) == 0) {
+            rpmMessage(RPMMESS_ERROR,
+                     _("%s is a Delta RPM and cannot be directly installed\n"),
+                     nevra);
+        } else {
+            rpmMessage(RPMMESS_ERROR, 
+                     _("Unsupported payload (%s) in package %s\n"),
+                     payloadfmt, nevra);
+        } 
+        nevra = _free(nevra);
+    }
+    return rc;
+}
+
+
  /*@=bounds@*/
diff -r 45b8d8cfd07e lib/rpmlib.h
--- a/lib/rpmlib.h	Wed May 23 08:40:22 2007 +0300
+++ b/lib/rpmlib.h	Wed May 23 09:37:25 2007 +0300
@@ -893,6 +893,13 @@ int headerVerifyInfo(int il, int dl, con
  int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate)
  	/*@modifies *iv @*/;

+/**
+ * Check for supported payload format in header.
+ * @param h		header to check
+ * @return		RPMRC_OK if supported, RPMRC_FAIL otherwise
+ */
+rpmRC headerCheckPayload(Header h);
+
  /**
   * Check header consistency, performing headerGetEntry() the hard way.
   *



More information about the Rpm-maint mailing list