~mrooney/+junk/ezpkg

« back to all changes in this revision

Viewing changes to package.py

  • Committer: Michael Rooney
  • Date: 2010-03-04 06:05:08 UTC
  • Revision ID: mrooney@wisdom-20100304060508-3hoi9x1ax0hbq9ge
enhance the project/packaging finding logic and improve output/documentation

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import commands, os
10
10
from config import PKGROOT, CODEROOT, PPAS, DISTS
11
11
 
12
 
def replace(command):
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):
 
17
            return path
 
18
    raise Exception("Unable to find project %s (version %s)" % (name, version))
 
19
 
 
20
def replace(command, version=None):
 
21
    proj = APP[0]
 
22
    replacements = [("ROOT", CODEROOT), ("APP", proj), ("PKGROOT", PKGROOT)]
 
23
    if version:
 
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)
16
27
    return command
17
28
 
18
 
def perform(cmds):
 
29
def perform(cmds, version=None):
19
30
    for command in cmds:
20
 
        command = replace(command)
 
31
        command = replace(command, version)
21
32
        print command
22
33
        status, output = commands.getstatusoutput(command)
23
34
        if output:
24
35
            print output
25
 
        assert status == 0, (command, output)
 
36
        assert status == 0 #, (command, output)
26
37
 
27
38
def prepare(version):
28
39
    commands = [
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]"
32
43
        ]
33
 
    perform(commands)
 
44
    perform(commands, version)
34
45
 
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)
39
50
 
40
51
 
41
52
def dch(version, dist=""):
70
81
def make_tgz(major, version):
71
82
    name = "[APP]-%s"%version
72
83
    perform([
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),
75
 
        ])
 
86
        ], version)
76
87
 
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"]: