From 2dc285b7b21e53b09a5738c8bc7ed5c1ab65d8d3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Tue, 16 Sep 2008 22:12:48 +0200 Subject: [PATCH] add some version checking and stuff --- iw.c | 2 +- version.sh | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/iw.c b/iw.c index 58d58f0..bbaba4d 100644 --- a/iw.c +++ b/iw.c @@ -105,7 +105,7 @@ static void usage(const char *argv0) static void version(void) { - printf("iw version " VERSION IW_GIT_VERSION "\n"); + printf("iw version " IW_VERSION "\n"); } static int phy_lookup(char *name) diff --git a/version.sh b/version.sh index 9126ef2..f61b39a 100755 --- a/version.sh +++ b/version.sh @@ -1,17 +1,23 @@ -#!/bin/sh +#!/bin/bash VERSION="0.9" ( -echo "#define VERSION \"$VERSION\"" if head=`git rev-parse --verify HEAD 2>/dev/null`; then git update-index --refresh --unmerged > /dev/null - printf "#define IW_GIT_VERSION \"-g%.8s" "$head" + descr=$(git describe) + + # on git builds check that the version number above + # is correct... + [ "${descr/-*/}" == "v$VERSION" ] || exit 2 + + echo -n '#define IW_VERSION "' + echo -n "${descr:1}" if git diff-index --name-only HEAD | read dummy ; then - printf -- "-dirty" + echo -n "-dirty" fi echo '"' else - echo '#define IW_GIT_VERSION ""' +echo "#define IW_VERSION \"$VERSION\"" fi ) > version.h -- 2.39.2