From e5be34335ca8ff9df4ec53c2ab421522a6ca02c3 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Fri, 24 Jul 2009 14:00:57 +0300 Subject: db: create cache index with non-repository packages this enables virtual packages and files specified from command line to work on non-harddisk installs. --- src/add.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'src/add.c') 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); -- cgit v1.2.3-60-g2f50