1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 06:41:53 +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_install = 0;
static int install_max = 0;
static int debug = 0;
/* ----- Version comparison ------------------------------------------------ */
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)
{
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)
{
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,
int level)
{

View File

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

View File

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