File: tbp-importorig

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 (94 lines) | stat: -rw-r--r-- 3,653 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
86
87
88
89
90
91
92
93
94
#!/usr/bin/python
# arch-tag: program to import and orig tar.gz or directory
# 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 os, sys
sys.path.append('/usr/share/tla-buildpackage')
from tbppy import tbpimport
from tbppy.versions import print_tbp_version
from vcs_support import commandver
import getopt

def printhelp():
    progname = os.path.basename(sys.argv[0])
    print """Usage: %s [options] orig-name package version
Import an upstream source into a tla-buildpackage archive

Where:
  orig-name  is the name of a tar.gz or directory to import
  package    is the name of the Debian source package
  version    is the upstream version being imported

Options:
  --tla-version=VERSION, --tla-upstream-version=VERSION
                  put the upstream sources into the tla version named VERSION
                  default: [package]--head--1.0
  --tla-branch-from=REVISION, --tla-upstream-branch-from=REVISION
                  branch the Debian sources from the tla revision named
                  REVISION; if no patch level is specified, the latest revision
                  from the given version will be used
  --force-version, --force-upstream-version
                  import this version even if it is older than other upstream
                  sources already imported
  -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',
                                                       'tla-upstream-version=',
                                                       'tla-upstream-branch-from=',
                                                       'tla-version=',
                                                       'tla-branch-from=',
                                                       'force-version',
                                                       'force-upstream-version'])
except getopt.GetoptError, err:
    print str(err)
    syntax(1)

opts = {}

for o, a in options:
    if o in ("-h", "--help"):
        syntax()
    elif o in ("-v", "--version"):
        print_tbp_version('tbp-importorig')
        sys.exit(0)
    elif o in ("--tla-version", "--tla-upstream-version"):
        opts['tla-upstream-version'] = a
    elif o in ("--tla-branch-from", "--tla-upstream-branch-from"):
        opts['tla-upstream-branch-from'] = a
    elif o in ("--force-version", "--force-upstream-version"):
        opts['force-upstream-version'] = True
    else:
        assert False, "unhandled option: %s" % o

if len(args) != 3:
    syntax(1)

commandver.setscm("tla")

ORIGNAME, PACKAGE, VERSION = args
if os.path.isdir(ORIGNAME):
    tbpimport.importorigdir(ORIGNAME, PACKAGE, VERSION, opts)
else:
    tbpimport.importorigtargz(ORIGNAME, PACKAGE, VERSION, opts)