1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-22 07:37:12 +02:00

qpkg: perform sanity checks after parsing a package entry

- gobble.c (compact_pkg, gobble_buf): renamed compact_pkg to finish_pkg
- gobble.c (finish_pkg): check that the package has a version
- gobble.c (finish_pkg): check that the package has an architecture
- gobble.c (finish_pkg): check that the package either has a file name or
  is installed
This commit is contained in:
Werner Almesberger 2010-11-21 04:00:32 -03:00
parent f14c041e51
commit 83c716424f

View File

@ -92,10 +92,29 @@
#define DONE goto done #define DONE goto done
static void compact_pkg(struct pkg *new, struct jrb *jrb) static void finish_pkg(struct pkg *new, struct jrb *jrb)
{ {
struct pkg *old; struct pkg *old;
if (!new->version) {
fprintf(stderr, "package %.*s has no version\n",
ID2PF(new->id));
exit(1);
}
if (!new->arch) {
fprintf(stderr,
"package %.*s version %.*s has no architecture\n",
ID2PF(new->id), ID2PF(new->version));
exit(1);
}
if (!new->filename && !(new->flags & QPKG_INSTALLED)) {
fprintf(stderr,
"package %.*s version %.*s has no file name "
"(nor is it installed)\n",
ID2PF(new->id), ID2PF(new->version));
exit(1);
}
for (old = new->more; old; old = old->more) for (old = new->more; old; old = old->more)
if (old->version == new->version) if (old->version == new->version)
goto compact; goto compact;
@ -280,7 +299,7 @@ depends:
package: package:
if (pkg) if (pkg)
compact_pkg(pkg, jrb); finish_pkg(pkg, jrb);
WHITESPACE; WHITESPACE;
pkg = alloc_type(struct pkg); pkg = alloc_type(struct pkg);
@ -407,7 +426,7 @@ list_with_version:
done: done:
if (pkg) if (pkg)
compact_pkg(pkg, jrb); finish_pkg(pkg, jrb);
return; return;
fail: fail: