pkgtools

morpheus pkg tools
git clone git://git.2f30.org/pkgtools
Log | Files | Refs | README | LICENSE

commit e54beb9f486a1329de54469aa8591235c3b53866
parent 621edd1167bae72ab8f47ab894ca3b46ab5cd622
Author: sin <sin@2f30.org>
Date:   Fri, 20 Jun 2014 16:03:46 +0100

pkg_remove() should work on a struct pkg

Diffstat:
Mdb.c | 15+++------------
Mdb.h | 2+-
Mremovepkg.c | 6++----
3 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/db.c b/db.c @@ -486,22 +486,13 @@ rm_empty_dir(const char *f, const struct stat *sb, int typeflag, /* Remove the package entries for `file' */ int -pkg_remove(struct db *db, const char *name) +pkg_remove(struct db *db, struct pkg *pkg) { - struct pkg *pkg; struct pkgentry *pe; struct stat sb; - for (pkg = db->head; pkg; pkg = pkg->next) { - if (pkg->deleted == 1) - continue; - if (strcmp(pkg->name, name) == 0) - break; - } - if (!pkg) { - weprintf("can't find %s in pkg db\n", name); - return -1; - } + if (pkg->deleted == 1) + return 0; for (pe = pkg->head; pe; pe = pe->next) { if (rej_match(db, pe->rpath) > 0) { diff --git a/db.h b/db.h @@ -38,7 +38,7 @@ int db_collisions(struct db *, const char *); int pkg_load(struct db *, struct pkg *); int pkg_install(struct db *, const char *); -int pkg_remove(struct db *, const char *); +int pkg_remove(struct db *, struct pkg *); struct pkg *pkg_new(char *); void pkg_free(struct pkg *); diff --git a/removepkg.c b/removepkg.c @@ -73,10 +73,8 @@ main(int argc, char *argv[]) static int pkg_remove_cb(struct db *db, struct pkg *pkg, void *name) { - char *n = name; - - if (strcmp(pkg->name, n) == 0) { - if (pkg_remove(db, n) < 0) + if (strcmp(pkg->name, name) == 0) { + if (pkg_remove(db, pkg) < 0) return -1; return 1; }