Skip to content

Commit

Permalink
correct return code when show-deps is failing
Browse files Browse the repository at this point in the history
  • Loading branch information
imilh committed Oct 22, 2011
1 parent 5be75a3 commit c389e42
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
16 changes: 10 additions & 6 deletions depends.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: depends.c,v 1.9 2011/09/30 14:14:36 imilh Exp $ */
/* $Id: depends.c,v 1.10 2011/10/22 12:48:40 imilh Exp $ */

/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -110,7 +110,7 @@ full_dep_tree(const char *pkgname, const char *depquery, Plisthead *pdphead)
TRACE("[<]-leaving depends\n");
}

void
int
show_direct_depends(const char *pkgarg)
{
char *pkgname, query[BUFSIZ];
Expand All @@ -119,12 +119,12 @@ show_direct_depends(const char *pkgarg)

if (SLIST_EMPTY(&r_plisthead)) {
printf("%s\n", MSG_EMPTY_AVAIL_PKGLIST);
return;
return EXIT_FAILURE;
}

if ((pkgname = unique_pkg(pkgarg, REMOTE_PKG)) == NULL) {
fprintf(stderr, MSG_PKG_NOT_AVAIL, pkgarg);
return;
return EXIT_FAILURE;
}

deptreehead = init_head();
Expand All @@ -144,9 +144,11 @@ show_direct_depends(const char *pkgarg)
free_pkglist(&deptreehead, DEPTREE);
}
XFREE(pkgname);

return EXIT_SUCCESS;
}

void
int
show_full_dep_tree(const char *pkgarg, const char *depquery, const char *msg)
{
Pkglist *pdp, *mapplist;
Expand All @@ -163,7 +165,7 @@ show_full_dep_tree(const char *pkgarg, const char *depquery, const char *msg)

if (pkgname == NULL) {
fprintf(stderr, MSG_PKG_NOT_AVAIL, pkgarg);
return;
return EXIT_FAILURE;
}

if (plisthead == NULL)
Expand All @@ -184,4 +186,6 @@ show_full_dep_tree(const char *pkgarg, const char *depquery, const char *msg)

XFREE(pkgname);
free_pkglist(&deptreehead, DEPTREE);

return EXIT_SUCCESS;
}
7 changes: 4 additions & 3 deletions impact.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: impact.c,v 1.11 2011/09/20 12:42:17 imilh Exp $ */
/* $Id: impact.c,v 1.12 2011/10/22 12:48:40 imilh Exp $ */

/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -87,7 +87,7 @@ break_depends(Plisthead *impacthead, Pkglist *pimpact)
trunc_str(pkgname, '-', STR_BACKWARD);

/* fetch old package reverse dependencies */
full_dep_tree(pkgname, LOCAL_REVERSE_DEPS, rdphead);
full_dep_tree(pkgname, REMOTE_REVERSE_DEPS, rdphead);

XFREE(pkgname);

Expand Down Expand Up @@ -136,11 +136,12 @@ break_depends(Plisthead *impacthead, Pkglist *pimpact)
* browse dependencies for rdp and see if
* new package to be installed matches
*/
SLIST_FOREACH(fdp, fdphead, next)
SLIST_FOREACH(fdp, fdphead, next) {
if (pkg_match(fdp->depend, pimpact->full)) {
dep_break = 0;
break;
}
}

free_pkglist(&fdphead, DEPTREE);

Expand Down
12 changes: 6 additions & 6 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: main.c,v 1.17 2011/10/01 18:06:44 imilh Exp $ */
/* $Id: main.c,v 1.18 2011/10/22 12:48:40 imilh Exp $ */

/*
* Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -50,7 +50,7 @@ main(int argc, char *argv[])
{
uint8_t updb_all;
uint8_t do_inst = DO_INST; /* by default, do install packages */
int ch;
int ch, rc = EXIT_SUCCESS;
struct stat sb;
const char *chrootpath = NULL;

Expand Down Expand Up @@ -174,16 +174,16 @@ main(int argc, char *argv[])
break;
case PKG_SHDDP_CMD: /* show direct depends */
missing_param(argc, 2, MSG_MISSING_PKGNAME);
show_direct_depends(argv[1]);
rc = show_direct_depends(argv[1]);
break;
case PKG_SHFDP_CMD: /* show full dependency tree */
missing_param(argc, 2, MSG_MISSING_PKGNAME);
show_full_dep_tree(argv[1],
rc = show_full_dep_tree(argv[1],
DIRECT_DEPS, MSG_FULLDEPTREE);
break;
case PKG_SHRDP_CMD: /* show full reverse dependency tree */
missing_param(argc, 2, MSG_MISSING_PKGNAME);
show_full_dep_tree(argv[1],
rc = show_full_dep_tree(argv[1],
LOCAL_REVERSE_DEPS,
MSG_REVDEPTREE);
break;
Expand Down Expand Up @@ -261,7 +261,7 @@ main(int argc, char *argv[])
XFREE(env_repos);
XFREE(pkg_repos);

return EXIT_SUCCESS;
return rc;
}

static void
Expand Down
6 changes: 3 additions & 3 deletions pkgin.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: pkgin.h,v 1.25 2011/10/10 13:06:37 imilh Exp $ */
/* $Id: pkgin.h,v 1.26 2011/10/22 12:48:40 imilh Exp $ */

/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -210,8 +210,8 @@ void split_repos(void);
int pdb_rec_list(void *, int, char **, char **);
int pdb_rec_depends(void *, int, char **, char **);
/* depends.c */
void show_direct_depends(const char *);
void show_full_dep_tree(const char *, const char *, const char *);
int show_direct_depends(const char *);
int show_full_dep_tree(const char *, const char *, const char *);
void full_dep_tree(const char *pkgname, const char *depquery,
Plisthead *pdphead);
/* pkglist.c */
Expand Down
3 changes: 2 additions & 1 deletion pkgindb.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: pkgindb.h,v 1.8 2011/09/11 08:39:16 imilh Exp $ */
/* $Id: pkgindb.h,v 1.9 2011/10/22 12:48:40 imilh Exp $ */

/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -44,6 +44,7 @@ extern const char DIRECT_DEPS[];
extern const char LOCAL_DIRECT_DEPS[];
extern const char EXACT_DIRECT_DEPS[];
extern const char LOCAL_REVERSE_DEPS[];
extern const char REMOTE_REVERSE_DEPS[];
extern const char LOCAL_CONFLICTS[];
extern const char GET_CONFLICT_QUERY[];
extern const char GET_REQUIRES_QUERY[];
Expand Down
10 changes: 8 additions & 2 deletions pkgindb_queries.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $Id: pkgindb_queries.c,v 1.15 2011/10/04 08:17:36 imilh Exp $ */
/* $Id: pkgindb_queries.c,v 1.16 2011/10/22 12:48:40 imilh Exp $ */

/*
* Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -77,10 +77,16 @@ const char EXACT_DIRECT_DEPS[] =

const char LOCAL_REVERSE_DEPS[] =
"SELECT LOCAL_PKG.FULLPKGNAME, LOCAL_PKG.PKGNAME, LOCAL_PKG.PKG_KEEP "
"FROM LOCAL_PKG,LOCAL_DEPS "
"FROM LOCAL_PKG, LOCAL_DEPS "
"WHERE LOCAL_DEPS.LOCAL_DEPS_PKGNAME = '%s' "
"AND LOCAL_PKG.PKG_ID = LOCAL_DEPS.PKG_ID;";

const char REMOTE_REVERSE_DEPS[] =
"SELECT REMOTE_PKG.FULLPKGNAME, REMOTE_PKG.PKGNAME, REMOTE_PKG.PKG_KEEP "
"FROM REMOTE_PKG, REMOTE_DEPS "
"WHERE REMOTE_DEPS.REMOVE_DEPS_PKGNAME = '%s' "
"AND REMOTE_PKG.PKG_ID = REMOTE_DEPS.PKG_ID;";

const char LOCAL_CONFLICTS[] =
"SELECT LOCAL_CONFLICTS_PKGNAME FROM LOCAL_CONFLICTS;";

Expand Down

0 comments on commit c389e42

Please sign in to comment.