Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions make-ppa
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

# Creates source packages and uploads them to Launchpad.
#
Expand All @@ -15,7 +15,7 @@ import re
import argparse

CHANGELOG = 'debian/changelog'
DISTS = ['trusty', 'xenial', 'bionic', 'focal', 'jammy', 'kinetic']

VERSION_PATTERN = re.compile(
r'^(?P<name>[+-.a-z0-9]+)\s+\((?P<version>[^)]+)\)\s+(?P<dist>[^)]+); urgency=(?P<urgency>.+)$')
OUTPUT_DIR = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -24,14 +24,27 @@ if sys.version_info[0] < 3:
input = raw_input


def supported_distros():
distro_info = subprocess.check_output(
['distro-info', '--supported', '--codename', '--days'], text=True
)

dists = []
for line in distro_info.splitlines():
name, days = line.split(' ')
if int(days) < 0:
dists.append(name)

return dists


class Package(object):

def __init__(self, dists=DISTS, ppa='yubico/stable'):
def __init__(self, dists, ppa):
self.dists = dists

file = open(CHANGELOG, 'r')
self.changelog = file.readlines()
file.close()
with open(CHANGELOG, 'r') as file:
self.changelog = file.readlines()
match = VERSION_PATTERN.match(self.changelog[0])

self.ppa = ppa
Expand Down Expand Up @@ -60,9 +73,8 @@ class Package(object):
changelog = list(self.changelog)
changelog[0] = line

file = open(CHANGELOG, 'w')
file.writelines(changelog)
file.close()
with open(CHANGELOG, 'w') as file:
file.writelines(changelog)

os.system('debuild -S -sa -us -uc')
os.system('mv ../%s_%s* %s/' %
Expand Down Expand Up @@ -92,9 +104,8 @@ class Package(object):
for dist in self.dists:
self.build_dist(dist)

file = open(CHANGELOG, 'w')
file.writelines(self.changelog)
file.close()
with open(CHANGELOG, 'w') as file:
file.writelines(self.changelog)

def sign(self, key, program):
args = [
Expand All @@ -118,7 +129,7 @@ if __name__ == '__main__':
help='Do not sign the packages (implies --no-upload)')
parser.add_argument('--no-upload', action='store_false', dest='upload',
help='Do not upload the (signed) packages')
parser.add_argument('--dists', nargs='+', default=DISTS, metavar='DIST',
parser.add_argument('--dists', nargs='+', default=supported_distros(), metavar='DIST',
help='Distributions to build for')
parser.add_argument('--ppa', nargs='?', default='yubico/stable',
help='PPA to upload to')
Expand Down