Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add pkg -v to show the version and the git hash if cloned from git
Baptiste Daroussin committed 14 years ago
commit 92e838218c87cb647a904b7c1c8062df54c36d51
parent 95f1b9e
2 files changed +12 -1
modified pkg/Makefile
@@ -22,6 +22,11 @@ SRCS= add.c \
		which.c
BINDIR=		/usr/sbin

+
.if exists(../.git)
+
GITHASH!=	git rev-parse HEAD
+
CFLAGS+=	-DGITHASH=\"${GITHASH}\"
+
.endif
+

DEBUG_FLAGS+=	-g -O0
.if defined(PROFILE_BUILD)
DEBUG_FLAGS+=	-pg
modified pkg/main.c
@@ -31,6 +31,8 @@
#include "version.h"
#include "which.h"

+
#define PKGVERSION "1.0-alpha2+"
+

static void usage(void);
static void usage_help(void);
static int exec_help(int, char **);
@@ -141,7 +143,7 @@ main(int argc, char **argv)

	pkg_event_register(&event_callback, &debug);

-
	while ((ch = getopt(argc, argv, "dj:c:")) != -1) {
+
	while ((ch = getopt(argc, argv, "dj:c:v")) != -1) {
		switch(ch) {
			case 'd':
				debug++;
@@ -152,6 +154,10 @@ main(int argc, char **argv)
			case 'j':
				jail_str = optarg;
				break;
+
			case 'v':
+
				printf(PKGVERSION" "GITHASH"\n");
+
				exit(EXIT_SUCCESS);
+
				break; /* NOT REACHED */
			default:
				break;
		}