1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 08:50:38 +02:00

qpkg: option -d to enable debugging at run time, and some cleanup

- prereq.c: added section titles
- prereq.c (debug), qpkg.h, qpkg.c: made variable "debug" global and moved
  it to qpkg.c
- qpkg.c (usage, main): new option -d to enable debugging
This commit is contained in:
Werner Almesberger 2010-11-21 20:55:25 -03:00
parent e1404bb6a2
commit a0c0e854cc
3 changed files with 23 additions and 3 deletions

View File

@ -39,7 +39,9 @@ static struct pkg **installs = NULL;
static int n_best; /* undefined if best == NULL */ static int n_best; /* undefined if best == NULL */
static int n_install = 0; static int n_install = 0;
static int install_max = 0; static int install_max = 0;
static int debug = 0;
/* ----- Version comparison ------------------------------------------------ */
static int epoch(const char **s, const struct id *id) static int epoch(const char **s, const struct id *id)
@ -100,6 +102,9 @@ static int comp_versions(const struct id *va, const struct id *vb)
} }
/* ----- List of packages considered for installation ---------------------- */
static void done(void) static void done(void)
{ {
int size; int size;
@ -139,6 +144,9 @@ static void backtrack(void)
} }
/* ----- Check dependencies and conflicts ---------------------------------- */
static int satisfies(const struct pkg *pkg, const struct ref *ref) static int satisfies(const struct pkg *pkg, const struct ref *ref)
{ {
int cmp; int cmp;
@ -171,6 +179,9 @@ static int conflicts(const struct pkg *pkg, const struct list *conf)
} }
/* ----- Recurse through lists and layers of dependencies ------------------ */
static void print_debug(const struct pkg *pkg, const struct stack *top, static void print_debug(const struct pkg *pkg, const struct stack *top,
int level) int level)
{ {

View File

@ -26,6 +26,8 @@
struct tree *packages = NULL; struct tree *packages = NULL;
struct tree *versions = NULL; struct tree *versions = NULL;
int debug = 0;
static void list_all_packages(void) static void list_all_packages(void)
{ {
@ -115,8 +117,9 @@ static void find_prereq(const char *name, const char *version)
static void usage(const char *name) static void usage(const char *name)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [pkg-list ...] list [pkg]\n" "usage: %s options [pkg-list ...] list [pkg]\n"
" %s [pkg-list ...] prereq pkg [version]\n" " %s options [pkg-list ...] prereq pkg [version]\n\n"
" -d enable debugging output\n"
, name, name); , name, name);
exit(1); exit(1);
} }
@ -133,6 +136,10 @@ int main(int argc, char **argv)
usage(*argv); usage(*argv);
for (arg = 1; arg != argc; arg++) { for (arg = 1; arg != argc; arg++) {
if (!strcmp(argv[arg], "-d")) {
debug = 1;
continue;
}
if (*argv[arg] == '-') if (*argv[arg] == '-')
usage(*argv); usage(*argv);
if (!strcmp(argv[arg], "list")) { if (!strcmp(argv[arg], "list")) {

View File

@ -52,4 +52,6 @@ struct pkg {
struct tree *packages; struct tree *packages;
struct tree *versions; struct tree *versions;
int debug;
#endif /* !QPKG_H */ #endif /* !QPKG_H */