diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-07-24 14:00:57 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-07-24 14:00:57 +0300 |
commit | e5be34335ca8ff9df4ec53c2ab421522a6ca02c3 (patch) | |
tree | 62d9f11702abf9bcded4c0aec6db101e0e17b429 /src/add.c | |
parent | 8806ce875e4e1d3dabbfd6a6cf12a3b5a6257ed9 (diff) | |
download | apk-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.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -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); |