Commit 076ce187 authored by Timo Teräs's avatar Timo Teräs

pkg, db: add preliminary mini support for arch field

Parse arch from .PKGINFO and index; write it to index and
installed database.

Contains conservative parts from master branch commit
fca1c30b. We'll add the
repository URL related changes when we have a migration plan.
parent 0c17ba51
......@@ -103,7 +103,7 @@ struct apk_database {
char *root;
int root_fd, lock_fd, cache_fd, cachetmp_fd, keys_fd;
unsigned name_id, num_repos;
const char *cache_dir;
const char *cache_dir, *arch;
unsigned int local_repos;
int permanent : 1;
int compat_newfeatures : 1;
......
......@@ -49,6 +49,7 @@
extern int apk_verbosity;
extern unsigned int apk_flags;
extern const char *apk_arch;
#define APK_FORCE 0x0001
#define APK_SIMULATE 0x0002
......
......@@ -87,7 +87,7 @@ struct apk_package {
apk_hash_node hash_node;
unsigned repos;
struct apk_name *name;
char *version;
char *version, *arch;
char *url, *description, *license;
struct apk_dependency_array *depends;
size_t installed_size, size;
......
......@@ -30,6 +30,14 @@
#include "apk_archive.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 {
APK_DISALLOW_RMDIR = 0,
APK_ALLOW_RMDIR = 1
......@@ -37,6 +45,7 @@ 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";
const char * const apk_index_gz = "APK_INDEX.gz";
......@@ -1126,6 +1135,8 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
blob = APK_BLOB_STR("etc:*etc/init.d");
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);
mkdirat(db->cache_fd, "tmp", 0644);
db->cachetmp_fd = openat(db->cache_fd, "tmp", O_RDONLY | O_CLOEXEC);
......
......@@ -637,6 +637,9 @@ int apk_pkg_add_info(struct apk_database *db, struct apk_package *pkg,
case 'L':
pkg->license = apk_blob_cstr(value);
break;
case 'A':
pkg->arch = apk_blob_cstr(value);
break;
case 'D':
apk_deps_parse(db, &pkg->depends, value);
break;
......@@ -678,6 +681,7 @@ static int read_info_line(void *ctx, apk_blob_t line)
{ "url", 'U' },
{ "size", 'I' },
{ "license", 'L' },
{ "arch", 'A' },
{ "depend", 'D' },
};
struct read_info_ctx *ri = (struct read_info_ctx *) ctx;
......@@ -839,6 +843,8 @@ void apk_pkg_free(struct apk_package *pkg)
free(pkg->description);
if (pkg->license)
free(pkg->license);
if (pkg->arch)
free(pkg->arch);
free(pkg);
}
......@@ -976,6 +982,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("\nV:"));
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_uint(&bbuf, info->size, 10);
apk_blob_push_blob(&bbuf, APK_BLOB_STR("\nI:"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment