some rpm.org derived patches

2007-12-11 Thread Per Øyvind Karlsen
Would anyone mind me commiting these patches derived from rpm.org to HEAD  
rpm-4_5?
-- 
Regards,
Per Øyvind Karlsen
Mandriva Norway
--- /home/peroyvind/Dokumenter/mandriva/rpmstuff/rpm4.5/rpm-4.5/lib/librpm.vers	2007-12-11 15:45:28.0 +0100
+++ lib/librpm.vers	2007-12-11 15:36:37.0 +0100
@@ -247,6 +247,8 @@ LIBRPM_0
 rpmpsGetProblem;
 rpmProblemGetPkgNEVR;
 rpmProblemGetAltNEVR;
+rpmProblemGetStr;
+rpmProblemGetLong;
 rpmProblemGetType;
 rpmProblemKey;
 rpmQueryPoptTable;
--- /home/peroyvind/Dokumenter/mandriva/rpmstuff/rpm4.5.old/rpm/lib/rpmps.h	2007-06-06 02:08:08.0 +0200
+++ lib/rpmps.h	2007-12-11 23:59:49.0 +0100
@@ -223,6 +223,24 @@ char * rpmProblemGetAltNEVR(rpmProblem p
 	/[EMAIL PROTECTED]/;
 
 /**
+ * Return a generic data string from a problem
+ * @param prob		rpm problem
+ * @return		a generic data string
+ * @todo		needs a better name
+ */
+char * rpmProblemGetStr(rpmProblem prob)
+	/[EMAIL PROTECTED]/;
+
+/**
+ * Return generic pointer/long attribute from a problem
+ * @param prob		rpm problem
+ * @return		a generic pointer/long attribute
+ * @todo		needs a better name
+ */
+unsigned long long rpmProblemGetLong(rpmProblem prob)
+	/[EMAIL PROTECTED]/;
+
+/**
  * Return the problem type
  *
  * @param prob  rpm problem
--- /home/peroyvind/Dokumenter/mandriva/rpmstuff/rpm4.5.old/rpm/lib/rpmps.c	2007-06-06 02:08:08.0 +0200
+++ lib/rpmps.c	2007-12-11 23:59:17.0 +0100
@@ -359,6 +359,16 @@ char * rpmProblemGetAltNEVR(rpmProblem p
 return(prob-altNEVR);
 }
 
+char * rpmProblemGetStr(rpmProblem prob)
+{
+return(prob-str1);
+}
+
+unsigned long long rpmProblemGetLong(rpmProblem prob)
+{
+return(prob-ulong1);
+}
+
 rpmProblemType rpmProblemGetType(rpmProblem prob)
 {
 return(prob-type);
--- /home/peroyvind/Dokumenter/mandriva/rpmstuff/rpm4.5.old/rpm/lib/rpmts.c	2007-12-09 18:46:48.0 +0100
+++ lib/rpmts.c	2007-12-11 22:11:59.0 +0100
@@ -11,6 +11,9 @@
 #define	_RPMDB_INTERNAL		/* XXX almost opaque sigh */
 #include rpmdb.h		/* XXX stealing db-db_mode. */
 
+#define	_RPMEVR_INTERNAL	/* XXX RPMSENSE_KEYRING */
+#include rpmevr.h
+
 #include rpmal.h
 #include rpmds.h
 #include rpmfi.h
@@ -385,6 +388,138 @@ exit:
 return res;
 }
 
+rpmRC rpmtsImportPubkey(const rpmts ts, const unsigned char * pkt, ssize_t pktlen)
+{
+static unsigned char zeros[] =
+	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+const char * afmt = %{pubkeys:armor};
+const char * group = Public Keys;
+const char * license = pubkey;
+const char * buildhost = localhost;
+int32_t pflags = (RPMSENSE_KEYRING|RPMSENSE_EQUAL);
+int32_t zero = 0;
+pgpDig dig = NULL;
+pgpDigParams pubp = NULL;
+const char * d = NULL;
+const char * enc = NULL;
+const char * n = NULL;
+const char * u = NULL;
+const char * v = NULL;
+const char * r = NULL;
+const char * evr = NULL;
+Header h = NULL;
+rpmRC rc = RPMRC_FAIL;		/* assume failure */
+char * t;
+int xx;
+
+if (pkt == NULL || pktlen = 0)
+	return RPMRC_FAIL;
+if (rpmtsOpenDB(ts, (O_RDWR|O_CREAT)))
+	return RPMRC_FAIL;
+
+if ((enc = b64encode(pkt, pktlen)) == NULL)
+	goto exit;
+
+dig = pgpNewDig();
+
+/* Build header elements. */
+(void) pgpPrtPkts(pkt, pktlen, dig, 0);
+pubp = dig-pubkey;
+
+if (!memcmp(pubp-signid, zeros, sizeof(pubp-signid))
+ || !memcmp(pubp-time, zeros, sizeof(pubp-time))
+ || pubp-userid == NULL)
+	goto exit;
+
+v = t = xmalloc(16+1);
+t = stpcpy(t, pgpHexStr(pubp-signid, sizeof(pubp-signid)));
+
+r = t = xmalloc(8+1);
+t = stpcpy(t, pgpHexStr(pubp-time, sizeof(pubp-time)));
+
+n = t = xmalloc(sizeof(gpg())+8);
+t = stpcpy( stpcpy( stpcpy(t, gpg(), v+8), ));
+
+/* FIX: pubp-userid may be NULL */
+u = t = xmalloc(sizeof(gpg())+strlen(pubp-userid));
+t = stpcpy( stpcpy( stpcpy(t, gpg(), pubp-userid), ));
+
+evr = t = xmalloc(sizeof(4X:-)+strlen(v)+strlen(r));
+t = stpcpy(t, (pubp-version == 4 ? 4: : 3:));
+t = stpcpy( stpcpy( stpcpy(t, v), -), r);
+
+/* Check for pre-existing header. */
+
+/* Build pubkey header. */
+h = headerNew();
+
+xx = headerAddOrAppendEntry(h, RPMTAG_PUBKEYS,
+			RPM_STRING_ARRAY_TYPE, enc, 1);
+
+d = headerSprintf(h, afmt, rpmTagTable, rpmHeaderFormats, NULL);
+if (d == NULL)
+	goto exit;
+
+xx = headerAddEntry(h, RPMTAG_NAME, RPM_STRING_TYPE, gpg-pubkey, 1);
+xx = headerAddEntry(h, RPMTAG_VERSION, RPM_STRING_TYPE, v+8, 1);
+xx = headerAddEntry(h, RPMTAG_RELEASE, RPM_STRING_TYPE, r, 1);
+xx = headerAddEntry(h, RPMTAG_DESCRIPTION, RPM_STRING_TYPE, d, 1);
+xx = headerAddEntry(h, RPMTAG_GROUP, RPM_STRING_TYPE, group, 1);
+xx = headerAddEntry(h, RPMTAG_LICENSE, RPM_STRING_TYPE, license, 1);
+xx = headerAddEntry(h, RPMTAG_SUMMARY, RPM_STRING_TYPE, u, 1);
+
+xx = headerAddEntry(h, RPMTAG_SIZE, RPM_INT32_TYPE, zero, 1);
+
+xx = 

Re: some rpm.org derived patches

2007-12-11 Thread Jeff Johnson


On Dec 11, 2007, at 6:39 PM, Per Øyvind Karlsen wrote:

Would anyone mind me commiting these patches derived from rpm.org  
to HEAD 

rpm-4_5?


Neither patch matters much at all.

Note that rpm-4.5 uses unsigned long long, not unsigned long as  
rpm.org does afaik.


If you feel the need for a wrapper and opaqueness, then by all means,  
add the patch.


The other patch does nothing other than
s/rpmcliImportPubkey/rpmtsImportPubkey/
and moves the routine from lib/rpmchecksig.c to lib/rpmts.c.

Note that pubkey handling in rpm-5.0 has been entirely rewritten,
pubkeys are no longer attached to a transaction set, so that other
alternative key ring implementations can be attempted without
the necessity of carrying a transaction set around.

73 de Jeff__
RPM Package Managerhttp://rpm5.org
Developer Communication Listrpm-devel@rpm5.org


Re: some rpm.org derived patches

2007-12-11 Thread Per Øyvind Karlsen
I noticed that my second patch was a bit zealotish, more correct one is at 
http://hg.rpm.org/rpm?cs=053b7741a883 , okay to adapt and commit?
Or should it stay as it is?
-- 
Regards,
Per Øyvind Karlsen
Mandriva Norway
__
RPM Package Managerhttp://rpm5.org
Developer Communication Listrpm-devel@rpm5.org


Re: some rpm.org derived patches

2007-12-11 Thread Per Øyvind Karlsen
 Neither patch matters much at all.

 Note that rpm-4.5 uses unsigned long long, not unsigned long as  
 rpm.org does afaik.
I've done it our way in my patch :)

 If you feel the need for a wrapper and opaqueness, then by all means,  
 add the patch.

 The other patch does nothing other than
      s/rpmcliImportPubkey/rpmtsImportPubkey/
 and moves the routine from lib/rpmchecksig.c to lib/rpmts.c.
yes, I figured out that just myself after looking closer, I'm a bit too hasty 
while figuring out things and differences in URPM.xs..

For maximum compatibility and easier maintenance, may I follow rpm.org 
renaming for rpm-4_5?

 Note that pubkey handling in rpm-5.0 has been entirely rewritten,
 pubkeys are no longer attached to a transaction set, so that other
 alternative key ring implementations can be attempted without
 the necessity of carrying a transaction set around.

-- 
Regards,
Per Øyvind Karlsen
Mandriva Norway
__
RPM Package Managerhttp://rpm5.org
Developer Communication Listrpm-devel@rpm5.org


Re: some rpm.org derived patches

2007-12-11 Thread Jeff Johnson


On Dec 11, 2007, at 8:29 PM, Per Øyvind Karlsen wrote:

I noticed that my second patch was a bit zealotish, more correct  
one is at

http://hg.rpm.org/rpm?cs=053b7741a883 , okay to adapt and commit?
Or should it stay as it is?


Make yourself happy. Names and locations of routines matter only
to those who think rpmlib needs an API/ABI, and attempting an API/ABI  
when

multiple forks of rpm exist is pointless.

The reason for rpmcliImportPubkey naming was to have all CLI modes
of rpm have a common rpmcliFoo prefix. The rpmts object is at a lower
layer then the CLI routines, and there is no known usage case for  
importing

pubkeys at the rpmts layer.

FWIW, one of the flaws of the rpmlib API is that most applications are
trying to get at rpmlib innards like rpmtsFoo rather than using
the far simpler rpmcliFoo API. But that's the rpmlib hysterical  
accident,

taking an installer API and trying to turn it into a useful package API.

Go fer the checkin!

73 de Jeff__
RPM Package Managerhttp://rpm5.org
Developer Communication Listrpm-devel@rpm5.org