On Jun 13, 2008, at 7:59 AM, devzero2000 wrote:
Jeff,
Kindly, it would be possible to know better the objective of this
patch ?
Sure.
The short & easy answer is as follows:
At this link
http://rpm5.org/community/rpm-devel/2608.html
Ralf suggested a syntax for matching/substituting
--queryformat pipe line data values.
(aside) What I actually need is selector patterns on
tag keys, not tag data; I'll get there eventually.
I've managed to get a find-and-replace mechanism
implemented using the simpler format extension
:strsub(foo,bar)
(aside) I have not attempted the requested (perfectly intuitive
and obvious) syntax
s/foo/bar/g
yet. Attaching a syntax to the :strsub(foo,bar)
will require a rewrite of the headerSprintf() --queryformat with
a grammar to accomodate white space token separation and
more. And %{lua:...} is still too complicated an implementation
to attach to the rather fragile --queryformat pipeline atm.
Not forgotten, just not yet. But I digress ...
You are looking at the "spewage" that I used to get
find-and-replace implemented underneath --queryformat.
Specifically, I spent way too much time (find-and-replace is
a tedious implementation un C) staring at this specific construct
in the --deb:control spewage
...
\nDescription: %{SUMMARY}\
\n%{DESCRIPTION:strsub(^, )}\
...
(aside) I mean "spewage" literally, I used dpkg only because
debian/control et al metadata format is simpler, more regular,
easier to debug, etc etc "spewage" than say, the SuSE *.solv
format, or Mac OS X plists or apt genbasedir metadata.
Perhaps the plan of re-unification or interoperability with deb has
resumed? Just for a better understanding.
Hehe, I was assigned the task of unifying dpkg <-> rpm during
RHL 6.0 release and given *TWO WHOLE WEEKS* to accomplish the
task, thank you Erik!. ;-) I certainly have not forgotten the goal of a
"unified package manager"
for Linux in the last decade. Howvere, I am frequently distracted by
other needed
implementations.
But there's a bit more Debian "spewage" processing that is needed
(and likely
other details ;-) before "unification" or "interoperability" can be
engineered.
E.g. I need to add debdepends et al header extension tags to map
rpm dependencies into package dependencies, and change the
"spewage" syntax with patterns like
Requires: foo >= 1:2.3-4
into
Depends: foo (>= 1:2.3-4)
The find-and-replace will need additional header tag/fmt extensions,
not hard.
With the above "spewage" transforms, it would not be any harder to
teach rpmbuild to produce *.deb packages in addition
to *.rpm packages than it was to create rpmrepo. There's more
commonality
(unsurprisingly) in rpm <-> deb metadata than there is in rpm-metadata.
(aside) That's even more true now that (some fork of) dpkg supports
triggers.
Please note that the fundamental reason why RPM <-> DEB
packages cannot be "unified" or otherwise become "interoperable"
is that the package name space values are different. Fixing the
name space deviations will require a rather complicated name
(and perhaps version, release, ...) remapping through a reliable
persistent mapping store of values (aka a "registry") to accomplish
the engineering.
(aside)Too bad that LSB lacks the cojones to attempt to help identify
what package names are currently in use by various distros.
But I digress ...
hth
73 de Jeff
Best regards
On Fri, Jun 13, 2008 at 10:32 AM, Jeff Johnson <[EMAIL PROTECTED]> wrote:
RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
______________________________________________________________________
______
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: [EMAIL PROTECTED]
Module: rpm Date: 13-Jun-2008 10:32:02
Branch: HEAD Handle: 2008061308320101
Modified files:
rpm CHANGES rpmpopt.in
rpm/rpmdb hdrfmt.c
Log:
- add --deb:foo aliases for *.deb spewage.
Summary:
Revision Changes Path
1.2411 +1 -0 rpm/CHANGES
1.107 +68 -7 rpm/rpmdb/hdrfmt.c
2.66 +89 -1 rpm/rpmpopt.in
______________________________________________________________________
______
patch -p0 <<'@@ .'
Index: rpm/CHANGES
======================================================================
======
$ cvs diff -u -r1.2410 -r1.2411 CHANGES
--- rpm/CHANGES 13 Jun 2008 06:18:56 -0000 1.2410
+++ rpm/CHANGES 13 Jun 2008 08:32:01 -0000 1.2411
@@ -1,5 +1,6 @@
5.1.0 -> 5.2a0:
+ - jbj: add --deb:foo aliases for *.deb spewage.
- jbj: rework :strsub find-and-replace to use mire patterns.
- jbj: mire: add REG_NEWLINE to default regex compilation.
- jbj: add :strsub format extension find-and-replace using
posix RE's.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/hdrfmt.c
======================================================================
======
$ cvs diff -u -r1.106 -r1.107 hdrfmt.c
--- rpm/rpmdb/hdrfmt.c 13 Jun 2008 06:18:57 -0000 1.106
+++ rpm/rpmdb/hdrfmt.c 13 Jun 2008 08:32:02 -0000 1.107
@@ -20,7 +20,7 @@
*__inbuf, *__inbytesleft, *__outbuf, *__outbytesleft
@*/;
extern int iconv_close(/[EMAIL PROTECTED]@*/ iconv_t __cd)
- /[EMAIL PROTECTED] __cd @*/;
+ /[EMAIL PROTECTED] __cd @*/;
/[EMAIL PROTECTED] =incondefs @*/
#endif
#endif
@@ -2345,6 +2345,65 @@
return _fnTag(h, he);
}
+/**
+ * Retrieve digest/path pairs for --deb:md5sums.
+ * @param h header
+ * @retval *he tag container
+ * @return 0 on success
+ */
+static int debmd5sumsTag(Header h, HE_t he)
+ /[EMAIL PROTECTED] he @*/
+{
+ HE_t nhe = memset(alloca(sizeof(*nhe)), 0, sizeof(*nhe));
+ HE_t dhe = memset(alloca(sizeof(*dhe)), 0, sizeof(*dhe));
+ char * t, * te;
+ size_t nb = 0;
+ int rc = 1;
+ int xx;
+ int i;
+
+ nhe->tag = RPMTAG_FILEPATHS;
+ if (!(xx = headerGet(h, nhe, 0)))
+ goto exit;
+ dhe->tag = RPMTAG_FILEDIGESTS;
+ if (!(xx = headerGet(h, dhe, 0)))
+ goto exit;
+
+ he->tag = tagValue("Debmd5sums");
+ he->t = RPM_STRING_ARRAY_TYPE;
+ he->c = 0;
+ he->freeData = 1;
+ for (i = 0; i < (int)dhe->c; i++) {
+ if (!(dhe->p.argv[i] && *dhe->p.argv[i]))
+ continue;
+ nb += sizeof(*he->p.argv);
+ nb += strlen(dhe->p.argv[i]) + sizeof(" ") + strlen(nhe-
>p.argv[i]) - 1;
+ he->c++;
+ }
+ nb += sizeof(*he->p.argv);
+
+ he->p.argv = xmalloc(nb);
+ te = (char *) &he->p.argv[he->c+1];
+
+ he->c = 0;
+ for (i = 0; i < (int)dhe->c; i++) {
+ if (!(dhe->p.argv[i] && *dhe->p.argv[i]))
+ continue;
+ he->p.argv[he->c++] = te;
+ t = rpmExpand(dhe->p.argv[i], " ", nhe->p.argv[i]+1, NULL);
+ te = stpcpy(te, t);
+ te++;
+ t = _free(t);
+ }
+ he->p.argv[he->c] = NULL;
+ rc = 0;
+
+exit:
+ nhe->p.ptr = _free(nhe->p.ptr);
+ dhe->p.ptr = _free(dhe->p.ptr);
+ return rc;
+}
+
static int filestatTag(Header h, HE_t he)
/[EMAIL PROTECTED] he @*/
{
@@ -3777,6 +3836,8 @@
{ .tagFunction = F1sqlTag } },
{ HEADER_EXT_TAG, "RPMTAG_FILESSQLENTRY2",
{ .tagFunction = F2sqlTag } },
+ { HEADER_EXT_TAG, "RPMTAG_DEBMD5SUMS",
+ { .tagFunction = debmd5sumsTag } },
{ HEADER_EXT_FORMAT, "armor",
{ .fmtFunction = armorFormat } },
{ HEADER_EXT_FORMAT, "base64",
@@ -3928,11 +3989,11 @@
*/
struct sprintfToken_s {
enum {
- PTOK_NONE = 0,
- PTOK_TAG = 1,
- PTOK_ARRAY = 2,
- PTOK_STRING = 3,
- PTOK_COND = 4
+ PTOK_NONE = 0,
+ PTOK_TAG = 1,
+ PTOK_ARRAY = 2,
+ PTOK_STRING = 3,
+ PTOK_COND = 4
} type;
union {
struct sprintfTag_s tag; /*!< PTOK_TAG */
@@ -4624,7 +4685,7 @@
/[EMAIL PROTECTED]@*/
if (dst != NULL)
- *dst = '\0';
+ *dst = '\0';
for (i = 0; i < (unsigned) numTokens; i++) {
token = format + i;
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmpopt.in
======================================================================
======
$ cvs diff -u -r2.65 -r2.66 rpmpopt.in
--- rpm/rpmpopt.in 29 May 2008 13:45:20 -0000 2.65
+++ rpm/rpmpopt.in 13 Jun 2008 08:32:01 -0000 2.66
@@ -2,7 +2,7 @@
# \verbatim
#
# @USRLIBRPM@/@configure_input@
-# $Id: rpmpopt.in,v 2.65 2008/05/29 13:45:20 jbj Exp $
+# $Id: rpmpopt.in,v 2.66 2008/06/13 08:32:01 jbj Exp $
#
# This file *should not be modified*. Local customizations
# belong in /etc/popt, not here. This file will be replaced
@@ -103,6 +103,94 @@
--POPTdesc=$"list metadata in yaml"
#=====================================================================
=========
+rpm alias --deb:control --qf '\
+Package: %{NAME}\
+\nVersion: %|EPOCH?{%{EPOCH}:}|%{VERSION}-%{RELEASE}\
+\nSection: %{GROUP}\
+%|Priority?{\
+\nPriority: %{Priority}\
+}:{\
+\nPriority: standard\
+}|\
+\nArchitecture: %{ARCH:strsub(noarch,all,src,source)}\
+%|Essential?{\
+\nEssential: %{Essential}\
+}|\
+%|REQUIRENAME?{\
+\nDepends:[ %{REQUIRENAME:contains(N)}]\
+}|\
+%|Predepends?{\
+\nPre-Depends:[ %{Predepends}]\
+}|\
+%|Recommends?{\
+\nRecommends:[ %{Recommends}]\
+}|\
+%|Suggests?{\
+\nSuggests:[ %{Suggests}]\
+}|\
+%|Enhances?{\
+\nEnhances:[ %{Enhances}]\
+}|\
+%|Breaks?{\
+\nBreaks:[ %{Breaks}]\
+}|\
+%|CONFLICTNAME?{\
+\nConflicts:[ %{CONFLICTNAME:contains(N)}]\
+}|\
+\nInstalled-Size: %{SIZE}\
+%|PACKAGER?{\
+\nMaintainer: %{PACKAGER}\
+}|\
+\nDescription: %{SUMMARY}\
+\n%{DESCRIPTION:strsub(^, )}\
+%|URL?{\
+\nHomepage: %{URL}\
+}|\
+\n' \
+ --POPTdesc=$"display binary debian/control file"
+
+rpm alias --deb:preinst --qf '\
+%|PREIN?{\
+%|PREINPROG?{#!%{PREINPROG})}:{#!/bin/sh}|\
+\n%{PREIN}\
+}|\
+\n' \
+ --POPTdesc=$"display debian/preinst script"
+
+rpm alias --deb:postinst --qf '\
+%|POSTIN?{\
+%|POSTINPROG?{#!%{POSTINPROG})}:{#!/bin/sh}|\
+\n%{POSTIN}\
+}|\
+\n' \
+ --POPTdesc=$"display debian/postinst script"
+
+rpm alias --deb:prerm --qf '\
+%|PREUN?{\
+%|PREUNPROG?{#!%{PREUNPROG})}:{#!/bin/sh}|\
+\n%{PREUN}\
+}|\
+\n' \
+ --POPTdesc=$"display debian/prerm script"
+
+rpm alias --deb:postrm --qf '\
+%|POSTUN?{\
+%|POSTUNPROG?{#!%{POSTUNPROG})}:{#!/bin/sh}|\
+\n%{POSTUN}\
+}|\
+\n' \
+ --POPTdesc=$"display debian/postrm script"
+
+rpm alias --deb:md5sums --qf '\
+%|FILENAMES?{\
+[\
+%{Debmd5sums}\n\
+]\
+}|\
+' \
+ --POPTdesc=$"display debian/md5sums manifest"
+
+#====================================================================
==========
rpm alias --yum:primary.xml --qf '\
<package type="rpm">\
\n <name>%{NAME:cdata}</name>\
@@ .
______________________________________________________________________
RPM Package Manager http://rpm5.org
CVS Sources Repository [EMAIL PROTECTED]