def tree_set_changelog_version(tree: WorkingTree, build_version: Version, subpath: str) -> None: cl_path = osutils.pathjoin(subpath, "debian/changelog") with tree.get_file(cl_path) as f: cl = Changelog(f) if Version(str(cl.version) + "~") > build_version: return cl.version = build_version with open(tree.abspath(cl_path), "w") as f: cl.write_to_open_file(f)
def make_changelog(self, version=None): if version is None: version = self.package_version c = Changelog() c.new_block() c.version = Version(version) c.package = self.package_name c.distributions = 'unstable' c.urgency = 'low' c.author = 'James Westby <*****@*****.**>' c.date = 'The, 3 Aug 2006 19:16:22 +0100' c.add_change('') c.add_change(' * test build') c.add_change('') return c
def manage_current_distribution(self, distrib): """manage debian files depending of the current distrib from options We copy debian_dir directory into tmp build depending of the target distribution in all cases, we copy the debian directory of the default version (unstable) If a file should not be included, touch an empty file in the overlay directory. This is specific to Logilab (debian directory is in project directory) """ try: # don't forget the final slash! export(osp.join(self.config.pkg_dir, 'debian'), osp.join(self.origpath, 'debian/'), verbose=(self.config.verbose == 2)) except IOError as err: raise LGPException(err) debian_dir = self.get_debian_dir(distrib) if debian_dir != "debian": self.logger.info("overriding files from '%s' directory..." % debian_dir) # don't forget the final slash! export(osp.join(self.config.pkg_dir, debian_dir), osp.join(self.origpath, 'debian/'), verbose=self.config.verbose) from debian.changelog import Changelog debchangelog = osp.join(self.origpath, 'debian', 'changelog') changelog = Changelog(open(debchangelog)) # substitute distribution string in changelog if distrib: # squeeze python-debian doesn't handle unicode well, see Debian bug#561805 changelog.distributions = str(distrib) # append suffix string (or timestamp if suffix is empty) to debian revision if self.config.suffix is not None: suffix = self.config.suffix or '+%s' % int(time.time()) self.logger.debug("suffix '%s' added to package version" % suffix) changelog.version = str(changelog.version) + suffix changelog.write_to_open_file(open(debchangelog, 'w')) return self.origpath
def update_changelog(repo, series, version): # Update d/changelog. with ExitStack() as resources: debian_changelog = os.path.join(repo.working_dir, 'debian', 'changelog') infp = resources.enter_context( open(debian_changelog, 'r', encoding='utf-8')) outfp = resources.enter_context(atomic(debian_changelog)) changelog = Changelog(infp) changelog.distributions = series series_version = { 'groovy': '20.10', 'focal': '20.04', 'bionic': '18.04', 'xenial': '16.04', }[series] new_version = '{}+{}ubuntu1'.format(version, series_version) changelog.version = new_version changelog.write_to_open_file(outfp) return new_version