aboutsummaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/build-debian-packages.py31
-rw-r--r--buildtools/make-version.py104
2 files changed, 64 insertions, 71 deletions
diff --git a/buildtools/build-debian-packages.py b/buildtools/build-debian-packages.py
index c2d30280..16c3091d 100644
--- a/buildtools/build-debian-packages.py
+++ b/buildtools/build-debian-packages.py
@@ -1,5 +1,3 @@
-# $Id$
-#
# Copyright (C) 2015--2016 Parsons Government Services ("PARSONS")
# Portions copyright (C) 2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2013 Internet Systems Consortium ("ISC")
@@ -40,35 +38,20 @@ parser.add_argument("-s", "--version-suffix", nargs = "?", const = platform.linu
help = "suffix to add to version string")
args = parser.parse_args()
-if os.path.exists(".svn"):
- version = "0.{rev}".format(
- rev = subprocess.check_output(("svnversion", "-c")).strip().split(":")[-1])
-elif os.path.exists(".git/svn"):
- git_svn_log = subprocess.check_output(("git", "svn", "log", "--show-commit", "--oneline", "--limit=1")).split()
- version = "0.{rev}.{count}.{time}.{commit}".format(
- rev = git_svn_log[0][1:],
- count = subprocess.check_output(("git", "rev-list", "--count", git_svn_log[2] + "..HEAD")).strip(),
- time = subprocess.check_output(("git", "show", "--no-patch", "--format=%ct", "HEAD")).strip(),
- commit = subprocess.check_output(("git", "rev-parse", "HEAD")).strip())
- del git_svn_log
-elif os.path.exists(".git"):
- # Ideally we'd use something like "git describe --dirty --tags --always" but I don't want to deal with that
- # generating something that won't parse as a package number. Using a timestamp is icky, but also simple.
- version = "0.{}".format(subprocess.check_output(("git", "show", "--no-patch", "--format=%ct", "HEAD")).strip())
-else:
- sys.exit("Sorry, don't know how to extract version number from this source tree")
+version = subprocess.check_output((sys.executable, os.path.join(os.path.dirname(sys.argv[0]), "make-version.py"), "--stdout")).strip()
if os.path.exists("debian"):
shutil.rmtree("debian")
-def ignore_dot_svn(src, names):
- return [name for name in names if name == ".svn"]
-
-shutil.copytree("buildtools/debian-skeleton", "debian", ignore = ignore_dot_svn)
+shutil.copytree("buildtools/debian-skeleton", "debian")
os.chmod("debian/rules", 0755)
-msg = "Version %s of https://subvert-rpki.hactrn.net/trunk/" % version
+msg = "Version {} of RPKI toolkit".format(version)
+
+assert version.startswith("buildbot-")
+
+version = version[len("buildbot-"):].replace("-", ".")
if args.version_suffix:
version += "~" + args.version_suffix
diff --git a/buildtools/make-version.py b/buildtools/make-version.py
index 09d43801..451809e7 100644
--- a/buildtools/make-version.py
+++ b/buildtools/make-version.py
@@ -1,69 +1,79 @@
#!/usr/bin/env python
-# $Id$
-# Copyright (C) 2013 Internet Systems Consortium ("ISC")
+# Copyright (C) 2016 Parsons Government Services ("PARSONS")
+# Portions copyright (C) 2013 Internet Systems Consortium ("ISC")
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
+# copyright notices and this permission notice appear in all copies.
#
-# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-# PERFORMANCE OF THIS SOFTWARE.
+# THE SOFTWARE IS PROVIDED "AS IS" AND PARSONS AND ISC DISCLAIM
+# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# PARSONS OR ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-# Kludge to extract Subversion revision number from environment at
-# build time, if possible, using it to construct the software version
-# number that one of our users so desperately wants us to have. This
-# is a bit tricky because we want this to be automatic (hence use of
-# Subversion revision number, which isn't really intended for this
-# purpose), want it to work whether installing from binary package or
-# subversion checkout or frozen tarball, and need to be careful both
-# to update it whenever the revision changes and not to stomp on it
-# when the subversion revision number isn't available.
-#
-# I did say this was a kludge.
-
-# One could argue that we should be throwing a fatal error when we
-# can't determine the version, rather than just issuing a warning and
-# writing a version of "Unknown". Maybe later.
+"""
+Kludge to extract revision information from environment at build
+time, if possible, using it to construct the software version number
+that one of our users so desperately wants us to have. This is a
+bit tricky because we want this to be automatic, want it to work
+whether installing from binary package or git checkout or frozen
+tarball, and need to be careful both to update it whenever the
+revision changes and not to stomp on it when the git revision
+information isn't available.
+"""
import subprocess
+import argparse
+import time
import sys
-unknown = "Unknown"
+parser = argparse.ArgumentParser(description = __doc__)
+parser.add_argument("--stdout", action = "store_true", help = "write version information to stdout")
-try:
- v = subprocess.Popen(("svnversion", "-c"), stdout = subprocess.PIPE).communicate()[0]
- err = None
-except Exception, e:
- v = unknown
- err = e
+# The next two are only for use by other build scripts. Using these directly will
+# likely result in version numbering that diverges from the semi-official packaged
+# binaries, which is unlikely to be what you want. Because of this, we suppress all
+# mention of these options from the --help output.
+
+parser.add_argument("--build-tag", action = "store_true", help = argparse.SUPPRESS)
+parser.add_argument("--major-version", default = "1.0", help = argparse.SUPPRESS)
-if any(s in v for s in ("Unversioned", "Uncommitted", unknown)):
- v = unknown
-else:
- v = "0." + v.strip().split(":")[-1].translate(None, "SMP")
+args = parser.parse_args()
+
+if args.build_tag:
+ try:
+ subprocess.check_call(("git", "describe", "--match", "buildbot-*", "--exact"),
+ stdout = open("/dev/null", "w"), stderr = subprocess.STDOUT)
+ except subprocess.CalledProcessError:
+ subprocess.check_call(("git", "tag", "-a", "-m", "Build robot",
+ "buildbot-{}.{}".format(args.major_version, int(time.time()))))
+
+try:
+ ver = subprocess.check_output(("git", "describe", "--match", "buildbot-*", "--dirty"), stderr = open("/dev/null", "w")).strip()
+except subprocess.CalledProcessError:
+ ver = None
try:
old = open("VERSION", "r").read().strip()
-except:
+except IOError:
old = None
-if err is not None and (old is None or old == unknown):
- sys.stderr.write("Warning: No saved version and svnversion failed: %s\n" % err)
+if ver is None:
+ ver = old
-if v == unknown:
- if old is not None and old != unknown:
- v = old
- else:
- sys.stderr.write("Warning: Could not determine software version\n")
+if ver is None and old is None:
+ sys.exit("Could not determine software version")
-if old is None or v != old:
+if ver != old:
with open("rpki/version.py", "w") as f:
- f.write("VERSION = \"%s\"\n" % v)
+ f.write("VERSION = \"{}\"\n".format(ver))
with open("VERSION", "w") as f:
- f.write(v + "\n")
+ f.write("{}\n".format(ver))
+
+if args.stdout:
+ sys.stdout.write("{}\n".format(ver))