| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
> |
| 5 |
|
| 6 |
|
| 7 |
import os |
| 8 |
import subprocess |
| 9 |
import time |
| 10 |
|
| 11 |
import distro_info |
| 12 |
|
| 13 |
GIT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) |
| 14 |
BASE = os.path.dirname(GIT) |
| 15 |
|
| 16 |
DH_VERSIONS = { |
| 17 |
'xenial': 9, |
| 18 |
'jammy': 13, |
| 19 |
'kinetic': 13, |
| 20 |
'lunar': 13, |
| 21 |
} |
| 22 |
|
| 23 |
subprocess.check_call(['git', 'checkout', 'debian/changelog'], |
| 24 |
cwd = GIT) |
| 25 |
subprocess.check_call(['git', 'checkout', 'debian/control'], |
| 26 |
cwd = GIT) |
| 27 |
|
| 28 |
from debian.changelog import Changelog |
| 29 |
with open('debian/changelog', encoding='utf-8') as log: |
| 30 |
cl = Changelog(log, strict=False) |
| 31 |
|
| 32 |
assert cl.distributions in ('unstable', 'UNRELEASED', 'experimental'), cl.distributions |
| 33 |
|
| 34 |
if cl.distributions == 'unstable': |
| 35 |
build_type = 'Backport to PPA' |
| 36 |
build_number = 'release+' |
| 37 |
else: |
| 38 |
build_type = 'Git snapshot' |
| 39 |
build_number = time.strftime('git%Y%m%d+') |
| 40 |
|
| 41 |
lts = distro_info.UbuntuDistroInfo().lts() |
| 42 |
current = distro_info.UbuntuDistroInfo().stable() |
| 43 |
|
| 44 |
releases = sorted(set([lts, current])) |
| 45 |
print('RELEASES:', releases) |
| 46 |
|
| 47 |
with open('debian/control', 'r') as compat: |
| 48 |
for line in compat: |
| 49 |
if 'debhelper-compat' in line: |
| 50 |
current_debhelper = int(line.split('(')[1].strip(' =),\n')) |
| 51 |
break |
| 52 |
|
| 53 |
for release in sorted(releases): |
| 54 |
supported_debhelper = DH_VERSIONS.get(release, current_debhelper) |
| 55 |
backported = set() |
| 56 |
|
| 57 |
if supported_debhelper < current_debhelper: |
| 58 |
backported.add('control') |
| 59 |
build_dep = 'debhelper-compat ( = %d)' % supported_debhelper |
| 60 |
subprocess.check_call(['sed', '-i', |
| 61 |
's/\ *debhelper-compat.*/ ' + build_dep + ',/', |
| 62 |
'debian/control'], |
| 63 |
cwd = GIT) |
| 64 |
|
| 65 |
snapshot = str(cl.version) + '~' + build_number + release |
| 66 |
subprocess.check_call(['dch', '-b', |
| 67 |
'-D', release, |
| 68 |
'-v', snapshot, |
| 69 |
build_type], |
| 70 |
cwd = GIT) |
| 71 |
|
| 72 |
subprocess.check_call(['debuild', '-S', '-sa'],cwd = GIT) |
| 73 |
subprocess.check_call(['dput', 'my-ppa', |
| 74 |
'gargoyle-free_%s_source.changes' % snapshot], |
| 75 |
cwd = BASE) |
| 76 |
|
| 77 |
subprocess.check_call(['git', 'checkout', 'debian/changelog'], |
| 78 |
cwd = GIT) |
| 79 |
|
| 80 |
for item in backported: |
| 81 |
subprocess.check_call(['git', 'checkout', 'debian/' + item], |
| 82 |
cwd = GIT) |
| 83 |
for file in ('.dsc', |
| 84 |
'_source.build', |
| 85 |
'_source.changes', |
| 86 |
'_source.my-ppa.upload'): |
| 87 |
subprocess.check_call(['rm', '-v', |
| 88 |
'gargoyle-free_%s%s' % (snapshot, file)], |
| 89 |
cwd = BASE) |