* ppaput: fix indentation issues.

This commit is contained in:
Daniel Holbach 2007-10-01 16:13:47 +02:00
parent 242d758f27
commit 17794d65bb
2 changed files with 65 additions and 62 deletions

3
debian/changelog vendored
View File

@ -3,6 +3,9 @@ ubuntu-dev-tools (0.15) UNRELEASED; urgency=low
[ Laurent Bigonville ] [ Laurent Bigonville ]
* update-maintainer: correctly pass path to dch (LP: #141015) * update-maintainer: correctly pass path to dch (LP: #141015)
[ Daniel Holbach ]
* ppaput: fix indentation issues.
-- Daniel Holbach <daniel.holbach@ubuntu.com> Mon, 01 Oct 2007 15:56:18 +0200 -- Daniel Holbach <daniel.holbach@ubuntu.com> Mon, 01 Oct 2007 15:56:18 +0200
ubuntu-dev-tools (0.14) gutsy; urgency=low ubuntu-dev-tools (0.14) gutsy; urgency=low

124
ppaput
View File

@ -49,15 +49,15 @@ USAGE = \
def dput_check(): def dput_check():
if not os.path.exists("/usr/bin/dput"): if not os.path.exists("/usr/bin/dput"):
print >> sys.stderr, "You need to install the dput package." print >> sys.stderr, "You need to install the dput package."
sys.exit(1) sys.exit(1)
def find_fixed_launchpad_bug(changesfile): def find_fixed_launchpad_bug(changesfile):
changes = open(changesfile).readlines() changes = open(changesfile).readlines()
for line in changes: for line in changes:
if line.startswith("Launchpad-Bugs-Fixed"): if line.startswith("Launchpad-Bugs-Fixed"):
return line.split(":")[1].split() return line.split(":")[1].split()
return [] return []
@ -70,12 +70,12 @@ def call_dput(location, changes):
(dummy, output, dummy) = os.popen3("dput --debug %s %s" % (location, changes)) (dummy, output, dummy) = os.popen3("dput --debug %s %s" % (location, changes))
text = output.readlines() text = output.readlines()
for line in text: for line in text:
if line.startswith("D: Incoming: "): if line.startswith("D: Incoming: "):
incoming = line.split("D: Incoming: ")[1].strip() incoming = line.split("D: Incoming: ")[1].strip()
if incoming[-1] == "/": if incoming[-1] == "/":
incoming = incoming[:-1] incoming = incoming[:-1]
if line.startswith("Successfully uploaded packages."): if line.startswith("Successfully uploaded packages."):
res = True res = True
return (res, incoming) return (res, incoming)
@ -84,7 +84,7 @@ def lookup_dput_host(host):
(dummy, output, dummy) = os.popen3("dput -H | grep ^%s" % host) (dummy, output, dummy) = os.popen3("dput -H | grep ^%s" % host)
text = output.read() text = output.read()
if text: if text:
return text.split()[2] return text.split()[2]
return "" return ""
@ -103,8 +103,8 @@ def call_debuild(options):
def get_name_and_version(): def get_name_and_version():
changelogfile = "debian/changelog" changelogfile = "debian/changelog"
if not os.path.exists(changelogfile): if not os.path.exists(changelogfile):
print >> sys.stderr, "%s not found." % changelogfile print >> sys.stderr, "%s not found." % changelogfile
sys.exit(1) sys.exit(1)
head = open(changelogfile).readline() head = open(changelogfile).readline()
return re.findall(r'^(.*)\ \((.*)\).*', head) return re.findall(r'^(.*)\ \((.*)\).*', head)
@ -112,13 +112,13 @@ def get_name_and_version():
def assemble_bug_comment_text(host, incoming, sourcepackage, version): def assemble_bug_comment_text(host, incoming, sourcepackage, version):
if host == "ppa.launchpad.net": if host == "ppa.launchpad.net":
dsc_file_location = "http://%s/%s/pool/main/%s/%s/%s_%s.dsc" % \ dsc_file_location = "http://%s/%s/pool/main/%s/%s/%s_%s.dsc" % \
(host, incoming[1:], sourcepackage[0], sourcepackage, \ (host, incoming[1:], sourcepackage[0], sourcepackage, \
sourcepackage, version) sourcepackage, version)
else: else:
# FIXME: this needs to be much much cleverer at some stage # FIXME: this needs to be much much cleverer at some stage
dsc_file_location = "http://%s/%s/pool/main/%s/%s/%s_%s.dsc" % \ dsc_file_location = "http://%s/%s/pool/main/%s/%s/%s_%s.dsc" % \
(host, incoming, sourcepackage[0], sourcepackage, version) (host, incoming, sourcepackage[0], sourcepackage, version)
return """A new version of %s was uploaded to fix this bug. return """A new version of %s was uploaded to fix this bug.
To review the current version, please run To review the current version, please run
@ -129,9 +129,9 @@ To review the current version, please run
def deal_with_bugreport(bugnumbers, host, incoming, sourcepackage, version): def deal_with_bugreport(bugnumbers, host, incoming, sourcepackage, version):
if not os.path.exists(os.path.expanduser("~/.lpcookie")): if not os.path.exists(os.path.expanduser("~/.lpcookie")):
print >> sys.stderr, \ print >> sys.stderr, \
"You need your Launchpad Cookie to be stored in ~/.lpcookie" "You need your Launchpad Cookie to be stored in ~/.lpcookie"
sys.exit(1) sys.exit(1)
#print apt.Cache()[sourcepackage].section.split("/")[0].count("verse") #print apt.Cache()[sourcepackage].section.split("/")[0].count("verse")
(dummy, output, dummy) = os.popen3( (dummy, output, dummy) = os.popen3(
@ -143,25 +143,25 @@ def deal_with_bugreport(bugnumbers, host, incoming, sourcepackage, version):
Bug.authentication = os.path.expanduser("~/.lpcookie") Bug.authentication = os.path.expanduser("~/.lpcookie")
for bugnumber in bugnumbers: for bugnumber in bugnumbers:
bug = Bug(int(bugnumber)) bug = Bug(int(bugnumber))
if component in ["main", "restricted"] and \ if component in ["main", "restricted"] and \
'ubuntu-main-sponsors' not in [str(s) for s in bug.subscribers]: 'ubuntu-main-sponsors' not in [str(s) for s in bug.subscribers]:
bug.subscribers.add('ubuntu-main-sponsors') bug.subscribers.add('ubuntu-main-sponsors')
if component in ["universe", "multiverse"] and \ if component in ["universe", "multiverse"] and \
'ubuntu-universe-sponsors' not in [str(s) for s in bug.subscribers]: 'ubuntu-universe-sponsors' not in [str(s) for s in bug.subscribers]:
bug.subscribers.add('ubuntu-universe-sponsors') bug.subscribers.add('ubuntu-universe-sponsors')
if not component: if not component:
bug.tags.append("needs-packaging") bug.tags.append("needs-packaging")
comment = Bug.NewComment(text=assemble_bug_comment_text(host, incoming, comment = Bug.NewComment(text=assemble_bug_comment_text(host, incoming,
sourcepackage, version), sourcepackage, version),
subject="Fix in %s (%s)" % \ subject="Fix in %s (%s)" % \
(sourcepackage, version)) (sourcepackage, version))
bug.comments.add(comment) bug.comments.add(comment)
if bug.status != "Fix Committed": if bug.status != "Fix Committed":
bug.status = "Fix Committed" bug.status = "Fix Committed"
bug.commit() bug.commit()
def check_arguments(args): def check_arguments(args):
@ -170,28 +170,28 @@ def check_arguments(args):
debuild_args = list() debuild_args = list()
if len(sys.argv) == 2 and sys.argv[1] in ["--help", "-H"]: if len(sys.argv) == 2 and sys.argv[1] in ["--help", "-H"]:
print USAGE print USAGE
sys.exit(0) sys.exit(0)
if len(sys.argv) == 1: if len(sys.argv) == 1:
return (new_bug, location, debuild_args) return (new_bug, location, debuild_args)
if sys.argv[1] == "-n": if sys.argv[1] == "-n":
new_bug = True new_bug = True
if len(sys.argv)>2: if len(sys.argv)>2:
if sys.argv[2].startswith("-"): if sys.argv[2].startswith("-"):
debuild_args = sys.argv[2:] debuild_args = sys.argv[2:]
else: else:
location = sys.argv[2] location = sys.argv[2]
if len(sys.argv)>3: if len(sys.argv)>3:
debuild_args = sys.argv[3:] debuild_args = sys.argv[3:]
else: else:
if sys.argv[1].startswith("-"): if sys.argv[1].startswith("-"):
debuild_args.append(sys.argv[1:]) debuild_args.append(sys.argv[1:])
else: else:
location = sys.argv[1] location = sys.argv[1]
if len(sys.argv)>2: if len(sys.argv)>2:
debuild_args = sys.argv[2:] debuild_args = sys.argv[2:]
return (new_bug, location, debuild_args) return (new_bug, location, debuild_args)
@ -201,13 +201,13 @@ def file_bug(sourcepackage, version):
Bug.authentication = os.path.expanduser("~/.lpcookie") Bug.authentication = os.path.expanduser("~/.lpcookie")
try: try:
bug = Bug.New(product={"name": sourcepackage, "target": "ubuntu"}, bug = Bug.New(product={"name": sourcepackage, "target": "ubuntu"},
summary="Please sponsor %s %s" % \ summary="Please sponsor %s %s" % \
(sourcepackage, version), (sourcepackage, version),
description=\ description=\
"The new package will be uploaded to PPA shortly.") "The new package will be uploaded to PPA shortly.")
except: except:
bug = Bug.New(product={"name": "ubuntu"}, bug = Bug.New(product={"name": "ubuntu"},
summary="Please sponsor %s %s" % \ summary="Please sponsor %s %s" % \
(sourcepackage, version), (sourcepackage, version),
description=\ description=\
@ -224,26 +224,26 @@ def main():
(sourcepackage, version) = get_name_and_version()[0] (sourcepackage, version) = get_name_and_version()[0]
if new_bug: if new_bug:
bugnumber = file_bug(sourcepackage, version) bugnumber = file_bug(sourcepackage, version)
os.system("dch -a 'Fixes (LP: #%s)'" % bugnumber) os.system("dch -a 'Fixes (LP: #%s)'" % bugnumber)
if not call_debuild(debuild_args): if not call_debuild(debuild_args):
sys.exit(1) sys.exit(1)
changesfile = "../%s_%s_source.changes" % (sourcepackage, version) changesfile = "../%s_%s_source.changes" % (sourcepackage, version)
if not os.path.exists(os.path.expanduser(changesfile)): if not os.path.exists(os.path.expanduser(changesfile)):
print >> sys.stderr, "%s does not exist." % \ print >> sys.stderr, "%s does not exist." % \
os.path.expanduser(changesfile) os.path.expanduser(changesfile)
sys.exit(1) sys.exit(1)
host = lookup_dput_host(location) host = lookup_dput_host(location)
(dput_res, incoming) = call_dput(location, changesfile) (dput_res, incoming) = call_dput(location, changesfile)
if not dput_res: if not dput_res:
print >> sys.stderr, "%s was not uploaded." % changesfile print >> sys.stderr, "%s was not uploaded." % changesfile
sys.exit(1) sys.exit(1)
fixed_lp_bugs = find_fixed_launchpad_bug(changesfile) fixed_lp_bugs = find_fixed_launchpad_bug(changesfile)
if(fixed_lp_bugs): if(fixed_lp_bugs):
deal_with_bugreport(fixed_lp_bugs, host, incoming, sourcepackage, deal_with_bugreport(fixed_lp_bugs, host, incoming, sourcepackage,
version) version)