Skip to content

Commit

Permalink
add version management in makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
gaubert committed Apr 24, 2012
1 parent 6cd2623 commit 2f73c02
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
9 changes: 7 additions & 2 deletions Makefile
Expand Up @@ -27,10 +27,15 @@ MAKENSIS=/cygdrive/d/Programs/NSIS/makensis.exe #windows work
#MAKENSIS=/c/Program\ Files/NSIS/makensis.exe #windows laptop

GMVVERSION=0.5
GMVDISTNAME=gmvault-$(GMVVERSION)
GMVDISTNAME=gmvault-v$(GMVVERSION)
MYVERSION=$(shell python $(BASEDIR)/etc/utils/find_version.py $(BASEDIR)/src/gmv/gmv_cmd.py)


all: gmv-linux-dist

version:
echo $(MYVERSION)

init:
mkdir -p $(GMVDIST)
mkdir -p $(GMVBUILDDIST)
Expand Down Expand Up @@ -71,7 +76,7 @@ gmv-linux-dist: clean init
mkdir -p $(GMVDIST)/$(GMVDISTNAME)/bin
cp -R $(BASEDIR)/etc/scripts/gmvault $(GMVDIST)/$(GMVDISTNAME)/bin
cd $(GMVDIST); tar zcvf ./$(GMVDISTNAME).tar.gz ./$(GMVDISTNAME)
echo "distribution stored in $(GMVDISTNAME)"
echo "distribution stored in $(GMVDIST)/$(GMVDISTNAME)"

gmv-win-dist: init
mkdir -p $(GMVWINBUILDDIST)
Expand Down
14 changes: 14 additions & 0 deletions etc/utils/find_version.py
@@ -0,0 +1,14 @@
import sys

if len(sys.argv) < 2:
print("Error: Need the path to gmv_cmd.py")
exit(-1)

path = sys.argv[1]

fd = open(path)

for line in fd:
index = line.find("GMVAULT_VERSION=\"")
if index > -1:
print(line[index+17:-2])
20 changes: 11 additions & 9 deletions src/gmv/gmv_cmd.py
Expand Up @@ -30,6 +30,8 @@
from cmdline_utils import CmdLineParser
from credential_utils import CredentialHelper

GMVAULT_VERSION="1.0-beta"

GLOBAL_HELP_EPILOGUE="""Examples:
a) Get help for each of the individual commands
Expand Down Expand Up @@ -94,8 +96,10 @@ def _create_parser(self):
parser = CmdLineParser()

parser.epilogue = GLOBAL_HELP_EPILOGUE

subparsers = parser.add_subparsers(help='commands (mandatory).')

parser.add_argument("-v", '--version', action='version', version='Gmvault v%s' % (GMVAULT_VERSION))

subparsers = parser.add_subparsers(title='subcommands', help='valid subcommands.')

# A sync command
sync_parser = subparsers.add_parser('sync', \
Expand Down Expand Up @@ -225,12 +229,10 @@ def _create_parser(self):


# A config command
config_parser = subparsers.add_parser('config', help='add/delete/modify properties in configuration.')
config_parser.add_argument('dirname', action='store', help='New directory to create')
config_parser.add_argument('--read-only', default=False, action='store_true',
help='Set permissions to prevent writing to the directory',
)
config_parser.set_defaults(verb='config')
#config_parser = subparsers.add_parser('config', help='add/delete/modify properties in configuration.')
#config_parser.add_argument('dirname', action='store', help='New directory to create')
#config_parser.add_argument('--read-only', default=False, action='store_true', help='Set permissions to prevent writing to the directory',)
#config_parser.set_defaults(verb='config')

return parser

Expand Down Expand Up @@ -306,7 +308,7 @@ def parse_args(self):
LOG.debug("Namespace = %s\n" % (options))

parsed_args = { }

parsed_args['command'] = options.verb

if parsed_args.get('command', '') == 'sync':
Expand Down

0 comments on commit 2f73c02

Please sign in to comment.