summaryrefslogtreecommitdiff
path: root/src/database.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2008-11-28 13:34:40 +0200
committerTimo Teras <timo.teras@iki.fi>2008-11-28 13:34:40 +0200
commit5ea81ca564534e4ef5eefbe723a74dbf490e6e07 (patch)
tree4b113c19fef609669d9e2db48a88d577b5e64eb3 /src/database.c
parent545a915fafbecbda0e278dfcc881984bd7a8b19b (diff)
downloadapk-tools-5ea81ca564534e4ef5eefbe723a74dbf490e6e07.tar.gz
apk-tools-5ea81ca564534e4ef5eefbe723a74dbf490e6e07.tar.bz2
apk-tools-5ea81ca564534e4ef5eefbe723a74dbf490e6e07.tar.xz
apk-tools-5ea81ca564534e4ef5eefbe723a74dbf490e6e07.zip
add: add support to install packages not in a repository
Diffstat (limited to 'src/database.c')
-rw-r--r--src/database.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/database.c b/src/database.c
index 513b2da..261011c 100644
--- a/src/database.c
+++ b/src/database.c
@@ -627,16 +627,14 @@ struct apk_package *apk_db_get_pkg(struct apk_database *db, csum_t sum)
APK_BLOB_PTR_LEN((void*) sum, sizeof(csum_t)));
}
-int apk_db_pkg_add_file(struct apk_database *db, const char *file)
+struct apk_package *apk_db_pkg_add_file(struct apk_database *db, const char *file)
{
struct apk_package *info;
info = apk_pkg_read(db, file);
- if (info == NULL)
- return FALSE;
-
- apk_db_pkg_add(db, info);
- return TRUE;
+ if (info != NULL)
+ apk_db_pkg_add(db, info);
+ return info;
}
static int write_index_entry(apk_hash_item item, void *ctx)
@@ -864,11 +862,15 @@ int apk_db_install_pkg(struct apk_database *db,
}
/* Install the new stuff */
- snprintf(file, sizeof(file),
- "%s/%s-%s.apk",
- db->repos[0].url, newpkg->name->name, newpkg->version);
+ if (newpkg->filename == NULL) {
+ snprintf(file, sizeof(file),
+ "%s/%s-%s.apk",
+ db->repos[0].url, newpkg->name->name, newpkg->version);
+
+ fd = open(file, O_RDONLY);
+ } else
+ fd = open(newpkg->filename, O_RDONLY);
- fd = open(file, O_RDONLY);
if (fd < 0) {
apk_error("%s: %s", file, strerror(errno));
return errno;