def generate_debian_release_version(self): """ Generate the release version according to changelog The release version is the latest version of debian/changelog return: release version """ # If the repository has the debianstatic/repository name/, # create a soft link to debian before compute version debian_exist = self.debian_exist() linked = False if not debian_exist: for filename in os.listdir(self._repo_dir): if filename == "debianstatic": debianstatic_dir = os.path.join(self._repo_dir, "debianstatic") for debianstatic_filename in os.listdir(debianstatic_dir): if debianstatic_filename == self._repo_name: debianstatic_repo_dir = "debianstatic/{0}".format( self._repo_name) common.link_dir(debianstatic_repo_dir, "debian", self._repo_dir) linked = True if not debian_exist and not linked: return None cmd_args = ["dpkg-parsechangelog", "--show-field", "Version"] version = common.run_command(cmd_args, directory=self._repo_dir) if linked: os.remove(os.path.join(self._repo_dir, "debian")) return version
def generate_big_version(self): """ Generate the big version according to changelog The big version is the latest version of debian/changelog return: big version """ # If the repository has the debianstatic/repository name/, # create a soft link to debian before compute version debian_exist = self.debian_exist() linked = False if not debian_exist: for filename in os.listdir(self._repo_dir): if filename == "debianstatic": debianstatic_dir = os.path.join(self._repo_dir, "debianstatic") for debianstatic_filename in os.listdir(debianstatic_dir): if debianstatic_filename == self._repo_name: debianstatic_repo_dir = "debianstatic/{0}".format(self._repo_name) common.link_dir(debianstatic_repo_dir, "debian", self._repo_dir) linked = True if not debian_exist and not linked: return None cmd_args = ["dpkg-parsechangelog", "--show-field", "Version"] version = common.run_command(cmd_args, directory=self._repo_dir) if linked: os.remove(os.path.join(self._repo_dir, "debian")) return version
def link_debianstatic(self): """ Handle repository which contains debianstatic/repository_name folder. Create a soft link of debianstatic/repository_name to debian for example: ln -s debianstatic/on-http debian """ repo_name = self.get_repo_name() linked = False for dir_name in os.listdir(self._repo_dir): if dir_name == "debianstatic": debianstatic_dir = os.path.join(self._repo_dir, "debianstatic") for debianstatic_dir_name in os.listdir(debianstatic_dir): if debianstatic_dir_name == repo_name: debianstatic_repo_dir = "debianstatic/{0}".format(repo_name) common.link_dir(debianstatic_repo_dir, "debian", self._repo_dir) linked = True return linked
def update_changelog(self, message=None): """ add an entry to changelog :param message: the message which is going to be added to changelog return: Ture if changelog is updated False, otherwise """ repo_name = self.get_repo_name() debian_exist = self.debian_exist() linked = False if not debian_exist: # Handle repository which contains debianstatic/repository_name folder, # for example: debianstatic/on-http for filename in os.listdir(self._repo_dir): if filename == "debianstatic": debianstatic_dir = os.path.join(self._repo_dir, "debianstatic") for debianstatic_filename in os.listdir(debianstatic_dir): if debianstatic_filename == repo_name: debianstatic_repo_dir = "debianstatic/{0}".format(repo_name) common.link_dir(debianstatic_repo_dir, "debian", self._repo_dir) linked = True if not debian_exist and not linked: return False print "start to update changelog of {0}".format(self._repo_dir) # -v: Add a new changelog entry with version number specified # -b: Force a version to be less than the current one # -m: Don't change (maintain) the trailer line in the changelog entry; i.e. # maintain the maintainer and date/time details try: cmd_args = ["dch", "-v", self._version, "-b", "-m"] if message is None: message = "new release {0}".format(self._version) cmd_args += ["-p", message] common.run_command(cmd_args, directory=self._repo_dir) if linked: os.remove(os.path.join(self._repo_dir, "debian")) return True except Exception, err: raise RuntimeError("Failed to add an entry for {0} in debian/changelog due to {1}".format(self._version, err))