[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rpm-devel
Subject:    Re: [CVS] RPM: rpm/ CHANGES rpm/lib/ poptQV.c
From:       Jeff Johnson <n3npq () mac ! com>
Date:       2009-01-25 0:49:10
Message-ID: 232F030D-E048-4475-9CEC-1FEB36F8ACBD () mac ! com
[Download RAW message or body]

This patch likely needs some background ...

Over the last year, its increasingly apparent (to me anyways)
that WYSIWIG metadata markup for packages is the only way forward
for software packaging.

So there are 6+ forms of half-baked markup (so far) that need to be
accommodated through --queryformat aka headerSprintf() "templates"
applied to *.rpm packages.

Up till now, the "templates" for the markup have been carried
in /usr/lib/rpm/rpmpopt-X.Y.Y, which has been adequate for proof-of- 
concept
development work.

But RPM (imho) needs to commit to some backing store for markup  
"templates"
in order to, say, share the --yum:primary.xml markup between
"rpm --query" and rpmrepo (my current narrow focus).

So this patch achieves the brutally simple basics of loading
a "template" from backing store, where the "template" follows
C newline escaping conventions, with no "# this is a comment" lines  
permitted.

I'm currently assuming this path
	/usr/lib/rpm/qf/
as a prefix for loading "templates". I already know that the backing  
store (and
the rather crude cut-n-paste in this patch) is going to change
a lot before I'm done.

Hint: For starters, all I/O in RPM typically uses Fopen(3), not open(2).
Are you prepared for a network URI connection to be attempted during
rpm(8) CLI argument processing? I am ...

hth

73 de Jeff

On Jan 24, 2009, at 7:29 PM, Jeff Johnson wrote:

>  RPM Package Manager, CVS Repository
>  http://rpm5.org/cvs/
>   
> ____________________________________________________________________________
>
>  Server: rpm5.org                         Name:   Jeff Johnson
>  Root:   /v/rpm/cvs                       Email:  jbj@rpm5.org
>  Module: rpm                              Date:   25-Jan-2009 01:29:49
>  Branch: HEAD                             Handle: 2009012500294801
>
>  Modified files:
>    rpm                     CHANGES
>    rpm/lib                 poptQV.c
>
>  Log:
>    - jbj: rude & crude backing store for --queryformat templates.
>
>  Summary:
>    Revision    Changes     Path
>    1.2754      +1  -0      rpm/CHANGES
>    2.58        +96 -0      rpm/lib/poptQV.c
>   
> ____________________________________________________________________________
>
>  patch -p0 <<'@@ .'
>  Index: rpm/CHANGES
>   
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>  $ cvs diff -u -r1.2753 -r1.2754 CHANGES
>  --- rpm/CHANGES	23 Jan 2009 23:12:51 -0000	1.2753
>  +++ rpm/CHANGES	25 Jan 2009 00:29:48 -0000	1.2754
>  @@ -1,5 +1,6 @@
>
>   5.2a2 -> 5.2a3:
>  +    - jbj: rude & crude backing store for --queryformat templates.
>       - proyvind: xzdio: accept compression level 0 - 9 (new '0' =  
> former '1' etc.).
>       - proyvind: don't wipe out $DOCDIR when using %doc as it will  
> wipe out any
>   	files that would happen to be installed during %install.
>  @@ .
>  patch -p0 <<'@@ .'
>  Index: rpm/lib/poptQV.c
>   
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
>  $ cvs diff -u -r2.57 -r2.58 poptQV.c
>  --- rpm/lib/poptQV.c	21 Jan 2009 22:24:18 -0000	2.57
>  +++ rpm/lib/poptQV.c	25 Jan 2009 00:29:49 -0000	2.58
>  @@ -195,6 +195,79 @@
>      POPT_TABLEEND
>   };
>
>  +/**
>  + * Read a file into a buffer.
>  + * @param con		context
>  + * @param fn		file name
>  + * @retval *bp		file contents
>  + * @retval *nbp		no. of bytes in file contents
>  + * return		0 on success
>  + */
>  +static int poptSlurp(/*@unused@*/ poptContext con, const char * fn,
>  +		char ** bp, off_t * nbp)
>  +	/*@globals errno, fileSystem, internalState @*/
>  +	/*@modifies *bp, *nbp, errno, fileSystem, internalState @*/
>  +{
>  +    int fdno;
>  +    char * b = NULL;
>  +    off_t nb = 0;
>  +    char * s, * t, * se;
>  +    int rc = POPT_ERROR_ERRNO;	/* assume failure */
>  +
>  +    fdno = open(fn, O_RDONLY);
>  +    if (fdno < 0)
>  +	goto exit;
>  +
>  +    if ((nb = lseek(fdno, 0, SEEK_END)) == (off_t)-1
>  +     || lseek(fdno, 0, SEEK_SET) == (off_t)-1
>  +     || (b = calloc(sizeof(*b), (size_t)nb + 1)) == NULL
>  +     || read(fdno, (char *)b, (size_t)nb) != (ssize_t)nb)
>  +    {
>  +	int oerrno = errno;
>  +	(void) close(fdno);
>  +	errno = oerrno;
>  +	goto exit;
>  +    }
>  +    if (close(fdno) == -1)
>  +	goto exit;
>  +    if (b == NULL || nb <= 0) {
>  +	rc = POPT_ERROR_BADCONFIG;
>  +	goto exit;
>  +    }
>  +    rc = 0;
>  +
>  +   /* Trim out escaped newlines. */
>  +    for (t = b, s = b, se = b + nb; *s && s < se; s++) {
>  +	switch (*s) {
>  +	case '\\':
>  +	    if (s[1] == '\n') {
>  +		s++;
>  +		continue;
>  +	    }
>  +	    /*@fallthrough@*/
>  +	default:
>  +	    *t++ = *s;
>  +	    /*@switchbreak@*/ break;
>  +	}
>  +    }
>  +    *t++ = '\0';
>  +    nb = (off_t)(t - b);
>  +
>  +exit:
>  +    if (rc == 0) {
>  +	*bp = b;
>  +	*nbp = nb;
>  +    } else {
>  +	if (b)
>  +	    free(b);
>  +	*bp = NULL;
>  +	*nbp = 0;
>  +    }
>  +/*@-compdef -nullstate @*/	/* XXX cannot annotate char **  
> correctly */
>  +    return rc;
>  +/*@=compdef =nullstate @*/
>  +}
>  +
>   /* ========== Query specific popt args */
>
>   static void queryArgCallback(poptContext con,
>  @@ -218,6 +291,26 @@
>       case POPT_QUERYFORMAT:
>   	if (arg) {
>   	    char * qf = (char *)qva->qva_queryFormat;
>  +	    char * b = NULL;
>  +	    off_t nb = 0;
>  +
>  +	    /* Read queryformat from file. */
>  +	    if (arg[0] == '/') {
>  +		const char * fn = arg;
>  +		int rc;
>  +
>  +		if ((rc = poptSlurp(con, fn, &b, &nb)) != 0)
>  +		    goto _qfexit;
>  +		if (b == NULL || nb <= 0)
>  +		    goto _qfexit;
>  +		/* XXX trim trailing newline(s). */
>  +		nb--;		/* XXX skip final NUL */
>  +		while (nb > 0 && b[nb-1] == '\n')
>  +		    b[--nb] = '\0';
>  +		arg = b;
>  +	    }
>  +
>  +	    /* Append to existing queryformat. */
>   	    if (qf) {
>   		size_t len = strlen(qf) + strlen(arg) + 1;
>   		qf = xrealloc(qf, len);
>  @@ -227,6 +320,9 @@
>   		strcpy(qf, arg);
>   	    }
>   	    qva->qva_queryFormat = qf;
>  +
>  +	_qfexit:
>  +	    b = _free(b);
>   	}
>   	break;
>
>  @@ .
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> CVS Sources Repository                                rpm-cvs@rpm5.org


["smime.p7s" (smime.p7s)]

0	*H
 010	+0	*H
 00 rk 0
	*H
0|10	UDE10U
TC TrustCenter GmbH1%0#UTC TrustCenter Class 1 L1 CA1(0&UTC TrustCenter \
Class 1 L1 CA VI0 081202135405Z
091203135405Z0B10	UUS10UJeff Johnson10	*H
	
n3npq@mac.com0"0
	*H
0
Ҭ14B~:*;˄rx%I"^~22Wń9i,#O))~SC	` \
˨ŕ1i!~I5S)R&Ϥ(tuIAЈTOb߁>fN*5Q<1Rn&,f`iR!S~WUzsB \
SNg>Ox>ɐ{FMк00+00Q+0Eh \
ttp://www.trustcenter.de/certservices/cacerts/tc_class1_L1_CA_VI.crt02+0&http \
://ocsp.VI.tcclass1.trustcenter.de0U#0NjkJɻdK&0U00JU \
C0A0?	*,0200+$http://www.trustcenter.de/guidelines0U0UDL荺e9=7N&d?0TUM0K0I \
G EChttp://crl.VI.tcclass1.trustcenter.de/crl/v2/tc_class1_L1_CA_VI.crl03U%,0*+++
 +70U0
n3npq@mac.com0
	*H
c3#5@+Nwc<~3mJ \
2݉}dsOM3/cCåt(:ӌmxH#F?&N^?6c"*-7lu`+x|W \
ʕnbgҮV4H008 bnrd0 	*H
010	UDE10UHamburg10UHamburg1:08U
1TC TrustCenter for Security in Data Networks GmbH1"0 UTC TrustCenter Class 1 \
CA1)0'	*H 	certificate@trustcenter.de0
080718113854Z
101231225959Z0|10	UDE10U
TC TrustCenter GmbH1%0#UTC TrustCenter Class 1 L1 CA1(0&UTC TrustCenter \
Class 1 L1 CA VI00 	*H
0?N~ݤ㰾(ݙuLαlK%8H
~uH@MNCm]9Xq
K1~_݄Vfk(ѢzaW00'
@00+00L+0@http://www.trustcenter.de/certservices/ \
cacerts/tc_class_1_ca.crt0/+0#http://ocsp.tcclass1.trustcenter.de0U00JU \
C0A0?	*,0200+$http://www.trustcenter.de/guidelines0U0UNjkJɻdK&0U00 \
 ؆;http://crl.tcclass1.trustcenter.de/crl/v2/tc_class_1_ca.crlldap://www.trustc \
enter.de/CN=TC%20TrustCenter%20Class%201%20CA,O=TC%20TrustCenter%20AG,ou=rootcerts,dc=trustcenter,dc=de?certificateRevocationList?base?0
 	*H
ng,<H[<KB*8ُ˰y}e-pT-):mnzq/eJ̄tZմw"D˴W\&8kT.WƎ|W[30(0 \
0 	*H
0y10U
Root CA10Uhttp://www.cacert.org1"0 UCA Cert Signing \
Authority1!0	*H 	support@cacert.org0
070806160927Z
090805160927Z0810UCAcert WoT User10	*H
	
n3npq@mac.com0"0
	*H
0
MǼ~arqC?j(Ѝ.=
ܐ[m47囵{Hǰmgk׼=FlFَ^ \
c9hٕ/,fOcY;ik"XFS	)֟W:Z#AqW:_rIqc&ZZAKBH
 oY_x(V!zd	AHDJAdG*QXVr:tpM00U00V	`HB
 IGTo get your own certificate for FREE head over to \
http://www.CAcert.org0@U%907++ +7

+7
	`HB02+&0$0"+0http://ocsp.cacert.org0U0
n3npq@mac.com0
	*H
BmC2G$+`?kdC
o߫'iƬ'9\q459xOS@B= \
49ێ0أZ-n!Hrλy)gPmcFkrzGr1d3)g"LZ\bkR&h@[%|%@ht'?Нc]y4J


m
!ϵ[4QB}bK_gD,	?
wG:U\XC\!}i)7%7ufmW]-x|̭QćHxNF%3z3rR>~c͛y2GL<n#K/
  (_Q7nfrCejT \
q$,76ICm@C@)H4{\ZX̢T@niQjcN'.i. +(a
=F(>O1B0>00|10	UDE10U
TC TrustCenter GmbH1%0#UTC TrustCenter Class 1 L1 CA1(0&UTC TrustCenter \
Class 1 L1 CA VIrk 0	+ 0	*H 	1	*H
0	*H
	1
090125004911Z0#	*H
	1 3ƈ,f?"̔0	+7100y10U
Root CA10Uhttp://www.cacert.org1"0 UCA Cert Signing \
Authority1!0	*H 	support@cacert.org0*H
	1 0y10U
Root CA10Uhttp://www.cacert.org1"0 UCA Cert Signing \
Authority1!0	*H 	support@cacert.org0
	*H
HcS2Ov!^{Ѹ5n=̺=h봒t:u
!!"2O

-3
lW'yh<XSs4Z2|(֖:sIx&t]Yw8)Yso=3PE?Elс;mn? \
RA^k901bDi`^-Q"48'L/f)(;h<;ֶHu_#Zpfquk



______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
Developer Communication List                        rpm-devel@rpm5.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic