summaryrefslogtreecommitdiffstats
path: root/rpmci/rpmci_spec_vcs_main.py
diff options
context:
space:
mode:
Diffstat (limited to 'rpmci/rpmci_spec_vcs_main.py')
-rw-r--r--rpmci/rpmci_spec_vcs_main.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/rpmci/rpmci_spec_vcs_main.py b/rpmci/rpmci_spec_vcs_main.py
index 935de5b..1e0ded2 100644
--- a/rpmci/rpmci_spec_vcs_main.py
+++ b/rpmci/rpmci_spec_vcs_main.py
@@ -14,6 +14,7 @@ import shutil
import optparse
import logging
import subprocess
+import datetime
import glib
import gobject
@@ -35,7 +36,8 @@ def _get_spec(options):
def set_revision(options, args):
if len(args) == 0:
- options.print_usage():
+ print "usage: set-revision COMMITID"
+ options.print_usage()
sys.exit(1)
revision = args[0]
@@ -45,31 +47,38 @@ def set_revision(options, args):
spec_obj = spec.Spec(specpath)
vcs_url = spec_obj.get_vcs()
- vcs = lame_vcs_abstraction.VCS.new_from_spec(vcs_url)
+ vcs = lame_vcs_abstraction.Vcs.new_from_spec(vcs_url)
+ vcs.set_directory(vcsdir)
resolved_id = vcs.resolve_id(revision)
- prefix = '%s-%s' % (spec.get_name(), resolved_id)
+ name = os.path.basename(spec_obj.get_name())
+ prefix = '%s-%s' % (name, resolved_id)
target_file = os.path.join(os.getcwd(), '%s.tar.bz2' % (prefix, ))
- vcs.export_archive(resolved_id, prefix, target_file, sys.stdout)
+ vcs.export_archive(resolved_id, prefix, target_file, sys.stderr)
-
+ now = datetime.datetime.now()
+ alphatag = "%s%s%s" % (now.strftime("%Y%m%d"), vcs.vcstype, resolved_id)
+ spec_obj.increment_release_snapshot(alphatag)
+ spec_obj.set_source(prefix, os.path.basename(target_file))
+ spec_obj.save()
def main():
glib.threads_init()
opts = optparse.OptionParser("usage: %prog [options] ACTION [args]")
opts.add_option('', '--debug', action='store_true', help="Print verbose debugging")
- opts.add_option('', '--vcsdir', action='store', help="Path to repository (defaults to current dir)")
+ opts.add_option('', '--vcsdir', action='store', dest="vcsdir",
+ default=None, help="Path to repository (defaults to current dir)")
(options, args) = opts.parse_args()
- if len(args) != 1:
+ if len(args) < 1:
opts.print_usage()
sys.exit(1)
verb = args[0]
if verb == 'set-revision':
- set_revision(opts, args[1:])
+ set_revision(options, args[1:])
else:
opts.print_usage()
sys.exit(1)