summaryrefslogtreecommitdiff
path: root/buildscripts/packager.py
diff options
context:
space:
mode:
authorRamon Fernandez <ramon@mongodb.com>2017-04-03 11:42:31 -0400
committerRamon Fernandez <ramon@mongodb.com>2017-04-03 11:42:31 -0400
commit6b58cac1fb36b328fa9d1be8b9e67d4355744a12 (patch)
tree1ace6c31385e0069109fbca610aee0f0a73111d6 /buildscripts/packager.py
parentabeacd95726365e00f35d00f4cb348c703224042 (diff)
downloadmongo-6b58cac1fb36b328fa9d1be8b9e67d4355744a12.tar.gz
SERVER-28484 Remove timestamp from Linux package versions and filenames
This changes the package names for commit-triggered builds to match the following format: - rpm: mongodb-org-server-3.4.3-0.1.latest.el6.x86_64.rpm - deb: mongodb-org-unstable-shell_3.5.5~latest_amd64.deb Patch builds packages are also changed to eliminate the NN-g<hash> part of the version (as produced by git-describe): - rpm: mongodb-org-server-3.4.3-0.1.patch.deadbeef1234.el6.x86_64.rpm - deb: mongodb-org-unstable-server_3.5.5~patch~deadbeef1234_amd64.deb Packages for release candidates and releases are not changed.
Diffstat (limited to 'buildscripts/packager.py')
-rwxr-xr-xbuildscripts/packager.py66
1 files changed, 49 insertions, 17 deletions
diff --git a/buildscripts/packager.py b/buildscripts/packager.py
index 933e0612323..80b0a3af6a1 100755
--- a/buildscripts/packager.py
+++ b/buildscripts/packager.py
@@ -50,11 +50,15 @@ class Spec(object):
self.gitspec = gitspec
self.rel = rel
- # Nightly version numbers can be in the form: 3.0.7-pre-, or 3.0.7-5-g3b67ac
+ # Commit-triggerd version numbers can be in the form: 3.0.7-pre-, or 3.0.7-5-g3b67ac
+ # Patch builds version numbers are in the form: 3.5.5-64-g03945fa-patch-58debcdb3ff1223c9d00005b
#
def is_nightly(self):
return bool(re.search("-$", self.version())) or bool(re.search("\d-\d+-g[0-9a-f]+$", self.version()))
+ def is_patch(self):
+ return bool(re.search("\d-\d+-g[0-9a-f]+-patch-[0-9a-f]+$", self.version()))
+
def is_rc(self):
return bool(re.search("-rc\d+$", self.version()))
@@ -64,6 +68,12 @@ class Spec(object):
def version(self):
return self.ver
+ def patch_id(self):
+ if self.is_patch():
+ return re.sub(r'.*-([0-9a-f]+$)', r'\1', self.version())
+ else:
+ return "none"
+
def metadata_gitspec(self):
"""Git revision to use for spec+control+init+manpage files.
The default is the release tag for the version being packaged."""
@@ -81,35 +91,57 @@ class Spec(object):
return "-org" if int(self.ver.split(".")[1])%2==0 else "-org-unstable"
def prelease(self):
- # "N" is either passed in on the command line, or "1"
+ # NOTE: This is only called for RPM packages, and only after
+ # pversion() below has been called. If you want to change this format
+ # and want DEB packages to match, make sure to update pversion()
+ # below
#
- # 1) Standard release - "N"
- # 2) Nightly (snapshot) - "0.N.YYYYMMDDlatest"
- # 3) RC's - "0.N.rcX"
+ # "N" is either passed in on the command line, or "1"
if self.rel:
- corenum = self.rel
+ corenum = self.rel
else:
- corenum = 1
- # RC's
+ corenum = 1
+
+ # Version suffix for RPM packages:
+ # 1) RC's - "0.N.rcX"
+ # 2) Nightly (snapshot) - "0.N.latest"
+ # 3) Patch builds - "0.N.patch.<patch_id>"
+ # 4) Standard release - "N"
if self.is_rc():
- return "0.%s.%s" % (corenum, re.sub('.*-','',self.version()))
- # Nightlies
+ return "0.%s.%s" % (corenum, re.sub('.*-','',self.version()))
elif self.is_nightly():
- return "0.%s.%s" % (corenum, time.strftime("%Y%m%d"))
+ return "0.%s.latest" % (corenum)
+ elif self.is_patch():
+ return "0.%s.patch.%s" % (corenum, self.patch_id())
else:
- return str(corenum)
+ return str(corenum)
def pversion(self, distro):
# Note: Debian packages have funny rules about dashes in
# version numbers, and RPM simply forbids dashes. pversion
# will be the package's version number (but we need to know
# our upstream version too).
+
+ # For RPM packages this just returns X.Y.X because of the
+ # aforementioned rules, and prelease (above) adds a suffix later,
+ # so detect this case early
+ if re.search("(suse|redhat|fedora|centos|amazon)", distro.name()):
+ return re.sub("-.*", "", self.version())
+
+ # For DEB packages, this code sets the full version. If you change
+ # this format and want RPM packages to match make sure you change
+ # prelease above as well
if re.search("^(debian|ubuntu)", distro.name()):
- return re.sub("-", "~", self.ver)
- elif re.search("(suse|redhat|fedora|centos|amazon)", distro.name()):
- return re.sub("-.*", "", self.ver)
- else:
- raise Exception("BUG: unsupported platform?")
+ if self.is_nightly():
+ ver = re.sub("-.*", "-latest", self.ver)
+ elif self.is_patch():
+ ver = re.sub("-.*", "", self.ver) + "-patch-" + self.patch_id()
+ else:
+ ver = self.ver
+
+ return re.sub("-", "~", ver)
+
+ raise Exception("BUG: unsupported platform?")
def branch(self):
"""Return the major and minor portions of the specified version.