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.cute-signatures
parent
762e0c717b
commit
cec1fa2b0f
|
@ -66,6 +66,8 @@ static struct apk_option generic_options[] = {
|
||||||
required_argument, "REPOFILE" },
|
required_argument, "REPOFILE" },
|
||||||
{ 0x109, "no-network", "Do not use network (cache is still used)" },
|
{ 0x109, "no-network", "Do not use network (cache is still used)" },
|
||||||
{ 0x111, "overlay-from-stdin", "Read list of overlay files from stdin" },
|
{ 0x111, "overlay-from-stdin", "Read list of overlay files from stdin" },
|
||||||
|
{ 0x112, "arch", "Use architecture with --root",
|
||||||
|
required_argument, "ARCH" },
|
||||||
};
|
};
|
||||||
|
|
||||||
static int version(void)
|
static int version(void)
|
||||||
|
@ -369,6 +371,9 @@ int main(int argc, char **argv)
|
||||||
case 0x111:
|
case 0x111:
|
||||||
apk_flags |= APK_OVERLAY_FROM_STDIN;
|
apk_flags |= APK_OVERLAY_FROM_STDIN;
|
||||||
break;
|
break;
|
||||||
|
case 0x112:
|
||||||
|
dbopts.arch = optarg;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if (applet == NULL || applet->parse == NULL ||
|
if (applet == NULL || applet->parse == NULL ||
|
||||||
applet->parse(ctx, &dbopts, r,
|
applet->parse(ctx, &dbopts, r,
|
||||||
|
|
|
@ -95,6 +95,7 @@ struct apk_db_options {
|
||||||
int lock_wait;
|
int lock_wait;
|
||||||
unsigned long open_flags;
|
unsigned long open_flags;
|
||||||
char *root;
|
char *root;
|
||||||
|
char *arch;
|
||||||
char *keys_dir;
|
char *keys_dir;
|
||||||
char *repositories_file;
|
char *repositories_file;
|
||||||
struct list_head repository_list;
|
struct list_head repository_list;
|
||||||
|
|
|
@ -49,7 +49,6 @@ enum {
|
||||||
|
|
||||||
int apk_verbosity = 1;
|
int apk_verbosity = 1;
|
||||||
unsigned int apk_flags = 0;
|
unsigned int apk_flags = 0;
|
||||||
const char *apk_arch = APK_DEFAULT_ARCH;
|
|
||||||
|
|
||||||
const char * const apkindex_tar_gz = "APKINDEX.tar.gz";
|
const char * const apkindex_tar_gz = "APKINDEX.tar.gz";
|
||||||
static const char * const apk_static_cache_dir = "var/cache/apk";
|
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);
|
apk_string_array_init(&db->protected_paths);
|
||||||
db->permanent = 1;
|
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 = strdup(dbopts->root ?: "/");
|
||||||
db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY | O_CLOEXEC);
|
db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY | O_CLOEXEC);
|
||||||
if (db->root_fd < 0 && (dbopts->open_flags & APK_OPENF_CREATE)) {
|
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->cachetmp_fd = db->cache_fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
db->arch = apk_blob_atomize(APK_BLOB_STR(apk_arch));
|
|
||||||
db->keys_fd = openat(db->root_fd,
|
db->keys_fd = openat(db->root_fd,
|
||||||
dbopts->keys_dir ?: "etc/apk/keys",
|
dbopts->keys_dir ?: "etc/apk/keys",
|
||||||
O_RDONLY | O_CLOEXEC);
|
O_RDONLY | O_CLOEXEC);
|
||||||
|
|
Loading…
Reference in New Issue