From 6a3e471304b939fa920adcf6f6a9ac31b22fd976 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 22 Nov 2010 22:48:28 -0300 Subject: [PATCH] qpkg: added some field names and relational operators from Ubuntu - gobble.c (gobble_buf): recognize (and ignore) the following fields: Bugs, Installed-Size, MD5sum, Origin, Original-Maintainer, SHA1, SHA256, Task. - pkg.h (enum relop): added comments showing the respective symbol - pkg.h (enum relop): added rel_gg (>>), rel_le (<=), and rel_ll (<<) - gobble.c (gobble_buf): recognize >>, <=, and << - TODO: record progress in support beyond Jlime/OE --- qpkg/TODO | 2 + qpkg/gobble.c | 119 ++++++++++++++++++++++++++++++++++++++++---------- qpkg/pkg.h | 9 ++-- 3 files changed, 105 insertions(+), 25 deletions(-) diff --git a/qpkg/TODO b/qpkg/TODO index 5111438..dd83e66 100644 --- a/qpkg/TODO +++ b/qpkg/TODO @@ -135,6 +135,8 @@ Still left to do - consider also supporting the similar but not identical (parent ?) format of /var/lib/dpkg/status and /var/lib/apt/lists/*Packages + Update: added as much as my Ubuntu system can reach before hitting | + Done ==== diff --git a/qpkg/gobble.c b/qpkg/gobble.c index 4cbc782..2fe8501 100644 --- a/qpkg/gobble.c +++ b/qpkg/gobble.c @@ -161,6 +161,10 @@ initial: FAIL; } + case 'B': /* Bugs */ + EXPECT("ugs:"); + goto skip_data; + case 'C': /* Conflicts // Conffiles */ EXPECT("onf"); switch (NEXT) { @@ -202,28 +206,63 @@ initial: FAIL; } - case 'I': /* Installed-Time */ - EXPECT("nstalled-Time:"); - goto skip_data; - - case 'L': /* License */ - EXPECT("icense:"); - goto skip_data; - - case 'M': /* Maintainer, MD5Sum */ + case 'I': /* Installed-Size, Installed-Time */ + EXPECT("nstalled-"); switch (NEXT) { - case 'a': - EXPECT("intainer:"); + case 'S': + EXPECT("ize:"); goto skip_data; - case 'D': - EXPECT("5Sum:"); + case 'T': + EXPECT("ime:"); goto skip_data; default: FAIL; } - case 'O': /* OE */ - EXPECT("E:"); + case 'L': /* License */ + EXPECT("icense:"); + goto skip_data; + + case 'M': /* Maintainer, MD5Sum, MD5sum */ + switch (NEXT) { + case 'a': + EXPECT("intainer:"); + goto skip_data; + case 'D': + EXPECT("5"); + switch (NEXT) { + case 'S': + case 's': + break; + default: + FAIL; + } + EXPECT("um:"); + goto skip_data; + default: + FAIL; + } + + case 'O': /* OE, Origin, Original-Maintainer */ + switch (NEXT) { + case 'E': + EXPECT(":"); + goto skip_data; + case 'r': + EXPECT("igin"); + switch (NEXT) { + case ':': + break; + case 'a': + EXPECT("l-Maintainer:"); + break; + default: + FAIL; + } + goto skip_data; + default: + FAIL; + } goto skip_data; case 'P': /* Package, Priority, Provides */ @@ -260,11 +299,25 @@ initial: FAIL; } - case 'S': /* Section, Size, Source, Suggests // Status */ + case 'S': /* Section, SHA1, SHA256, Size, Source, Suggests + // Status */ switch (NEXT) { case 'e': EXPECT("ction:"); goto skip_data; + case 'H': + EXPECT("A"); + switch (NEXT) { + case '1': + EXPECT(":"); + break; + case '2': + EXPECT("56:"); + break; + default: + FAIL; + } + goto skip_data; case 'i': EXPECT("ze:"); goto skip_data; @@ -281,6 +334,10 @@ initial: FAIL; } + case 'T': /* Task */ + EXPECT("ask:"); + goto skip_data; + case 'V': /* Version */ EXPECT("ersion:"); goto version; @@ -389,18 +446,36 @@ list_with_version: ref->version = NULL; else { buf++; - if (buf == end) - FAIL; - switch (*buf++) { + switch (NEXT) { case '=': ref->relop = rel_eq; break; case '<': - ref->relop = rel_lt; + switch (NEXT) { + case ' ': + ref->relop = rel_lt; + break; + case '=': + ref->relop = rel_le; + break; + case '<': + ref->relop = rel_ll; + break; + default: + buf--; + } break; case '>': - EXPECT("="); - ref->relop = rel_ge; + switch (NEXT) { + case '=': + ref->relop = rel_ge; + break; + case '>': + ref->relop = rel_gg; + break; + default: + FAIL; + } break; default: FAIL; diff --git a/qpkg/pkg.h b/qpkg/pkg.h index b104dcc..6228439 100644 --- a/qpkg/pkg.h +++ b/qpkg/pkg.h @@ -28,9 +28,12 @@ enum flags { }; enum relop { - rel_eq, - rel_ge, - rel_lt, + rel_eq, /* = */ + rel_ge, /* >= */ + rel_gg, /* >> */ + rel_lt, /* < */ + rel_le, /* <= */ + rel_ll, /* << */ }; struct pkg;