commit 7dcf2a44ceb7b9792c7b60e20fc69a933ea85894
parent a848f47036cc6edca573c6ca5f6787da16fff659
Author: sin <sin@2f30.org>
Date: Sat, 21 Jun 2014 20:04:14 +0100
pkg_install() uses a struct pkg now
Diffstat:
3 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/db.c b/db.c
@@ -339,21 +339,15 @@ pkg_load_file(struct db *db, const char *filename)
return pkg;
}
-/* Install the package `file' to disk */
+/* Install the given package */
int
-pkg_install(struct db *db, const char *file)
+pkg_install(struct db *db, struct pkg *pkg)
{
char cwd[PATH_MAX];
- char pkgpath[PATH_MAX];
struct archive *ar;
struct archive_entry *entry;
int flags, r;
- if (!realpath(file, pkgpath)) {
- weprintf("realpath %s:", file);
- return -1;
- }
-
ar = archive_read_new();
archive_read_support_filter_gzip(ar);
@@ -361,8 +355,8 @@ pkg_install(struct db *db, const char *file)
archive_read_support_filter_xz(ar);
archive_read_support_format_tar(ar);
- if (archive_read_open_filename(ar, pkgpath, ARCHIVEBUFSIZ) < 0) {
- weprintf("archive_read_open_filename %s: %s\n", pkgpath,
+ if (archive_read_open_filename(ar, pkg->path, ARCHIVEBUFSIZ) < 0) {
+ weprintf("archive_read_open_filename %s: %s\n", pkg->path,
archive_error_string(ar));
return -1;
}
diff --git a/db.h b/db.h
@@ -38,7 +38,7 @@ int db_walk(struct db *, int (*)(struct db *, struct pkg *, void *), void *);
int db_links(struct db *, const char *);
struct pkg *pkg_load(struct db *, const char *);
-int pkg_install(struct db *, const char *);
+int pkg_install(struct db *, struct pkg *);
int pkg_remove(struct db *, struct pkg *);
int pkg_collisions(struct pkg *);
struct pkg *pkg_new(const char *, const char *, const char *);
diff --git a/installpkg.c b/installpkg.c
@@ -67,8 +67,7 @@ main(int argc, char *argv[])
}
}
db_add(db, pkg);
- /* TODO: fix pkg_install() to work with struct pkg */
- pkg_install(db, path);
+ pkg_install(db, pkg);
printf("installed %s\n", path);
}