1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-15 10:48:33 +01:00
Clementine-audio-player-Mac.../dist/googlecode_upload_all.py

227 lines
5.8 KiB
Python
Raw Normal View History

import getpass
import os
import re
import subprocess
import sys
import googlecode_upload
PROJECT_NAME = "clementine-player"
FILENAME_PATTERNS = {
"deb": "clementine_%(major)s.%(minor)s.%(patch)s%(tildeprerelease)s~%(distro)s_%(debarch)s.deb",
"rpm": "clementine-%(major)s.%(minor)s.%(patch)s-%(rpmrelease)s.%(distro)s.%(rpmarch)s.rpm",
"exe": "ClementineSetup-%(major)s.%(minor)s.%(patch)s%(prerelease)s.exe",
"dmg": "clementine-%(major)s.%(minor)s.%(patch)s%(prerelease)s.dmg",
"tar.gz": "clementine-%(major)s.%(minor)s.%(patch)s%(prerelease)s.tar.gz",
}
LABELS = {
"deb": ["Type-Package", "OpSys-Linux"],
"rpm": ["Type-Package", "OpSys-Linux", "Distro-Fedora"],
"exe": ["Type-Package", "OpSys-Windows", "Arch-i386"],
2011-12-05 13:58:55 +01:00
"dmg": ["Type-Package", "OpSys-OSX", "Distro-SnowLeopard", "Arch-x86-64"],
32: ["Arch-i386"],
64: ["Arch-x86-64"],
"lucid": ["Distro-Ubuntu"],
"maverick": ["Distro-Ubuntu"],
"natty": ["Distro-Ubuntu"],
"oneiric": ["Distro-Ubuntu"],
"squeeze": ["Distro-Debian"],
}
2011-12-05 13:58:55 +01:00
MIN_SIZE = {
"deb": 5000000,
"rpm": 4000000,
"exe": 18000000,
"dmg": 24000000,
"tar.gz": 8000000,
}
DEB_ARCH = {
32: "i386",
64: "amd64",
}
RPM_ARCH = {
32: "i686",
64: "x86_64",
}
DESCRIPTIONS = {
("deb", "lucid"): "for Ubuntu Lucid (10.04)",
("deb", "maverick"): "for Ubuntu Maverick (10.10)",
("deb", "natty"): "for Ubuntu Natty (11.04)",
("deb", "oneiric"): "for Ubuntu Oneiric (11.10)",
("deb", "squeeze"): "for Debian Squeeze",
("rpm", "fc15"): "for Fedora 15",
("rpm", "fc16"): "for Fedora 16",
("exe", None): "for Windows",
("dmg", None): "for Mac OS X",
("tar.gz", None): "source",
}
RELEASES = [
("deb", "lucid", 32),
("deb", "lucid", 64),
("deb", "maverick", 32),
("deb", "maverick", 64),
("deb", "natty", 32),
("deb", "natty", 64),
("deb", "oneiric", 32),
("deb", "oneiric", 64),
("deb", "squeeze", 32),
("deb", "squeeze", 64),
("rpm", "fc15", 32),
("rpm", "fc15", 64),
("rpm", "fc16", 32),
("rpm", "fc16", 64),
("exe", None, None),
("dmg", None, None),
("tar.gz", None, None),
]
class VersionInfo(object):
def __init__(self, root_dir):
filename = os.path.join(root_dir, "cmake/Version.cmake")
data = open(filename).read()
2011-12-05 13:58:55 +01:00
self.info = {
"major": self._version(data, "MAJOR"),
"minor": self._version(data, "MINOR"),
"patch": self._version(data, "PATCH"),
"prerelease": self._version(data, "PRERELEASE"),
}
2011-12-05 13:58:55 +01:00
for key, value in self.info.items():
setattr(self, key, value)
2011-12-05 13:58:55 +01:00
def _version(self, data, part):
regex = r"^set\(CLEMENTINE_VERSION_%s (\w+)\)$" % part
match = re.search(regex, data, re.MULTILINE)
2011-12-05 13:58:55 +01:00
if not match:
return ""
2011-12-05 13:58:55 +01:00
return match.group(1)
2011-12-05 13:58:55 +01:00
def filename(self, release):
(package, distro, arch) = release
2011-12-05 13:58:55 +01:00
data = dict(self.info)
data["distro"] = distro
data["rpmarch"] = RPM_ARCH.get(arch, None)
data["debarch"] = DEB_ARCH.get(arch, None)
data["tildeprerelease"] = ""
data["rpmrelease"] = "1"
2011-12-05 13:58:55 +01:00
if data["prerelease"]:
data["tildeprerelease"] = "~%s" % data["prerelease"]
data["rpmrelease"] = "0.%s" % data["prerelease"]
2011-12-05 13:58:55 +01:00
return FILENAME_PATTERNS[package] % data
2011-12-05 13:58:55 +01:00
def description(self, release):
(package, distro, arch) = release
2011-12-05 13:58:55 +01:00
version_name = "%(major)s.%(minor)s" % self.info
2011-12-05 13:58:55 +01:00
if self.patch is not "0":
version_name += ".%s" % self.patch
2011-12-05 13:58:55 +01:00
if self.prerelease:
version_name += " %s" % self.prerelease.upper()
2011-12-05 13:58:55 +01:00
os_name = DESCRIPTIONS[(package, distro)]
2011-12-05 13:58:55 +01:00
if arch is not None:
os_name += " %d-bit" % arch
2011-12-05 13:58:55 +01:00
return "Clementine %s %s" % (version_name, os_name)
2011-12-05 13:58:55 +01:00
def labels(self, release):
(package, distro, arch) = release
2011-12-05 13:58:55 +01:00
labels = LABELS.get(package, []) + \
LABELS.get(distro, []) + \
LABELS.get(arch, [])
2011-12-05 13:58:55 +01:00
if self.prerelease.startswith("rc"):
labels.append("Release-RC")
elif self.prerelease.startswith("beta"):
labels.append("Release-Beta")
else:
labels.append("Release-Stable")
2011-12-05 13:58:55 +01:00
return labels
def main():
dist_dir = os.path.dirname(os.path.abspath(__file__))
root_dir = os.path.normpath(os.path.join(dist_dir, ".."))
2011-12-05 13:58:55 +01:00
# Read the version file
version = VersionInfo(root_dir)
2011-12-05 13:58:55 +01:00
# Display the files that will be uploaded
for release in RELEASES:
filename = version.filename(release)
description = version.description(release)
2011-12-05 13:58:55 +01:00
if not os.path.exists(filename):
print
print "%s - file not found" % filename
print "Run this script from a directory containing all the release packages"
return 1
2011-12-05 13:58:55 +01:00
size = os.path.getsize(filename)
2011-12-05 13:58:55 +01:00
if size < MIN_SIZE[release[0]]:
print
print "%s - file not big enough" % filename
print "%s files are expected to be at least %d bytes, but this was %d bytes" % (
release[0], MIN_SIZE[release[0]], size)
return 1
2011-12-05 13:58:55 +01:00
labels = version.labels(release)
2011-12-05 13:58:55 +01:00
print "%-40s %15s %-55s %s" % (filename, "%d bytes" % size, description, " ".join(sorted(labels)))
2011-12-05 13:58:55 +01:00
print
2011-12-05 13:58:55 +01:00
# Prompt for username and password
username = raw_input("Google username: ")
if not username:
return 1
password = getpass.getpass("Google Code password (different to your Google account): ")
if not password:
return 1
2011-12-05 13:58:55 +01:00
print
2011-12-05 13:58:55 +01:00
# Upload everything
for release in RELEASES:
(status, reason, url) = googlecode_upload.upload(
file=version.filename(release),
project_name=PROJECT_NAME,
user_name=username,
password=password,
summary=version.description(release),
labels=version.labels(release),
)
2011-12-05 13:58:55 +01:00
if status != 201:
print "%s: (%d) %s" % (version.filename(release), status, reason)
else:
print "Uploaded %s" % url
2011-12-05 13:58:55 +01:00
return 0
2011-12-05 13:58:55 +01:00
if __name__ == "__main__":
sys.exit(main())