aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2011-02-26 12:31:48 +0200
committerTimo Teräs <timo.teras@iki.fi>2011-02-26 12:31:48 +0200
commit076ce1876b8d530e0777472637d432f1e2b9459c (patch)
tree56f17e24beedd195c9076761883445d6315018c2
parent0c17ba515c8d76f256dec1f8862024c7d19a0b54 (diff)
downloadapk-tools-076ce1876b8d530e0777472637d432f1e2b9459c.tar.gz
apk-tools-076ce1876b8d530e0777472637d432f1e2b9459c.tar.bz2
apk-tools-076ce1876b8d530e0777472637d432f1e2b9459c.tar.xz
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 fca1c30b801537ce35c1e4aa50331ae52c9bf567. We'll add the repository URL related changes when we have a migration plan.
-rw-r--r--src/apk_database.h2
-rw-r--r--src/apk_defines.h1
-rw-r--r--src/apk_package.h2
-rw-r--r--src/database.c11
-rw-r--r--src/package.c10
5 files changed, 24 insertions, 2 deletions
diff --git a/src/apk_database.h b/src/apk_database.h
index 4dc7480..2fa3340 100644
--- a/src/apk_database.h
+++ b/src/apk_database.h
@@ -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;
diff --git a/src/apk_defines.h b/src/apk_defines.h
index 30927bd..6d5f49c 100644
--- a/src/apk_defines.h
+++ b/src/apk_defines.h
@@ -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
diff --git a/src/apk_package.h b/src/apk_package.h
index 0488f55..43fd10c 100644
--- a/src/apk_package.h
+++ b/src/apk_package.h
@@ -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;
diff --git a/src/database.c b/src/database.c
index 600ee18..276af2b 100644
--- a/src/database.c
+++ b/src/database.c
@@ -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);
diff --git a/src/package.c b/src/package.c
index 25c6770..ae01ad7 100644
--- a/src/package.c
+++ b/src/package.c
@@ -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:"));