10
10
from config import PKGROOT, CODEROOT, PPAS, DISTS
13
replacements = (("ROOT", CODEROOT), ("APP", APP[0]), ("PKGROOT", PKGROOT))
12
def findProject(name, version):
13
potentials = ["%s-%s" % (name, version), name]
14
for potential in potentials:
15
path = os.path.expanduser(os.path.join(CODEROOT, potential))
16
if os.path.exists(path):
18
raise Exception("Unable to find project %s (version %s)" % (name, version))
20
def replace(command, version=None):
22
replacements = [("ROOT", CODEROOT), ("APP", proj), ("PKGROOT", PKGROOT)]
24
replacements += [("APPLOC", findProject(proj, version)), ("PKGINGLOC", findProject("packaging", version))]
14
25
for variable, replacement in replacements:
15
26
command = command.replace("[%s]"%variable, replacement)
29
def perform(cmds, version=None):
19
30
for command in cmds:
20
command = replace(command)
31
command = replace(command, version)
22
33
status, output = commands.getstatusoutput(command)
25
assert status == 0, (command, output)
36
assert status == 0 #, (command, output)
27
38
def prepare(version):
29
40
"mkdir -p [PKGROOT]",
30
41
"rm -rf [PKGROOT]/*",
31
"bzr export [PKGROOT]/[APP] [ROOT]/[APP]-%s" % version
42
"bzr export [PKGROOT]/[APP] [APPLOC]"
44
perform(commands, version)
35
46
# If the package doesn't contain a debian already, assume it is a separate thing to export.
36
47
pdir = os.path.expanduser(replace("[PKGROOT]/[APP]/debian"))
37
48
if not os.path.exists(pdir):
38
perform(["bzr export [PKGROOT]/[APP]/debian [ROOT]/packaging-%s" % version])
49
perform(["bzr export [PKGROOT]/[APP]/debian [PKGINGLOC]"], version)
41
52
def dch(version, dist=""):
70
81
def make_tgz(major, version):
71
82
name = "[APP]-%s"%version
73
"bzr export [PKGROOT]/[APP]-%s [ROOT]/[APP]-%s" % (version, major),
84
"bzr export [PKGROOT]/%s [APPLOC]" % (name),
74
85
"cd [PKGROOT] && tar -cz %s --file %s.tar.gz" % (name, name),
77
88
def gen_sig(filepath):
78
89
dir, file = os.path.split(filepath)
95
106
# Iterate over each destination (PPA) to upload to.
96
107
# Use "lp" destination (default) to build a .deb and .tar.gz
97
108
if destinations not in [["lp"], ["test"]]: # Only warn if this is actually going to PPA[s]
98
raw_input("Will create %s%s and upload to %s for %s. Enter to continue..." % (major, minor, destinations, DISTS.keys()))
109
raw_input("Will create %s %s%s and upload to %s for %s. Enter to continue..." % (replace("[APP]"), major, minor, destinations, DISTS.keys()))
99
110
for dest in destinations:
100
111
watermarked = watermark("%s%s~%s"%(major,minor,dest))
101
112
if dest in ["lp", "test"]: