From f247401133fc84d621f53e80370770b12c526520 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Fri, 19 Aug 2016 14:46:57 +0200 Subject: [PATCH] beeversion: Add two additional format placeholders Add *E* and *d* as placeholders to format the extra version. Sometimes, the bee version requirement, to separate the extra version with an underscore, contradicts the upstream versioning, which for example uses a dash. 4.8-rc2 is the version of the second release candidate of the Linux kernel 4.8. An underscore has to be used in the bee file version though. ``` $ beeversion linux-4.8_rc2-95.x86_64 PKGNAME=linux PKGEXTRANAME= PKGEXTRANAME_UNDERSCORE= PKGEXTRANAME_DASH= PKGVERSION=( 4.8 4 4.8 ) PKGEXTRAVERSION=rc2 PKGEXTRAVERSION_UNDERSCORE=_rc2 PKGEXTRAVERSION_DASH=-rc2 PKGREVISION=95 PKGARCH=x86_64 PKGFULLNAME=linux PKGFULLVERSION=4.8_rc2 PKGFULLPKG=linux-4.8_rc2-95 PKGALLPKG=linux-4.8_rc2-95.x86_64 PKGSUFFIX= ``` As can be seen, environment variables to output the extra version with a dash (-) or with an underscore (_) are provided. These options are missing as placeholders for the switch `format`. So, add them. *E* adds an underscore in front of the extra version, while *d* adds a dash. These are useful, as now, no additional logic has to be implemented in scripts calling `beeversion`, to check if an extra version is present, to determine if a separator needs to be added or not. In case of the Linux kernel, 4.8-rc2 can be created with the switch below. ``` > beeversion --format="%v%d" linux-4.8_rc2-95.x86_64 4.8-rc2 ``` --- src/bee_version_output.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bee_version_output.c b/src/bee_version_output.c index 55550bd..aa67df5 100644 --- a/src/bee_version_output.c +++ b/src/bee_version_output.c @@ -105,6 +105,12 @@ void print_format(char* s, struct beeversion *v, char *filter_pkgfullname) case 'e': printf("%s", v->extraversion); break; + case 'E': + printf("_%s", v->extraversion); + break; + case 'd': + printf("-%s", v->extraversion); + break; case 'r': printf("%s", v->pkgrevision); break;