diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-04-14 21:48:49 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-04-14 19:59:01 +0000 |
commit | cec1fa2b0f414e980c4dc56a5cc4dc9ff48bddb8 (patch) | |
tree | f3e5a5bdef05102f7400195e4ef2ed8e8fb9a2ad /src/database.c | |
parent | 762e0c717bcae8c2d0f46ba4f35232b773ac8419 (diff) | |
download | apk-tools-cec1fa2b0f414e980c4dc56a5cc4dc9ff48bddb8.tar.gz apk-tools-cec1fa2b0f414e980c4dc56a5cc4dc9ff48bddb8.tar.bz2 apk-tools-cec1fa2b0f414e980c4dc56a5cc4dc9ff48bddb8.tar.xz apk-tools-cec1fa2b0f414e980c4dc56a5cc4dc9ff48bddb8.zip |
db: Allow override arch when using --root
This is so we can do x86 --root installs on x86_64 hosts.
Using --arch without --root can make great damage so we only enable it
if --root is used.
Diffstat (limited to 'src/database.c')
-rw-r--r-- | src/database.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/database.c b/src/database.c index 1376ec3..45960d2 100644 --- a/src/database.c +++ b/src/database.c @@ -49,7 +49,6 @@ enum { int apk_verbosity = 1; unsigned int apk_flags = 0; -const char *apk_arch = APK_DEFAULT_ARCH; const char * const apkindex_tar_gz = "APKINDEX.tar.gz"; static const char * const apk_static_cache_dir = "var/cache/apk"; @@ -1149,6 +1148,11 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts) apk_string_array_init(&db->protected_paths); db->permanent = 1; + if (dbopts->root && dbopts->arch) { + db->arch = apk_blob_atomize(APK_BLOB_STR(dbopts->arch)); + } else { + db->arch = apk_blob_atomize(APK_BLOB_STR(APK_DEFAULT_ARCH)); + } db->root = strdup(dbopts->root ?: "/"); db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY | O_CLOEXEC); if (db->root_fd < 0 && (dbopts->open_flags & APK_OPENF_CREATE)) { @@ -1226,7 +1230,6 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts) db->cachetmp_fd = db->cache_fd; } - db->arch = apk_blob_atomize(APK_BLOB_STR(apk_arch)); db->keys_fd = openat(db->root_fd, dbopts->keys_dir ?: "etc/apk/keys", O_RDONLY | O_CLOEXEC); |