def _tag_release(self): """ Tag a new release of the package, add specfile global named commit. (ie: x.y.z-r+1) and ldflags from hack/common.sh os::build::ldflags """ self._make_changelog() new_version = self._bump_version() new_version = re.sub(r"-.*", "", new_version) git_hash = get_latest_commit() update_commit = \ "sed -i 's/^%%global commit .*$/%%global commit {0}/' {1}".format( git_hash, self.spec_file ) output = run_command(update_commit) cmd = '. ./hack/common.sh ; echo $(os::build::ldflags)' ldflags = run_command('bash -c \'{0}\''.format(cmd)) # hack/common.sh will tell us that the tree is dirty because tito has # already mucked with things, but lets not consider the tree to be # dirty ldflags = ldflags.replace('-dirty', '') update_ldflags = \ "sed -i 's|^%%global ldflags .*$|%%global ldflags {0}|' {1}".format( ldflags, self.spec_file ) # FIXME - this output is never used output = run_command(update_ldflags) self._check_tag_does_not_exist(self._get_new_tag(new_version)) self._update_changelog(new_version) self._update_package_metadata(new_version)
def _tag_release(self): """ Tag a new release of the package, add specfile global named commit. (ie: x.y.z-r+1) and ldflags from hack/common.sh os::build::ldflags """ self._make_changelog() new_version = self._bump_version() new_version = re.sub(r"-.*", "", new_version) git_hash = get_latest_commit() update_commit = \ "sed -i 's/^%global commit .*$/%global commit {0}/' {1}".format( git_hash, self.spec_file ) output = run_command(update_commit) cmd = '. ./hack/common.sh ; echo $(os::build::ldflags)' ldflags = run_command('bash -c \'{0}\''.format(cmd)) # hack/common.sh will tell us that the tree is dirty because tito has # already mucked with things, but lets not consider the tree to be # dirty ldflags = ldflags.replace('-dirty', '') update_ldflags = \ "sed -i 's|^%global ldflags .*$|%global ldflags {0}|' {1}".format( ldflags, self.spec_file ) # FIXME - this output is never used output = run_command(update_ldflags) self._check_tag_does_not_exist(self._get_new_tag(new_version)) self._update_changelog(new_version) self._update_package_metadata(new_version)
def _get_rpmbuild_dir_options(self): git_hash = get_latest_commit() return ( '--define "_topdir %s" --define "_sourcedir %s" --define "_builddir %s" --define ' '"_srcrpmdir %s" --define "_rpmdir %s" --define "commit %s" ' % (self.rpmbuild_dir, self.rpmbuild_sourcedir, self.rpmbuild_builddir, self.rpmbuild_basedir, self.rpmbuild_basedir, git_hash))
def _get_rpmbuild_dir_options(self): git_hash = get_latest_commit() return ('--define "_topdir %s" --define "_sourcedir %s" --define "_builddir %s" --define ' '"_srcrpmdir %s" --define "_rpmdir %s" --define "commit %s" ' % ( self.rpmbuild_dir, self.rpmbuild_sourcedir, self.rpmbuild_builddir, self.rpmbuild_basedir, self.rpmbuild_basedir, git_hash))
def _get_rpmbuild_dir_options(self): git_hash = get_latest_commit() cmd = '. ./hack/common.sh ; echo $(os::build::ldflags)' ldflags = run_command('bash -c \'%s\'' % (cmd)) return ( '--define "_topdir %s" --define "_sourcedir %s" --define "_builddir %s" ' '--define "_srcrpmdir %s" --define "_rpmdir %s" --define "ldflags %s" ' '--define "commit %s" ' % (self.rpmbuild_dir, self.rpmbuild_sourcedir, self.rpmbuild_builddir, self.rpmbuild_basedir, self.rpmbuild_basedir, ldflags, git_hash))
def _get_rpmbuild_dir_options(self): git_hash = get_latest_commit() cmd = '. ./hack/common.sh ; OS_ROOT=$(pwd) ; echo $(os::build::ldflags)' ldflags = run_command("bash -c '{0}'".format(cmd)) return ('--define "_topdir %s" --define "_sourcedir %s" --define "_builddir %s" ' '--define "_srcrpmdir %s" --define "_rpmdir %s" --define "ldflags %s" ' '--define "commit %s" ' % ( self.rpmbuild_dir, self.rpmbuild_sourcedir, self.rpmbuild_builddir, self.rpmbuild_basedir, self.rpmbuild_basedir, ldflags, git_hash))
def _get_rpmbuild_dir_options(self): git_hash = get_latest_commit() cmd = 'source ./hack/lib/init.sh; os::build::ldflags' ldflags = run_command("bash -c '{0}'".format(cmd)) return ( '--define "_topdir %s" --define "_sourcedir %s" --define "_builddir %s" ' '--define "_srcrpmdir %s" --define "_rpmdir %s" --define "ldflags %s" ' '--define "commit %s" ' % (self.rpmbuild_dir, self.rpmbuild_sourcedir, self.rpmbuild_builddir, self.rpmbuild_basedir, self.rpmbuild_basedir, ldflags, git_hash))
def _get_rpmbuild_dir_options(self): git_hash = get_latest_commit() cmd = 'source ./hack/lib/init.sh; os::build::ldflags' ldflags = run_command("bash -c '{0}'".format(cmd)) return ('--define "_topdir %s" --define "_sourcedir %s" --define "_builddir %s" ' '--define "_srcrpmdir %s" --define "_rpmdir %s" --define "ldflags %s" ' '--define "commit %s" ' % ( self.rpmbuild_dir, self.rpmbuild_sourcedir, self.rpmbuild_builddir, self.rpmbuild_basedir, self.rpmbuild_basedir, ldflags, git_hash))
def _tag_release(self): """ Tag a new release of the package, add specfile global named commit. (ie: x.y.z-r+1) """ self._make_changelog() new_version = self._bump_version(release=True) git_hash = get_latest_commit() update_commit = "sed -i 's/^%%global commit .*$/%%global commit %s/' %s" % \ (git_hash, self.spec_file) output = run_command(update_commit) self._check_tag_does_not_exist(self._get_new_tag(new_version)) self._update_changelog(new_version) self._update_package_metadata(new_version)
def update_global_hash(spec_file): """ Update the specfile to reflect the latest commit. A line with the following syntax is expected in the specfile: %global commit This line will be overwritten to add the git commit. """ git_hash = get_latest_commit() update_commit = \ "sed -i 's/^%global commit .*$/%global commit {0}/' {1}".format( git_hash, spec_file ) run_command(update_commit)
def _get_display_version(self): """ Get the package display version to build. Normally this is whatever is .tito/packages/. In the case of a --test build it will be the SHA1 for the HEAD commit of the current git branch. """ if self.test: # should get latest commit for given directory *NOT* HEAD latest_commit = get_latest_commit(".") self.commit_count = get_commit_count(self.build_tag, latest_commit) version = "git-%s.%s" % (self.commit_count, latest_commit[:7]) else: version = self.build_version.split("-")[0] return version
def _tag_release(self): """ Tag a new release of the package, add specfile global named commit. (ie: x.y.z-r+1) and ldflags from hack/common.sh os::build::ldflags """ self._make_changelog() new_version = self._bump_version() new_version = re.sub(r"-.*", "", new_version) git_hash = get_latest_commit() update_commit = \ "sed -i 's/^%global commit .*$/%global commit {0}/' {1}".format( git_hash, self.spec_file ) output = run_command(update_commit) ## Fixup os_git_vars cmd = '. ./hack/common.sh ; OS_ROOT=$(pwd) ; os::build::os_version_vars ; echo ${OS_GIT_COMMIT}' os_git_commit = run_command("bash -c '{0}'".format(cmd)) cmd = '. ./hack/common.sh ; OS_ROOT=$(pwd) ; os::build::os_version_vars ; echo ${OS_GIT_VERSION}' os_git_version = run_command("bash -c '{0}'".format(cmd)) os_git_version = os_git_version.replace('-dirty', '') cmd = '. ./hack/common.sh ; OS_ROOT=$(pwd) ; os::build::os_version_vars ; echo ${OS_GIT_MAJOR}' os_git_major = run_command("bash -c '{0}'".format(cmd)) cmd = '. ./hack/common.sh ; OS_ROOT=$(pwd) ; os::build::os_version_vars ; echo ${OS_GIT_MINOR}' os_git_minor = run_command("bash -c '{0}'".format(cmd)) print("OS_GIT_COMMIT::{0}".format(os_git_commit)) print("OS_GIT_VERSION::{0}".format(os_git_version)) print("OS_GIT_MAJOR::{0}".format(os_git_major)) print("OS_GIT_MINOR::{0}".format(os_git_minor)) update_os_git_vars = \ "sed -i 's|^%global os_git_vars .*$|%global os_git_vars OS_GIT_TREE_STATE='clean' OS_GIT_VERSION={0} OS_GIT_COMMIT={1} OS_GIT_MAJOR={2} OS_GIT_MINOR={3}|' {4}".format( os_git_version, os_git_commit, os_git_major, os_git_minor, self.spec_file ) output = run_command(update_os_git_vars) self._check_tag_does_not_exist(self._get_new_tag(new_version)) self._update_changelog(new_version) self._update_package_metadata(new_version)
def _tag_release(self): """ Tag a new release of the package, add specfile global named commit. (ie: x.y.z-r+1) and ldflags from hack/common.sh os::build::ldflags """ self._make_changelog() new_version = self._bump_version(release=True) git_hash = get_latest_commit() update_commit = "sed -i 's/^%%global commit .*$/%%global commit %s/' %s" % \ (git_hash, self.spec_file) output = run_command(update_commit) cmd = '. ./hack/common.sh ; echo $(os::build::ldflags)' ldflags = run_command('bash -c \'%s\'' % (cmd)) update_ldflags = "sed -i 's|^%%global ldflags .*$|%%global ldflags %s|' %s" % \ (ldflags, self.spec_file) output = run_command(update_ldflags) self._check_tag_does_not_exist(self._get_new_tag(new_version)) self._update_changelog(new_version) self._update_package_metadata(new_version)