Skip to content

Commit

Permalink
Merge pull request #88 from gleichdick/fix-29
Browse files Browse the repository at this point in the history
Replace @Version@ placeholders in .dsc files
  • Loading branch information
adrianschroeter authored Jan 11, 2024
2 parents d4150d2 + df50be9 commit edd5863
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions set_version
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,19 @@ def _replace_tag(filename, tag, string):
f.write(contents_new)


def _replace_variable(filename, variable, string):
# cmake configure_file behavior, replace variables marked with @ sign
with codecs.open(filename, 'r+', 'utf8') as f:
contents = f.read()
f.seek(0)
contents_new, subs = re.subn(
r"@{variable}@".format(variable=variable),
string, contents, flags=re.MULTILINE)
if subs > 0:
f.truncate()
f.write(contents_new)


def _replace_debian_changelog_version(fname, version_new):
# first, modify a copy of filename and then move it
# get current version
Expand Down Expand Up @@ -460,8 +473,12 @@ if __name__ == '__main__':
shutil.copyfile(f, filename)
if "-" in VersionDetector._get_version_via_debian_dsc(filename):
_replace_tag(filename, 'Version', version + "-0")
_replace_variable(filename, 'VERSION', version)
_replace_variable(filename, 'VERSION-RELEASE', version + "-0")
else:
_replace_tag(filename, 'Version', version)
_replace_variable(filename, 'VERSION', version)
_replace_variable(filename, 'VERSION-RELEASE', version)

for f in filter(lambda x: x.endswith(("debian.changelog")), files):
filename = outdir + "/" + f
Expand Down

0 comments on commit edd5863

Please sign in to comment.