From c389e42d852fdca32a2f89c84487327f03ef9c96 Mon Sep 17 00:00:00 2001 From: imilh Date: Sat, 22 Oct 2011 12:48:40 +0000 Subject: [PATCH] correct return code when show-deps is failing --- depends.c | 16 ++++++++++------ impact.c | 7 ++++--- main.c | 12 ++++++------ pkgin.h | 6 +++--- pkgindb.h | 3 ++- pkgindb_queries.c | 10 ++++++++-- 6 files changed, 33 insertions(+), 21 deletions(-) diff --git a/depends.c b/depends.c index 8a172cc..e542c43 100644 --- a/depends.c +++ b/depends.c @@ -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. @@ -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]; @@ -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(); @@ -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; @@ -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) @@ -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; } diff --git a/impact.c b/impact.c index ecaabac..1ceb43e 100644 --- a/impact.c +++ b/impact.c @@ -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. @@ -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); @@ -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); diff --git a/main.c b/main.c index ada9c22..e290a9b 100644 --- a/main.c +++ b/main.c @@ -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. @@ -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; @@ -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; @@ -261,7 +261,7 @@ main(int argc, char *argv[]) XFREE(env_repos); XFREE(pkg_repos); - return EXIT_SUCCESS; + return rc; } static void diff --git a/pkgin.h b/pkgin.h index 57dec0b..b6a990b 100644 --- a/pkgin.h +++ b/pkgin.h @@ -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. @@ -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 */ diff --git a/pkgindb.h b/pkgindb.h index 374d2d3..dd1f556 100644 --- a/pkgindb.h +++ b/pkgindb.h @@ -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. @@ -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[]; diff --git a/pkgindb_queries.c b/pkgindb_queries.c index 3d7d072..1c6547d 100644 --- a/pkgindb_queries.c +++ b/pkgindb_queries.c @@ -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. @@ -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;";