aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNicholas Corgan <nick.corgan@ettus.com>2015-12-30 10:20:14 -0800
committerMartin Braun <martin.braun@ettus.com>2015-12-30 11:22:49 -0800
commitd956bb6668553694eb610ef89313e4a4b6bb0f72 (patch)
treefde6f463b0cc00be4c46d7caf24107419ae98918 /tools
parent5993ee4a4d19a41ffe40dc1a17726d52f0b8b6d0 (diff)
downloaduhd-d956bb6668553694eb610ef89313e4a4b6bb0f72.tar.gz
uhd-d956bb6668553694eb610ef89313e4a4b6bb0f72.tar.bz2
uhd-d956bb6668553694eb610ef89313e4a4b6bb0f72.zip
Added scripts and Debian configuration files for Ubuntu PPA
Diffstat (limited to 'tools')
-rwxr-xr-xtools/debs/convert_changelog.py108
-rwxr-xr-xtools/debs/upload_debs.sh127
2 files changed, 235 insertions, 0 deletions
diff --git a/tools/debs/convert_changelog.py b/tools/debs/convert_changelog.py
new file mode 100755
index 000000000..5d12a958c
--- /dev/null
+++ b/tools/debs/convert_changelog.py
@@ -0,0 +1,108 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright 2015 National Instruments Corp.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+"""
+Converts our changelog into a format suitable for Debian packaging
+"""
+
+import datetime
+from optparse import OptionParser
+import os
+import re
+import sys
+
+# Pass in first line of Debian changelog file, should contain last version
+def detect_last_version(line):
+ return convert_version_string(re.search("[0-9]+\.[0-9]+\.[0-9]", line).group(), False)
+
+# "## 003.008.005" to "3.8.5" or vice versa
+def convert_version_string(version, to_debian=True):
+ if version == None:
+ return ""
+
+ if to_debian:
+ return ".".join(list(str(int(num)) for num in re.split('[ .]', version)[1:]))
+ else:
+ return "## {0}".format(".".join("{0:03d}".format(int(num)) for num in version.split(".")))
+
+#
+# The "trusty" string below doesn't need to be changed, even when Trusty loses support. The script
+# to upload packages replaces it anyway.
+#
+def get_header(version):
+ return "uhd ({0}-0ubuntu1) trusty; urgency=low\n\n".format(convert_version_string(version))
+
+def get_footer(uploader_name, uploader_email):
+ return " -- {0} <{1}> {2}\n\n".format(uploader_name, uploader_email, datetime.datetime.now().strftime("%a, %d %b %Y %I:%M:%S %Z-0800"))
+
+if __name__ == "__main__":
+
+ parser = OptionParser()
+ parser.add_option("--input-file", type="string", help="Input UHD top-level changelog file")
+ parser.add_option("--output-file", type="string", help="Output Debian changelog file (will append onto existing)")
+ parser.add_option("--uploader-name", type="string", help="Uploader name (must match GPG key)")
+ parser.add_option("--uploader-email", type="string", help="Uploader email (must match GPG key)")
+ parser.add_option("--last-version", type="string", help="Manually specify last version (Debian format)", default="")
+ (options, args) = parser.parse_args()
+
+ # Input file
+ f = open(options.input_file, "r")
+ lines_in = f.readlines()
+ f.close()
+
+ # Output file
+ if os.path.exists(os.path.normpath(options.output_file)):
+ g = open(options.output_file, "r")
+ lines_out = g.readlines()
+ g.close()
+ else:
+ lines_out = []
+
+ g = open(options.output_file, "w")
+
+ if options.last_version == "":
+ if(len(lines_out) > 0):
+ last_version = detect_last_version(lines_out[0])
+ check_last_version = True
+ else:
+ last_version = ""
+ check_last_version = False # Will do every version
+ else:
+ last_version = convert_version_string(options.last_version, False)
+ check_last_version = True
+
+ new_lines_out = []
+ for line in lines_in[3:]:
+ if line.rstrip() == last_version and last_version != "":
+ # We've fully updated, stop here
+ break
+ elif re.search("^## [0-9]{3}\.[0-9]{3}\.[0-9]{3}", line):
+ # New version
+ new_lines_out += [get_header(line.rstrip())]
+ elif line == "\n":
+ # End of version
+ new_lines_out += ["\n"]
+ new_lines_out += [get_footer(options.uploader_name, options.uploader_email)]
+ else:
+ # Actual changes
+ new_lines_out += [" " + line]
+
+ new_lines_out += lines_out
+ for line in new_lines_out:
+ g.write(line)
+ g.close()
diff --git a/tools/debs/upload_debs.sh b/tools/debs/upload_debs.sh
new file mode 100755
index 000000000..4ff03cced
--- /dev/null
+++ b/tools/debs/upload_debs.sh
@@ -0,0 +1,127 @@
+#!/bin/bash
+#
+# Copyright 2015 National Instruments Corp.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+if ! ls | grep host > /dev/null
+then
+ echo "This script must be run from UHD's top-level directory."
+ exit 1
+fi
+
+FORCE_YES=0
+if [ $# -eq 1 ]
+then
+ if [ "$1" = "-y" ]
+ then
+ FORCE_YES=1
+ fi
+fi
+
+UHD_TOP_LEVEL=$PWD
+
+# Get version info
+VERSION=`head -1 host/cmake/debian/changelog | grep -o '[0-9.]*' | head -1`
+ORIG_RELEASE=`head -1 host/cmake/debian/changelog | sed 's/.*) \(.*\);.*/\1/'`
+
+#
+# Currently supported versions can be found here:
+# https://launchpad.net/ubuntu/+ppas
+#
+RELEASES="precise trusty vivid wily xenial"
+PPA=ppa:ettusresearch/uhd
+
+#
+# Make sure this is the intended version.
+#
+# This is based on the contents of debian/changelog. If convert_changelog.py was not
+# run on this version, it will show the previous release.
+#
+echo "Will generate installer configuration files for UHD "$VERSION
+if [ $FORCE_YES -ne 1 ]
+then
+ echo "Is this correct? (yes/no)"
+ read response
+ if [ "$response" != "yes" ]
+ then
+ exit 0
+ fi
+fi
+
+# Generate the TAR file to be uploaded.
+echo "Creating UHD source archive."
+tar --exclude='*git*' --exclude='./debian' --exclude='*.swp' -cJf ../uhd_${VERSION}.orig.tar.xz .
+if [ $? != 0 ]
+then
+ echo "Failed to create UHD source archive."
+ exit 1
+fi
+
+# debuild expects our directory name to be ${source package}-${version}
+cd ..
+ln -fs ${UHD_TOP_LEVEL} uhd-${VERSION}
+cd uhd-${VERSION}
+
+#
+# Generate package info for each version.
+#
+# This script substitutes each version string into the debian/changelog file to
+# create package info for each version. We need to store the original outside the
+# UHD repo, or dpkg-source will detect the change and error out.
+#
+cp -r host/cmake/debian .
+cp host/utils/uhd-usrp.rules debian/uhd-host.udev
+find host/docs -name '*.1' > debian/uhd-host.manpages
+rm -f debian/postinst.in debian/postrm.in debian/preinst.in debian/prerm.in
+exit 0
+
+for RELEASE in ${RELEASES}
+do
+ cp debian/changelog ../changelog.backup
+ sed -i "s/${ORIG_RELEASE}/${RELEASE}/;s/0ubuntu1/0ubuntu1~${RELEASE}1/" debian/changelog
+ debuild -S -i -sa
+ if [ $? != 0 ]
+ then
+ echo "Failed to generate package info for" ${RELEASE}
+ mv changelog.backup debian/changelog
+ exit 1
+ fi
+ mv ../changelog.backup debian/changelog
+done
+
+# Upload package into to Launchpad, which will automatically build packages
+for RELEASE in ${RELEASES}
+do
+ continue
+ dput ${PPA} ../uhd_${VERSION}-0ubuntu1~${RELEASE}1_source.changes
+ if [ $? != 0 ]
+ then
+ echo "Failed to upload" ${VERSION} "package info to Launchpad."
+ exit 1
+ fi
+done
+
+if [ $FORCE_YES -ne 1 ]
+then
+ echo
+ echo "Clean up build artifacts? (yes/no)"
+ read response
+ if [ "$response" = "yes" ]
+ then
+ cd ..
+ rm -r ${UHD_TOP_LEVEL}/debian uhd-${VERSION} uhd_${VERSION}.orig.tar.xz uhd*dsc uhd*changes uhd*debian.tar.gz uhd*_source.build uhd*.upload
+ fi
+fi