From 11e1afd84ce43ebfa7d57ae4cf17dffb08cdafab Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Thu, 6 Jun 2013 20:58:51 -0700 Subject: [PATCH] ceph: add -v for version. Makefile processes ceph_ver.h Signed-off-by: Dan Mick --- src/Makefile.am | 17 ++++++++++++++++- src/{ceph => ceph.in} | 9 ++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) rename src/{ceph => ceph.in} (99%) diff --git a/src/Makefile.am b/src/Makefile.am index e851f9888bf1..c792f1042233 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1240,7 +1240,7 @@ EXTRA_DIST += \ $(srcdir)/upstart/radosgw.conf \ $(srcdir)/upstart/radosgw-all.conf \ $(srcdir)/upstart/radosgw-all-starter.conf \ - ceph \ + ceph.in \ ceph-disk \ ceph-disk-prepare \ ceph-disk-activate \ @@ -1305,6 +1305,21 @@ ceph_ver.c: ./ceph_ver.h common/version.cc: ./ceph_ver.h test/encoding/ceph_dencoder.cc: ./ceph_ver.h +# assemble Python script with global version variables +# NB: depends on format of ceph_ver.h + +ceph: ceph.in ./ceph_ver.h Makefile + rm -f $@ $@.tmp + echo "#!/usr/bin/python" >$@.tmp + grep "#define CEPH_GIT_NICE_VER" ./ceph_ver.h | \ + sed -e 's/#define \(.*VER\) /\1=/' >>$@.tmp + grep "#define CEPH_GIT_VER" ./ceph_ver.h | \ + sed -e 's/#define \(.*VER\) /\1=/' -e 's/=\(.*\)$$/="\1"/' >>$@.tmp + cat $@.in >>$@.tmp + chmod a+x $@.tmp + chmod a-w $@.tmp + mv $@.tmp $@ + # cleaning clean-local: -rm *.so *.gcno *.gcda diff --git a/src/ceph b/src/ceph.in similarity index 99% rename from src/ceph rename to src/ceph.in index 678d83484860..0b345a593021 100755 --- a/src/ceph +++ b/src/ceph.in @@ -1,4 +1,6 @@ -#!/usr/bin/python +# +# Processed in Makefile to add python #! line and version variable +# import argparse import copy @@ -820,6 +822,7 @@ def parse_cmdargs(args=None, target=''): parser.add_argument('--watch-error', action='store_true', help='watch error events') + parser.add_argument('-v', action="store_true") parser.add_argument('--verbose', action="store_true") parser.add_argument('--concise', dest='verbose', action="store_false") @@ -1300,6 +1303,10 @@ def main(): parser, parsed_args, childargs = parse_cmdargs() + if parsed_args.v: + print 'ceph version {0} ({1})'.format(CEPH_GIT_NICE_VER, CEPH_GIT_VER) + return 0 + global verbose verbose = parsed_args.verbose -- 2.47.3