Bug#46671: dpkg: /usr/share, and libdpkg issues
Package: dpkg
Version: 1.4.1.6
Severity: normal
Hello world,
dpkg installs dpkg.h in /usr/share/include/dpkg/, which gcc doesn't search
by default. /usr/include would seem a more sensible place.
Also, since dpkg-dev and dpkg both use /usr/doc/dpkg, the /usr/doc/dpkg
symlink to /usr/share/doc/dpkg wasn't made. apt-get install dpkg;
apt-get install dpkg-dev should be enough to duplicate this. I'd suggest
adding a Conflicts: line to make sure they're both upgraded concurrently.
#include <dpkg/dpkg.h> gives errors unless the following symbols are defined:
#define NONRETURNING
#define NONRETURNPRINTFFORMAT(a,b)
#define PRINTFFORMAT(a,b)
dpkg itself defines them in a meaningful way, these definitions should
probably be moved into dpkg.h itself.
Finally, and as more of a wishlist item, it'd be nice if the cmpversions()
function from main/enquiry.c was included in libdpkg itself. A possible
implementation might be:
#define NONRETURNING
#define NONRETURNPRINTFFORMAT(a,b)
#define PRINTFFORMAT(a,b)
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
const char thisname[] = "main"; /* defined separately in each program */
const char printforhelp[] = "foo";
/* returns:
* 0 if true
* 1 if false
*
* -1 for bad operand
* -2 for bad version
*
* eg,
* 0 == cmpversions("2.0-1", "<<", "3.4-4");
*/
static int cmpversions(char *left, char *op, char *right) {
struct relationinfo {
const char *string;
/* These values are exit status codes, so 0=true, 1=false */
int if_lesser, if_equal, if_greater;
int if_none_a, if_none_both, if_none_b;
};
static const struct relationinfo relationinfos[]= {
/* < = > !a!2!b */
{ "le", 0,0,1, 0,0,1 },
{ "lt", 0,1,1, 0,1,1 },
{ "eq", 1,0,1, 1,0,1 },
{ "ne", 0,1,0, 0,1,0 },
{ "ge", 1,0,0, 1,0,0 },
{ "gt", 1,1,0, 1,1,0 },
{ "le-nl", 0,0,1, 1,0,0 }, /* Here none */
{ "lt-nl", 0,1,1, 1,1,0 }, /* is counted */
{ "ge-nl", 1,0,0, 0,0,1 }, /* than any version.*/
{ "gt-nl", 1,1,0, 0,1,1 }, /* */
{ "<", 0,0,1, 0,0,1 }, /* For compatibility*/
{ "<=", 0,0,1, 0,0,1 }, /* with dpkg */
{ "<<", 0,1,1, 0,1,1 }, /* control file */
{ "=", 1,0,1, 1,0,1 }, /* syntax */
{ ">", 1,0,0, 1,0,0 }, /* */
{ ">=", 1,0,0, 1,0,0 },
{ ">>", 1,1,0, 1,1,0 },
{ 0 }
};
const struct relationinfo *rip;
const char *emsg;
struct versionrevision a, b;
int r;
for (rip=relationinfos; rip->string && strcmp(rip->string,op); rip++);
if (!rip->string) return -1; /* bad op */
if (*left && strcmp(left,"<unknown>")) {
emsg= parseversion(&a,left);
if (emsg) {
return -2; /* bad version syntax */
}
} else {
blankversion(&a);
}
if (*right && strcmp(right,"<unknown>")) {
emsg= parseversion(&b,right);
if (emsg) {
return -2; /* bad version syntax */
}
} else {
blankversion(&b);
}
if (!informativeversion(&a)) {
return(informativeversion(&b) ? rip->if_none_a : rip->if_none_both);
} else if (!informativeversion(&b)) {
return(rip->if_none_b);
}
r= versioncompare(&a,&b);
if (r>0) return(rip->if_greater);
else if (r<0) return(rip->if_lesser);
else return(rip->if_equal);
}
Thanks in advance.
Cheers,
aj
-- System Information
Debian Release: potato
Kernel Version: Linux azure 2.0.33 #1 Fri May 15 19:45:40 EST 1998 i586 unknown
Versions of the packages dpkg depends on:
ii libc6 2.1.2-0pre12 GNU C Library: Shared libraries and timezone
ii libncurses4 4.2-3.2 Shared libraries for terminal handling
ii libstdc++2.9-gl 2.91.66-2 The GNU stdc++ library (EGCS version)
Reply to: