Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-12-22 15:11:38 +0100
committerAllan McRae <allan@archlinux.org>2014-12-24 11:19:30 +1000
commit9f527d2de453b542293e24d85ee894fa6452259a (patch)
tree0718d9cfc13cf3b81d02b6b5e8e94df49aae3f8c /lib
parentfda599df3773955aa2f95a842649902e41f4e0bc (diff)
libalpm: Parse and write PKGBASEs
This commit adds support to libalpm to parse the pkgbase present in packages .PKGINFO files, writing the PKGBASE to the %BASE% section of the local DBs desc files and for parsing it again when loading the local DB Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/be_local.c6
-rw-r--r--lib/libalpm/be_package.c2
-rw-r--r--lib/libalpm/be_sync.c2
-rw-r--r--lib/libalpm/package.c2
-rw-r--r--lib/libalpm/package.h1
5 files changed, 12 insertions, 1 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index d0e8944d..852baa4c 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -701,6 +701,8 @@ static int local_db_read(alpm_pkg_t *info, alpm_dbinfrq_t inforeq)
_alpm_log(db->handle, ALPM_LOG_ERROR, _("%s database is inconsistent: version "
"mismatch on package %s\n"), db->treename, info->name);
}
+ } else if(strcmp(line, "%BASE%") == 0) {
+ READ_AND_STORE(info->base);
} else if(strcmp(line, "%DESC%") == 0) {
READ_AND_STORE(info->desc);
} else if(strcmp(line, "%GROUPS%") == 0) {
@@ -905,6 +907,10 @@ int _alpm_local_db_write(alpm_db_t *db, alpm_pkg_t *info, alpm_dbinfrq_t inforeq
free(path);
fprintf(fp, "%%NAME%%\n%s\n\n"
"%%VERSION%%\n%s\n\n", info->name, info->version);
+ if(info->base) {
+ fprintf(fp, "%%BASE%%\n"
+ "%s\n\n", info->base);
+ }
if(info->desc) {
fprintf(fp, "%%DESC%%\n"
"%s\n\n", info->desc);
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 5617f4fa..2d42465f 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -193,7 +193,7 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
STRDUP(newpkg->name, ptr, return -1);
newpkg->name_hash = _alpm_hash_sdbm(newpkg->name);
} else if(strcmp(key, "pkgbase") == 0) {
- /* not used atm */
+ STRDUP(newpkg->base, ptr, return -1);
} else if(strcmp(key, "pkgver") == 0) {
STRDUP(newpkg->version, ptr, return -1);
} else if(strcmp(key, "basever") == 0) {
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 52459483..6e89ad93 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -614,6 +614,8 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
if(_alpm_validate_filename(db, pkg->name, pkg->filename) < 0) {
return -1;
}
+ } else if(strcmp(line, "%BASE%") == 0) {
+ READ_AND_STORE(pkg->base);
} else if(strcmp(line, "%DESC%") == 0) {
READ_AND_STORE(pkg->desc);
} else if(strcmp(line, "%GROUPS%") == 0) {
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index e2997f69..3be5e74e 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -566,6 +566,7 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
newpkg->name_hash = pkg->name_hash;
STRDUP(newpkg->filename, pkg->filename, goto cleanup);
+ STRDUP(newpkg->base, pkg->base, goto cleanup);
STRDUP(newpkg->name, pkg->name, goto cleanup);
STRDUP(newpkg->version, pkg->version, goto cleanup);
STRDUP(newpkg->desc, pkg->desc, goto cleanup);
@@ -641,6 +642,7 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
}
FREE(pkg->filename);
+ FREE(pkg->base);
FREE(pkg->name);
FREE(pkg->version);
FREE(pkg->desc);
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 357c20ef..98c1e6d6 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -85,6 +85,7 @@ extern struct pkg_operations default_pkg_ops;
struct __alpm_pkg_t {
unsigned long name_hash;
char *filename;
+ char *base;
char *name;
char *version;
char *desc;