summaryrefslogtreecommitdiff
path: root/src/add.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-24 14:00:57 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-24 14:00:57 +0300
commite5be34335ca8ff9df4ec53c2ab421522a6ca02c3 (patch)
tree62d9f11702abf9bcded4c0aec6db101e0e17b429 /src/add.c
parent8806ce875e4e1d3dabbfd6a6cf12a3b5a6257ed9 (diff)
downloadapk-tools-e5be34335ca8ff9df4ec53c2ab421522a6ca02c3.tar.gz
apk-tools-e5be34335ca8ff9df4ec53c2ab421522a6ca02c3.tar.bz2
apk-tools-e5be34335ca8ff9df4ec53c2ab421522a6ca02c3.tar.xz
apk-tools-e5be34335ca8ff9df4ec53c2ab421522a6ca02c3.zip
db: create cache index with non-repository packages
this enables virtual packages and files specified from command line to work on non-harddisk installs.
Diffstat (limited to 'src/add.c')
-rw-r--r--src/add.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/add.c b/src/add.c
index 03fc96a..d147fa6 100644
--- a/src/add.c
+++ b/src/add.c
@@ -77,6 +77,22 @@ static int cup(void)
return 0;
}
+static int non_repository_check(struct apk_database *db)
+{
+ if (apk_flags & APK_FORCE)
+ return 0;
+ if (apk_db_cache_active(db))
+ return 0;
+ if (apk_db_permanent(db))
+ return 0;
+
+ apk_error("You tried to add a non-repository package to system, "
+ "but it would be lost on next reboot. Enable package caching "
+ "(apk cache --help) or use --force if you know what you are "
+ "doing.");
+ return 1;
+}
+
static int add_main(void *ctx, int argc, char **argv)
{
@@ -97,6 +113,9 @@ static int add_main(void *ctx, int argc, char **argv)
return r;
if (actx->virtpkg) {
+ if (non_repository_check(&db))
+ goto err;
+
virtpkg = apk_pkg_new();
if (virtpkg == NULL) {
apk_error("Failed to allocate virtual meta package");
@@ -119,14 +138,8 @@ static int add_main(void *ctx, int argc, char **argv)
struct apk_package *pkg = NULL;
struct apk_sign_ctx sctx;
- if (!apk_db_cache_active(&db) &&
- !apk_db_permanent(&db) &&
- !(apk_flags & APK_FORCE)) {
- apk_error("Use --force or enable package "
- "caching to install non-repository "
- "packages.");
+ if (non_repository_check(&db))
goto err;
- }
apk_sign_ctx_init(&sctx, APK_SIGN_VERIFY_AND_GENERATE,
NULL);