~mrooney/+junk/ezpkg

« back to all changes in this revision

Viewing changes to package.py

  • Committer: Michael Rooney
  • Date: 2010-01-02 04:38:24 UTC
  • Revision ID: mrooney@ubuntu.com-20100102043824-yhrbw3m91horyxyc
abstract out the configuration into config.py so that is the only thing you need to change, and make PKGROOT configurable, by default in the directory of ezpkg

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
Example:
6
6
    package.py wxbanker 0.6 .0.0~ppa1 ppa1 ppa2 lp
7
7
"""
 
8
APP = []
8
9
import commands, os
9
 
APP = []
10
 
 
11
 
### THINGS YOU MIGHT CHANGE ###
12
 
# If you say "package.py foo 1.0", you must have the bzr branch at CODEROOT/foo-1.0
13
 
CODEROOT = "~/Code/packages"
14
 
# The name associated with your GPG key that Launchpad knows about.
15
 
os.environ['DEBFULLNAME'] = "Michael Rooney (PPA)"
16
 
# The list of available PPAs that you can specify on the command-line.
17
 
PPAS = {
18
 
    "dev": "mrooney/wxbanker-testing",
19
 
    "stable": "mrooney/ppa",
20
 
    "users": "wxbanker-users/ppa",
21
 
    "eart": "elementaryart/ppa",
22
 
}
23
 
# The distributions it will be uploaded to for each ppa.
24
 
DISTS = {
25
 
    #"10.04": "lucid",
26
 
    "9.10": "karmic",
27
 
    "9.04": "jaunty",
28
 
    #"8.10": "intrepid",
29
 
    #"8.04": "hardy",
30
 
}
31
 
### END THINGS YOU MIGHT CHANGE ###
 
10
from config import PKGROOT, CODEROOT, PPAS, DISTS
32
11
 
33
12
def replace(command):
34
 
    return command.replace("[ROOT]", CODEROOT).replace("[APP]", APP[0])
 
13
    replacements = (("ROOT", CODEROOT), ("APP", APP[0]), ("PKGROOT", PKGROOT))
 
14
    for variable, replacement in replacements:
 
15
        command = command.replace("[%s]"%variable, replacement)
 
16
    return command
35
17
 
36
18
def perform(cmds):
37
19
    for command in cmds:
44
26
 
45
27
def prepare(version):
46
28
    commands = [
47
 
        "mkdir -p ~/packaging",
48
 
        "rm -rf ~/packaging/*",
49
 
        "bzr export ~/packaging/[APP] [ROOT]/[APP]-%s" % version
 
29
        "mkdir -p [PKGROOT]",
 
30
        "rm -rf [PKGROOT]/*",
 
31
        "bzr export [PKGROOT]/[APP] [ROOT]/[APP]-%s" % version
50
32
        ]
51
33
    perform(commands)
52
34
 
53
35
    # If the package doesn't contain a debian already, assume it is a separate thing to export.
54
 
    pdir = os.path.expanduser(replace("~/packaging/[APP]/debian"))
 
36
    pdir = os.path.expanduser(replace("[PKGROOT]/[APP]/debian"))
55
37
    if not os.path.exists(pdir):
56
 
        perform(["bzr export ~/packaging/[APP]/debian [ROOT]/packaging-%s" % version])
 
38
        perform(["bzr export [PKGROOT]/[APP]/debian [ROOT]/packaging-%s" % version])
57
39
 
58
40
 
59
41
def dch(version, dist=""):
64
46
        dist = sorted(DISTS.keys())[-1]
65
47
        print "Latest:", dist
66
48
 
67
 
    perform(["dch -b -v %s%s -c ~/packaging/[APP]/debian/changelog -D %s \"automated upload\"" % (version, distMod, DISTS[dist])])
 
49
    perform(["dch -b -v %s%s -c [PKGROOT]/[APP]/debian/changelog -D %s \"automated upload\"" % (version, distMod, DISTS[dist])])
68
50
 
69
51
def watermark(mark):
70
52
    for script in ("postinst", "postrm"):
71
 
        inst = replace(os.path.expanduser("~/packaging/[APP]/debian/%s"%script))
 
53
        inst = replace(os.path.expanduser("[PKGROOT]/[APP]/debian/%s"%script))
72
54
        # If there isn't a postinst or preinst, we can't watermark of course.
73
55
        if not os.path.exists(inst):
74
56
            return False
80
62
        print "Watermarked as as: %s" % mark
81
63
 
82
64
def make_unsigned_deb():
83
 
    perform(["cd ~/packaging/[APP] && debuild -i -us -uc -b"])
 
65
    perform(["cd [PKGROOT]/[APP] && debuild -i -us -uc -b"])
84
66
 
85
67
def make_source():
86
 
    perform(["cd ~/packaging/[APP] && debuild -S -sa"])
 
68
    perform(["cd [PKGROOT]/[APP] && debuild -S -sa"])
87
69
 
88
70
def make_tgz(major, version):
89
71
    name = "[APP]-%s"%version
90
72
    perform([
91
 
        "bzr export ~/packaging/[APP]-%s [ROOT]/[APP]-%s" % (version, major),
92
 
        "cd ~/packaging && tar -cz %s --file %s.tar.gz" % (name, name),
 
73
        "bzr export [PKGROOT]/[APP]-%s [ROOT]/[APP]-%s" % (version, major),
 
74
        "cd [PKGROOT] && tar -cz %s --file %s.tar.gz" % (name, name),
93
75
        ])
94
76
 
95
77
def gen_sig(filepath):
97
79
    perform(["cd %s && gpg --armor --sign --detach-sig %s" % (dir, file)])
98
80
 
99
81
def upload(ppa, dist=""):
100
 
    perform(["dput --force ppa:%s ~/packaging/*%s_source.changes" % (ppa, dist)])
 
82
    perform(["dput --force ppa:%s [PKGROOT]/*%s_source.changes" % (ppa, dist)])
101
83
    print "Uploaded to %s" % ppa
102
84
 
103
85
def share():
104
86
    perform([
105
87
        "rm -rf ~/Public/packaging",
106
 
        "cp -r ~/packaging ~/Public/",
 
88
        "cp -r [PKGROOT] ~/Public/",
107
89
        ])
108
90
 
109
91
 
122
104
            make_tgz(major, version)
123
105
            # We only need to sign 'lp' releases.
124
106
            if dest == "lp":
125
 
                gen_sig("~/packaging/[APP]_%s_all.deb"%version)
126
 
                gen_sig("~/packaging/[APP]-%s.tar.gz"%version)
 
107
                gen_sig("[PKGROOT]/[APP]_%s_all.deb"%version)
 
108
                gen_sig("[PKGROOT]/[APP]-%s.tar.gz"%version)
127
109
        else:
128
110
            ppa = PPAS[dest]
129
111
            # Upload for each distribution supported.