pkg, db: add preliminary support for arch field
Architecture is now: - parsed from .PKGINFO - written to index and installed db - appended to repository URL when fetching filescute-signatures
parent
6e34f048c7
commit
fca1c30b80
|
@ -103,7 +103,7 @@ struct apk_database {
|
||||||
char *root;
|
char *root;
|
||||||
int root_fd, lock_fd, cache_fd, cachetmp_fd, keys_fd;
|
int root_fd, lock_fd, cache_fd, cachetmp_fd, keys_fd;
|
||||||
unsigned name_id, num_repos;
|
unsigned name_id, num_repos;
|
||||||
const char *cache_dir;
|
const char *cache_dir, *arch;
|
||||||
int permanent;
|
int permanent;
|
||||||
unsigned int local_repos;
|
unsigned int local_repos;
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
|
|
||||||
extern int apk_verbosity;
|
extern int apk_verbosity;
|
||||||
extern unsigned int apk_flags;
|
extern unsigned int apk_flags;
|
||||||
|
extern const char *apk_arch;
|
||||||
|
|
||||||
#define APK_FORCE 0x0001
|
#define APK_FORCE 0x0001
|
||||||
#define APK_SIMULATE 0x0002
|
#define APK_SIMULATE 0x0002
|
||||||
|
|
|
@ -85,7 +85,7 @@ struct apk_package {
|
||||||
apk_hash_node hash_node;
|
apk_hash_node hash_node;
|
||||||
unsigned repos;
|
unsigned repos;
|
||||||
struct apk_name *name;
|
struct apk_name *name;
|
||||||
char *version;
|
char *version, *arch;
|
||||||
char *url, *description, *license;
|
char *url, *description, *license;
|
||||||
struct apk_dependency_array *depends;
|
struct apk_dependency_array *depends;
|
||||||
size_t installed_size, size;
|
size_t installed_size, size;
|
||||||
|
|
|
@ -30,6 +30,14 @@
|
||||||
#include "apk_archive.h"
|
#include "apk_archive.h"
|
||||||
#include "apk_print.h"
|
#include "apk_print.h"
|
||||||
|
|
||||||
|
#if defined(__x86_64__)
|
||||||
|
#define APK_DEFAULT_ARCH "x86_64"
|
||||||
|
#elif defined(__i386__)
|
||||||
|
#define APK_DEFAULT_ARCH "x86"
|
||||||
|
#else
|
||||||
|
#define APK_DEFAULT_ARCH "noarch"
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
APK_DISALLOW_RMDIR = 0,
|
APK_DISALLOW_RMDIR = 0,
|
||||||
APK_ALLOW_RMDIR = 1
|
APK_ALLOW_RMDIR = 1
|
||||||
|
@ -37,6 +45,7 @@ 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/lib/apk";
|
static const char * const apk_static_cache_dir = "var/lib/apk";
|
||||||
|
@ -444,8 +453,9 @@ int apk_cache_download(struct apk_database *db, const char *url,
|
||||||
char fullurl[PATH_MAX];
|
char fullurl[PATH_MAX];
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
snprintf(fullurl, sizeof(fullurl), "%s%s%s",
|
snprintf(fullurl, sizeof(fullurl), "%s%s%s/%s",
|
||||||
url, url[strlen(url)-1] == '/' ? "" : "/", item);
|
url, url[strlen(url)-1] == '/' ? "" : "/",
|
||||||
|
db->arch, item);
|
||||||
apk_message("fetch %s", fullurl);
|
apk_message("fetch %s", fullurl);
|
||||||
|
|
||||||
if (apk_flags & APK_SIMULATE)
|
if (apk_flags & APK_SIMULATE)
|
||||||
|
@ -1112,6 +1122,8 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
|
||||||
blob = APK_BLOB_STR("etc:*etc/init.d");
|
blob = APK_BLOB_STR("etc:*etc/init.d");
|
||||||
apk_blob_for_each_segment(blob, ":", add_protected_path, db);
|
apk_blob_for_each_segment(blob, ":", add_protected_path, db);
|
||||||
|
|
||||||
|
db->arch = apk_arch;
|
||||||
|
|
||||||
db->cache_fd = openat(db->root_fd, db->cache_dir, O_RDONLY | O_CLOEXEC);
|
db->cache_fd = openat(db->root_fd, db->cache_dir, O_RDONLY | O_CLOEXEC);
|
||||||
mkdirat(db->cache_fd, "tmp", 0644);
|
mkdirat(db->cache_fd, "tmp", 0644);
|
||||||
db->cachetmp_fd = openat(db->cache_fd, "tmp", O_RDONLY | O_CLOEXEC);
|
db->cachetmp_fd = openat(db->cache_fd, "tmp", O_RDONLY | O_CLOEXEC);
|
||||||
|
@ -1389,13 +1401,15 @@ static int apk_repo_is_remote(struct apk_repository *repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct apk_bstream *apk_repo_file_open(struct apk_repository *repo,
|
static struct apk_bstream *apk_repo_file_open(struct apk_repository *repo,
|
||||||
|
const char *arch,
|
||||||
const char *file,
|
const char *file,
|
||||||
char *buf, int buflen)
|
char *buf, int buflen)
|
||||||
{
|
{
|
||||||
const char *url = repo->url;
|
const char *url = repo->url;
|
||||||
|
|
||||||
snprintf(buf, buflen, "%s%s%s",
|
snprintf(buf, buflen, "%s%s%s/%s",
|
||||||
url, url[strlen(url)-1] == '/' ? "" : "/", file);
|
url, url[strlen(url)-1] == '/' ? "" : "/",
|
||||||
|
arch, file);
|
||||||
|
|
||||||
if ((apk_flags & APK_NO_NETWORK) && apk_repo_is_remote(repo))
|
if ((apk_flags & APK_NO_NETWORK) && apk_repo_is_remote(repo))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1563,7 +1577,7 @@ int apk_db_add_repository(apk_database_t _db, apk_blob_t repository)
|
||||||
bs = apk_bstream_from_file(db->cache_fd, buf);
|
bs = apk_bstream_from_file(db->cache_fd, buf);
|
||||||
} else {
|
} else {
|
||||||
db->local_repos |= BIT(r);
|
db->local_repos |= BIT(r);
|
||||||
bs = apk_repo_file_open(repo, apkindex_tar_gz, buf, sizeof(buf));
|
bs = apk_repo_file_open(repo, db->arch, apkindex_tar_gz, buf, sizeof(buf));
|
||||||
}
|
}
|
||||||
if (bs == NULL) {
|
if (bs == NULL) {
|
||||||
apk_warning("Failed to open index for %s", repo->url);
|
apk_warning("Failed to open index for %s", repo->url);
|
||||||
|
@ -1987,7 +2001,7 @@ static int apk_db_unpack_pkg(struct apk_database *db,
|
||||||
|
|
||||||
if (bs == NULL) {
|
if (bs == NULL) {
|
||||||
apk_pkg_format_plain(pkg, APK_BLOB_BUF(item));
|
apk_pkg_format_plain(pkg, APK_BLOB_BUF(item));
|
||||||
bs = apk_repo_file_open(repo, item, file, sizeof(file));
|
bs = apk_repo_file_open(repo, pkg->arch ?: db->arch, item, file, sizeof(file));
|
||||||
if (apk_repo_is_remote(repo))
|
if (apk_repo_is_remote(repo))
|
||||||
need_copy = TRUE;
|
need_copy = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -623,6 +623,9 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg,
|
||||||
case 'L':
|
case 'L':
|
||||||
pkg->license = apk_blob_cstr(value);
|
pkg->license = apk_blob_cstr(value);
|
||||||
break;
|
break;
|
||||||
|
case 'A':
|
||||||
|
pkg->arch = apk_blob_cstr(value);
|
||||||
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
apk_deps_parse(db, &pkg->depends, value);
|
apk_deps_parse(db, &pkg->depends, value);
|
||||||
break;
|
break;
|
||||||
|
@ -655,6 +658,7 @@ static int read_info_line(void *ctx, apk_blob_t line)
|
||||||
{ "url", 'U' },
|
{ "url", 'U' },
|
||||||
{ "size", 'I' },
|
{ "size", 'I' },
|
||||||
{ "license", 'L' },
|
{ "license", 'L' },
|
||||||
|
{ "arch", 'A' },
|
||||||
{ "depend", 'D' },
|
{ "depend", 'D' },
|
||||||
};
|
};
|
||||||
struct read_info_ctx *ri = (struct read_info_ctx *) ctx;
|
struct read_info_ctx *ri = (struct read_info_ctx *) ctx;
|
||||||
|
@ -767,6 +771,8 @@ void apk_pkg_free(struct apk_package *pkg)
|
||||||
free(pkg->description);
|
free(pkg->description);
|
||||||
if (pkg->license)
|
if (pkg->license)
|
||||||
free(pkg->license);
|
free(pkg->license);
|
||||||
|
if (pkg->arch)
|
||||||
|
free(pkg->arch);
|
||||||
free(pkg);
|
free(pkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,6 +909,10 @@ int apk_pkg_write_index_entry(struct apk_package *info,
|
||||||
apk_blob_push_blob(&bbuf, APK_BLOB_STR(info->name->name));
|
apk_blob_push_blob(&bbuf, APK_BLOB_STR(info->name->name));
|
||||||
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nV:"));
|
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nV:"));
|
||||||
apk_blob_push_blob(&bbuf, APK_BLOB_STR(info->version));
|
apk_blob_push_blob(&bbuf, APK_BLOB_STR(info->version));
|
||||||
|
if (info->arch != NULL) {
|
||||||
|
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nA:"));
|
||||||
|
apk_blob_push_blob(&bbuf, APK_BLOB_STR(info->arch));
|
||||||
|
}
|
||||||
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nS:"));
|
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nS:"));
|
||||||
apk_blob_push_uint(&bbuf, info->size, 10);
|
apk_blob_push_uint(&bbuf, info->size, 10);
|
||||||
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nI:"));
|
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nI:"));
|
||||||
|
|
Loading…
Reference in New Issue