diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2009-01-08 07:15:16 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2009-01-08 07:16:53 +0000 |
commit | 174dd41113da46bb4bb920326bd8824cec8fad84 (patch) | |
tree | 76a7f305db398532c165a9e4d3b8d6eb26d0d854 /src/database.c | |
parent | d704e93f8dbc8b6560fd34d0dc0524c674d55e15 (diff) | |
download | apk-tools-174dd41113da46bb4bb920326bd8824cec8fad84.tar.gz apk-tools-174dd41113da46bb4bb920326bd8824cec8fad84.tar.bz2 apk-tools-174dd41113da46bb4bb920326bd8824cec8fad84.tar.xz apk-tools-174dd41113da46bb4bb920326bd8824cec8fad84.zip |
src/database.c: get repository file from environment variable APK_REPOS
Defaults to /etc/apk/repositories, absolute path and not relative
the install root.
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 7cb579b..18bf290 100644 --- a/src/database.c +++ b/src/database.c @@ -16,6 +16,7 @@ #include <unistd.h> #include <malloc.h> #include <string.h> +#include <stdlib.h> #include "apk_defines.h" #include "apk_package.h" @@ -576,6 +577,7 @@ static int add_protected_path(void *ctx, apk_blob_t blob) int apk_db_open(struct apk_database *db, const char *root) { apk_blob_t blob; + const char *apk_repos = getenv("APK_REPOS"); memset(db, 0, sizeof(*db)); apk_hash_init(&db->available.names, &pkg_name_hash_ops, 1000); @@ -599,8 +601,9 @@ int apk_db_open(struct apk_database *db, const char *root) if (apk_db_read_state(db) != 0) return -1; - fchdir(db->root_fd); - blob = apk_blob_from_file("etc/apk/repositories"); + if (apk_repos == NULL) + apk_repos="/etc/apk/repositories"; + blob = apk_blob_from_file(apk_repos); if (!APK_BLOB_IS_NULL(blob)) { apk_blob_for_each_segment(blob, "\n", apk_db_add_repository, db); free(blob.ptr); |