summaryrefslogtreecommitdiff
path: root/src/add.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/add.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/add.c')
-rw-r--r--src/add.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/add.c b/src/add.c
index b20d16f..562ce26 100644
--- a/src/add.c
+++ b/src/add.c
@@ -22,14 +22,32 @@ static int add_main(int argc, char **argv)
return -1;
for (i = 0; i < argc; i++) {
- struct apk_dependency dep = {
- .name = apk_db_get_name(&db, APK_BLOB_STR(argv[i])),
- };
+ struct apk_dependency dep;
+
+ if (strstr(argv[i], ".apk") != NULL) {
+ struct apk_package *pkg;
+
+ pkg = apk_db_pkg_add_file(&db, argv[i]);
+ if (pkg == NULL) {
+ apk_error("Unable to read '%s'", argv[i]);
+ goto err;
+ }
+
+ dep = (struct apk_dependency) {
+ .name = pkg->name,
+ .version_mask = APK_VERSION_RESULT_MASK(APK_VERSION_EQUAL),
+ .version = pkg->version,
+ };
+ } else {
+ dep = (struct apk_dependency) {
+ .name = apk_db_get_name(&db, APK_BLOB_STR(argv[i])),
+ };
+ }
apk_deps_add(&db.world, &dep);
}
apk_db_recalculate_and_commit(&db);
+err:
apk_db_close(&db);
-
return 0;
}