~ubuntu-branches/ubuntu/raring/sunpinyin/raring

« back to all changes in this revision

Viewing changes to wrapper/macos/packaging/package.py

  • Committer: Package Import Robot
  • Author(s): YunQiang Su
  • Date: 2012-03-30 15:31:55 UTC
  • mfrom: (1.1.3) (1.2.7 sid)
  • Revision ID: package-import@ubuntu.com-20120330153155-qgls77sogzgtg9zp
Tags: 2.0.3+git20120222-1
* Team upload: git snapshot 20120222.
   - fix breaks if LDFLAGS in environment contains
       multiple words (Closese #646001).
   - rm patches merged to upstream:
       append-os-environ-toenv.patch
       fix-ftbfs-on-sh.patch
       remove-10-candidate-words-limitation.patch
   - refresh disable-lm-dict-compile.patch.
* Bump stardard version to 3.9.3: no modify needed.
* add libsunpinyin3-dbg and python-sunpinyin packages.
* debian/compat to 9, multiarch it.
* rewrite debian/rules with dh 7 format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# Package SunPinyin for release
 
3
 
 
4
import sys, os, commands, time, plistlib
 
5
 
 
6
try:
 
7
    from jinja2 import Environment, FileSystemLoader
 
8
except:
 
9
    print "Install jinja2 first."
 
10
    sys.exit(1)
 
11
 
 
12
env = Environment(loader=FileSystemLoader('.'))
 
13
plist = plistlib.readPlist("../build/SunPinyin.app/Contents/Info.plist")
 
14
 
 
15
url_base = "http://sunpinyin.googlecode.com/files/"
 
16
xml_url_base = "http://release.sunpinyin.googlecode.com/hg/"
 
17
appcast_url = xml_url_base + "SunpinyinAppcast.xml"
 
18
 
 
19
pack_proj = "SunPinyin/SunPinyin.packproj"
 
20
pkg = "SunPinyin/build/SunPinyin.pkg"
 
21
resource_dir = "../build/SunPinyin.app/Contents/Resources"
 
22
 
 
23
version = plist["CFBundleVersion"]
 
24
releasenotes_url = xml_url_base + "SunpinyinReleaseNotes.xml"
 
25
 
 
26
zip = "SunPinyin-MacOS-%s.zip" % version
 
27
file_url = url_base + zip
 
28
 
 
29
priv_key = "%s/.ssh/dsa_priv.pem" % os.path.expanduser('~')
 
30
date = time.strftime("%a, %d %b %Y %H:%M:%S %z")
 
31
appcast_template = 'appcast.template.xml'
 
32
appcast = "sunpinyin_appcast.xml"
 
33
 
 
34
if len(sys.argv) > 1:
 
35
    priv_key = sys.argv[1]
 
36
 
 
37
def remove_if_exists(file):
 
38
    if os.path.isfile(file):
 
39
        os.remove(file)
 
40
 
 
41
print "[PACK] Remove temporary files..."
 
42
 
 
43
#remove_if_exists("%s/lm_sc.t3g" % resource_dir)
 
44
#remove_if_exists("%s/pydict_sc.bin" % resource_dir)
 
45
 
 
46
print "[PACK] Building %s..." % pkg
 
47
 
 
48
os.system("freeze -v %s" % pack_proj)
 
49
 
 
50
print "[PACK] Compressing %s..." % zip
 
51
os.chdir("SunPinyin/build")
 
52
os.system("zip -y -r ../../%s SunPinyin.pkg" % zip)
 
53
os.chdir("../..")
 
54
 
 
55
print "[PACK] Signing %s..." % zip
 
56
signed = commands.getoutput('openssl dgst -sha1 -binary < "%s" | openssl dgst -dss1 -sign "%s" | openssl enc -base64' % (zip, priv_key))
 
57
 
 
58
print "[PACK] Generating %s..." % appcast
 
59
template = env.get_template(appcast_template)
 
60
 
 
61
output = open(appcast, "w")
 
62
 
 
63
output.write(template.render(link=appcast_url,
 
64
        releaseNotesLink=releasenotes_url,
 
65
        url=file_url,
 
66
        date=date,
 
67
        version=version,
 
68
        length=os.path.getsize(zip),
 
69
        signed=signed).encode("utf-8"))
 
70
 
 
71
output.close()
 
72
 
 
73
print "Done! Please:\n  1. Publish %s to %s\n  2. Publish %s to %s\n  3. Update the release note for version %s at %s." % (appcast, appcast_url, zip, file_url, version, releasenotes_url)
 
74