File: tbp-markdeb

package info (click to toggle)
tla-buildpackage 0.9.13
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 392 kB
  • ctags: 46
  • sloc: python: 738; sh: 62; makefile: 49
file content (85 lines) | stat: -rw-r--r-- 2,920 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/python
# arch-tag: tool to note that a particular version is "golden"
# Copyright (C) 2003 John Goerzen
#               2008 Hubert Chathi
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
#

import sys, os
sys.path.append('/usr/share/tla-buildpackage')
from tbppy import versions, extcmd, tbpconfig, configs, tla
import getopt

def printhelp():
    progname = os.path.basename(sys.argv[0])
    print """Usage: %s [options]
Mark the Debian version of the working directory in archive

Options:
  --force-version mark this Debian version even if it is already marked in the
                  archive
  -h, --help      display this help message and exit
  -v, --version   display version information and exit""" % progname

def syntax(code = 0):
    printhelp()
    sys.exit(code)

try:
    options, args = getopt.getopt(sys.argv[1:], 'hv', ['help', 'version',
                                                       'force-version'])
except getopt.GetoptError, err:
    print str(err)
    syntax(1)

FORCE = False

for o, a in options:
    if o in ("-h", "--help"):
        syntax()
    elif o in ("-v", "--version"):
        versions.print_tbp_version('tbp-markdeb')
        sys.exit(0)
    elif o in ("--force-version"):
        FORCE = True
    else:
        assert False, "unhandled option: %s" % o

debver, upstreamver, package, wcdir = tbpconfig.pkginit()
startdir = os.getcwd()
os.chdir(wcdir)

if configs.hasconfig('debian', package, debver):
    if not FORCE:
        print " *** ERROR: configuration for %s %s already exists; not modifying"%\
              (package, debver)
        sys.exit(100)
    print " *** WARNING: configuration for %s %s already exists;"%\
          (package, debver)
    print " *** but continuing anyways, as requested"

os.chdir(startdir)
tlaversion = tla.gettreeversion()
newrev_base = extcmd.run('tla revisions')[-1]
newrev = '%s--%s' % (tlaversion, newrev_base)
os.chdir(wcdir)
configs.writelatest('debian', package, debver, tlaversion)
configs.writeconfig('debian', package, debver, newrev)
extcmd.qrun('tla commit -L "Added configs for Debian %s %s"' % \
            (package, debver))

print " *** Success: Noted Debian %s version %s\n *** at %s" % \
      (package, debver, newrev)