Skip to content
Snippets Groups Projects
Unverified Commit 69459391 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Add a version suffix even when there are no local changes


We always add some extra files, at least the Apertis component,
plus copyright scanning results. Since those are intended to end up
in the source package, we should append a version suffix regardless
of any other actual changes we add on top.

Since these changes are an addition of metadata only, co0 seems a
good enough starting version.

Instead of dch, we use a custom changelog modification implementation.
This is because dch insists on launching an interactive editor when
a changelog is finalised.

Apertis: T7556

Signed-off-by: default avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
parent a71bf970
No related branches found
No related tags found
2 merge requests!167T7556: Add version suffix to newly imported updates,!93WIP: documentation-builder: Rebase on Apertis instead of Debian Buster
......@@ -16,13 +16,12 @@ import sys
import tempfile
import urllib.request
from sh import dch
from sh.contrib import git
from pathlib import Path
from debian.debian_support import Version
from debian.changelog import Changelog
from debian.changelog import Changelog, VersionError, format_date
APERTIS_CI_NAME = 'Apertis CI'
APERTIS_CI_EMAIL = 'devel@lists.apertis.org'
......@@ -72,6 +71,24 @@ def get_current_branch_name():
branch = git('rev-parse', '-q', '--verify', '--symbolic-full-name', 'HEAD', _ok_code=[0, 1]).strip('\n')
return branch.replace('refs/heads/', '', 1)
def bump_version(version: Version, changes: list, release: bool = False):
with Path("debian/changelog") as f:
ch = Changelog(f.read_text())
if version <= ch.version:
raise VersionError("The new version must be greater than the last one.")
ch.new_block(package=ch.package,
version=version,
distributions='apertis' if release else 'UNRELEASED',
urgency='medium',
author=('%s <%s>' % (APERTIS_CI_NAME, APERTIS_CI_EMAIL)),
date=format_date())
ch.add_change('')
for change in changes:
ch.add_change(f' * {change}')
ch.add_change('')
f.write_text(str(ch))
git.add('-f', f)
def main():
parser = argparse.ArgumentParser(description='Merge updates from the upstream repositories to the derivative branch')
parser.add_argument('--package', dest='package', type=str, help='the package name (e.g. glib2.0)') # TODO: figure this out from the repo
......@@ -99,14 +116,26 @@ def main():
print(e)
sys.exit(1)
o = git('diff', '--exit-code', args.upstream, 'debian/changelog', _ok_code=[0,1])
o = git('diff', '--exit-code', args.upstream, ':!debian/changelog', ':!debian/apertis/*', _ok_code=[0,1])
if o.exit_code == 1:
# debian/changelog isn't as is from debian, so someone should
# we carry some changes in addition to changelog entries
# and metadata under debian/apertis, so someone should
# re-summarize the remaining changes
version = upstream_version.full_version + 'co1'
dch('--no-auto-nmu', f"--newversion={version}",
'PLEASE SUMMARIZE remaining Apertis changes')
git('commit', '--amend', '--no-edit', 'debian/changelog')
bump_version(
version,
['PLEASE SUMMARIZE remaining Apertis changes'],
release=False
)
else:
# no changes, but we add a suffix anyway
version = upstream_version.full_version + 'co0'
bump_version(
version,
[f'Sync from Debian {args.upstream}.'],
release=True
)
git('commit', '--amend', '--no-edit', 'debian/changelog')
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment