pkg: pass-through ABIVersion to status file
authorDaniel Golle <daniel@makrotopia.org>
Wed, 10 Mar 2021 23:39:48 +0000 (23:39 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 11 Mar 2021 00:16:46 +0000 (00:16 +0000)
This allows removing it from package names if needed without
storing the SourceName for each and every package, which is mostly
redundant information.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
libopkg/pkg.c
libopkg/pkg.h
libopkg/pkg_parse.c
libopkg/pkg_parse.h

index f68ce0c74385a142c96f020818de9630f97b84b3..51110687cc8c50368f099b1e82457666104f8655 100644 (file)
@@ -479,6 +479,8 @@ int pkg_merge(pkg_t * oldpkg, pkg_t * newpkg)
                pkg_set_string(oldpkg, PKG_PRIORITY, pkg_get_string(newpkg, PKG_PRIORITY));
        if (!pkg_get_string(oldpkg, PKG_SOURCE))
                pkg_set_string(oldpkg, PKG_SOURCE, pkg_get_string(newpkg, PKG_SOURCE));
+       if (!pkg_get_string(oldpkg, PKG_ABIVERSION))
+               pkg_set_string(oldpkg, PKG_ABIVERSION, pkg_get_string(newpkg, PKG_ABIVERSION));
 
        if (!pkg_get_ptr(oldpkg, PKG_CONFFILES)) {
                pkg_set_ptr(oldpkg, PKG_CONFFILES, pkg_get_ptr(newpkg, PKG_CONFFILES));
@@ -650,7 +652,12 @@ void pkg_formatted_field(FILE * fp, pkg_t * pkg, const char *field)
        switch (field[0]) {
        case 'a':
        case 'A':
-               if (strcasecmp(field, "Alternatives") == 0) {
+               if (strcasecmp(field, "ABIVersion") == 0) {
+                       p = pkg_get_string(pkg, PKG_ABIVERSION);
+                       if (p) {
+                               fprintf(fp, "ABIVersion: %s\n", p);
+                       }
+               } else if (strcasecmp(field, "Alternatives") == 0) {
                        struct pkg_alternatives *pkg_alts = pkg_get_ptr(pkg, PKG_ALTERNATIVES);
 
                        if (pkg_alts && pkg_alts->nalts > 0) {
@@ -954,6 +961,7 @@ void pkg_print_status(pkg_t * pkg, FILE * file)
        }
 
        pkg_formatted_field(file, pkg, "Package");
+       pkg_formatted_field(file, pkg, "ABIVersion");
        pkg_formatted_field(file, pkg, "Version");
        pkg_formatted_field(file, pkg, "Depends");
        pkg_formatted_field(file, pkg, "Recommends");
index bc0e030e800142e26fc174756a3d9f586c602538..c9bfa7e3356e699bfa12f72d83bb14cb2f68f3e2 100644 (file)
@@ -101,6 +101,7 @@ enum pkg_fields {
        PKG_CONFLICTS,
        PKG_CONFFILES,
        PKG_ALTERNATIVES,
+       PKG_ABIVERSION,
 };
 
 struct abstract_pkg {
index 0baa4db396569be816386b50568c57e12d1cd98c..c9e0cdf45a4236afad622041877bd1578f985241 100644 (file)
@@ -208,7 +208,9 @@ int pkg_parse_line(void *ptr, char *line, uint mask)
 
        switch (*line) {
        case 'A':
-               if ((mask & PFM_ALTERNATIVES) && is_field("Alternatives", line))
+               if ((mask & PFM_ABIVERSION) && is_field("ABIVersion", line))
+                       pkg_set_string(pkg, PKG_ABIVERSION, line + strlen("ABIVersion") + 1);
+               else if ((mask & PFM_ALTERNATIVES) && is_field("Alternatives", line))
                        parse_alternatives(pkg, line + strlen("Alternatives") + 1);
                else if ((mask & PFM_ARCHITECTURE) && is_field("Architecture", line))
                        parse_architecture(pkg, line + strlen("Architecture") + 1);
index d1f901a1031472e8bf8dd24f064c8cfe706d3364..e27eadd9d4646262995558625c4652d531378ab1 100644 (file)
@@ -54,6 +54,7 @@ int pkg_parse_line(void *ptr, char *line, uint mask);
 #define PFM_SUGGESTS           (1 << 25)
 #define PFM_TAGS               (1 << 26)
 #define PFM_VERSION            (1 << 27)
+#define PFM_ABIVERSION         (1 << 28)
 
 #define PFM_ALL        (~(uint)0)