diff options
-rw-r--r-- | buildtools/build-freebsd-ca-port.py (renamed from buildtools/build-freebsd-port.py) | 0 | ||||
-rw-r--r-- | buildtools/build-freebsd-rp-port.py | 158 | ||||
-rwxr-xr-x | configure | 47 | ||||
-rw-r--r-- | configure.ac | 33 | ||||
-rw-r--r-- | rcynic/Makefile.in | 5 | ||||
-rw-r--r-- | rcynic/installation-scripts/deinstall.sh | 2 | ||||
-rw-r--r-- | setup.py | 16 |
7 files changed, 258 insertions, 3 deletions
diff --git a/buildtools/build-freebsd-port.py b/buildtools/build-freebsd-ca-port.py index 033bcc9b..033bcc9b 100644 --- a/buildtools/build-freebsd-port.py +++ b/buildtools/build-freebsd-ca-port.py diff --git a/buildtools/build-freebsd-rp-port.py b/buildtools/build-freebsd-rp-port.py new file mode 100644 index 00000000..140c67ae --- /dev/null +++ b/buildtools/build-freebsd-rp-port.py @@ -0,0 +1,158 @@ +""" +Construct a FreeBSD port template given the URL of a source tarball. + +$Id$ + +Copyright (C) 2012-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. + +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. +""" + +import sys +import os +import subprocess +import urlparse +import errno +import glob + +try: + url = sys.argv[1] +except IndexError: + sys.exit("Usage: %s URL-of-source-tarball" % sys.argv[0]) + +def stripext(fn, *exts): + fn1, fn2 = os.path.splitext(fn) + return fn1 if fn2 in exts else fn + +def mkdir_maybe(*args): + try: + print "Creating", args[0] + os.makedirs(*args) + except OSError, e: + if e.errno != errno.EEXIST: + raise + +name = os.path.basename(urlparse.urlparse(url).path) +name = stripext(name, ".gz", ".bz2", ".xz") +name = stripext(name, ".tar", ".tgz", ".tbz", ".txz") + +# Up until this point this is fairly generic, but we reach the point +# of diminishing returns when we have to parse the port name and +# version number out of the filename. This will need to be changed +# when we start doing this with something other than snapshot +# tarballs. + +try: + base, trunk, vers = name.split("-") +except: + base, trunk, vers = None + +if trunk != "trunk" or not vers.isdigit(): + sys.exit("Unexpected tarball URL name format") + +mkdir_maybe(base) + +# Just want relying party tools, and have to whack rcynic jail +# location to something acceptable to FreeBSD package system. + +configure_args = "--disable-ca-tools --with-rcynic-jail=/usr/local/var/rcynic" + +with open(os.path.join(base, "Makefile"), "w") as f: + print "Writing", f.name + + f.write('''\ +PORTNAME= %(portname)s-rp +PORTVERSION= 0.%(snapshot)s +CATEGORIES= net +MASTER_SITES= %(master_sites)s +DISTFILES= %(distfiles)s +WRKSRC= ${WRKDIR}/%(tarname)s + +MAINTAINER= sra@hactrn.net +COMMENT= rpki.net RPKI relying party tools + +GNU_CONFIGURE= yes +USE_PYTHON= 2.7+ +USE_GNOME= libxml2 libxslt + +# For OpenSSL, not needed otherwise +USE_PERL5_BUILD=yes + +# For OpenSSL, not needed otherwise +BUILD_DEPENDS+= makedepend>0:${PORTSDIR}/devel/makedepend + +# For rcynic-html +RUN_DEPENDS+= rrdtool>0:${PORTSDIR}/databases/rrdtool + +CONIGURE_ARGS= %(configure_args)s + +.include <bsd.port.mk> +''' % { "portname" : base, + "snapshot" : vers, + "tarname" : name, + "master_sites" : os.path.dirname(url) + "/", + "distfiles" : os.path.basename(url), + "configure_args": configure_args }) + +with open(os.path.join(base, "pkg-descr"), "w") as f: + print "Writing", f.name + + f.write('''\ +This is a port of the rpki.net RPKI toolkit relying party tools. + +WWW: http://rpki.net/ +''') + +with open(os.path.join(base, "pkg-plist"), "w") as f: + + print "Writing empty", f.name + +print "Generating checksum" + +subprocess.check_call(("make", "makesum", "DISTDIR=" + os.getcwd()), cwd = base) + +print "Extracting list of trust anchors" + +trust_anchors = ["var/rcynic/etc/trust-anchors/%s" % os.path.basename(fn) + for fn in subprocess.check_output(("tar", "tf", os.path.basename(url))).splitlines() + if "/rcynic/sample-trust-anchors/" in fn and fn.endswith(".tal")] + +with open(os.path.join(base, "pkg-plist"), "w") as f: + + print "Writing", f.name + + f.write('''\ +bin/find_roa +bin/hashdir +bin/print_roa +bin/print_rpki_manifest +bin/rtr-origin +bin/scan_roas +etc/rc.d/rcynic +var/rcynic/bin/rcynic +var/rcynic/bin/rcynic-html +var/rcynic/bin/rsync +''') + + for trust_anchor in trust_anchors: + f.write("%s\n" % trust_anchor) + + f.write('''\ +@dirrm var/rcynic/var +@dirrm var/rcynic/etc/trust-anchors +@dirrm var/rcynic/etc +@dirrm var/rcynic/dev +@dirrm var/rcynic/data +@dirrm var/rcynic/bin +@dirrm var/rcynic +''') @@ -629,6 +629,8 @@ OPENSSL_SO_GLOB OPENSSL_CONFIG_COMMAND TOP_LEVEL_SUBDIRS PYTHON +RCYNIC_JAIL_DIRECTORY +USE_RCYNIC_JAIL TRANG RRDTOOL SORT @@ -699,6 +701,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking with_system_openssl +with_rcynic_jail enable_openssl_asm enable_ca_tools enable_rpki_rtr @@ -1337,6 +1340,7 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-system-openssl Link against system copy of OpenSSL + --with-rcynic-jail Set location of rcynic jail directory Some influential environment variables: CC C compiler command @@ -2370,6 +2374,14 @@ else with_system_openssl=auto fi + +# Check whether --with-rcynic-jail was given. +if test "${with_rcynic_jail+set}" = set; then : + withval=$with_rcynic_jail; +else + with_rcynic_jail=auto +fi + # Check whether --enable-openssl_asm was given. if test "${enable_openssl_asm+set}" = set; then : enableval=$enable_openssl_asm; @@ -4240,6 +4252,41 @@ case $enable_openssl_asm in ;; esac +# Figure out where to put rcynic jail. In the long run I suspect we +# will want to use autoconf file substitution here to let us include +# different chunks of Makefile code depending on whether we're +# building a jail or not, but for today all I really care about is +# being able to set the jail directory so I can write a FreeBSD port. + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking where to put rcynic jail" >&5 +$as_echo_n "checking where to put rcynic jail... " >&6; } + +case $with_rcynic_jail in + yes|auto) + RCYNIC_JAIL_DIRECTORY=/var/rcynic + ;; + no) + RCYNIC_JAIL_DIRECTORY='' + ;; + *) + RCYNIC_JAIL_DIRECTORY="$with_rcynic_jail" + ;; +esac + +if test "X$RCYNIC_JAIL_DIRECTORY" = "X" +then + USE_RCYNIC_JAIL=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no rcynic jail" >&5 +$as_echo "no rcynic jail" >&6; } +else + USE_RCYNIC_JAIL=yes + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RCYNIC_JAIL_DIRECTORY" >&5 +$as_echo "$RCYNIC_JAIL_DIRECTORY" >&6; } +fi + + + + # Now a bunch of checks to figure out what we can do with Python. If # we don't have Python at all, none of the rest of this matters. If # we do have Python, we need to check for required packages and diff --git a/configure.ac b/configure.ac index 379ab6d6..27b55f67 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,7 @@ fi # Put the user option stuff up front. AC_ARG_WITH([system_openssl], [AS_HELP_STRING([--with-system-openssl], [Link against system copy of OpenSSL])], [], [with_system_openssl=auto]) +AC_ARG_WITH([rcynic-jail], [AS_HELP_STRING([--with-rcynic-jail], [Set location of rcynic jail directory])], [], [with_rcynic_jail=auto]) AC_ARG_ENABLE([openssl_asm], [AS_HELP_STRING([--disable-openssl-asm], [Don't let OpenSSL build assembler code])], [], [enable_openssl_asm=auto]) AC_ARG_ENABLE([ca_tools], [AS_HELP_STRING([--disable-ca-tools], [Don't build any of the CA tools])], [], [enable_ca_tools=yes]) AC_ARG_ENABLE([rpki_rtr], [AS_HELP_STRING([--disable-rpki-rtr], [Don't build the rpki-rtr code])], [], [enable_rpki_rtr=yes]) @@ -220,6 +221,38 @@ case $enable_openssl_asm in ;; esac +# Figure out where to put rcynic jail. In the long run I suspect we +# will want to use autoconf file substitution here to let us include +# different chunks of Makefile code depending on whether we're +# building a jail or not, but for today all I really care about is +# being able to set the jail directory so I can write a FreeBSD port. + +AC_MSG_CHECKING([where to put rcynic jail]) + +case $with_rcynic_jail in + yes|auto) + RCYNIC_JAIL_DIRECTORY=/var/rcynic + ;; + no) + RCYNIC_JAIL_DIRECTORY='' + ;; + *) + RCYNIC_JAIL_DIRECTORY="$with_rcynic_jail" + ;; +esac + +if test "X$RCYNIC_JAIL_DIRECTORY" = "X" +then + USE_RCYNIC_JAIL=no + AC_MSG_RESULT([no rcynic jail]) +else + USE_RCYNIC_JAIL=yes + AC_MSG_RESULT([$RCYNIC_JAIL_DIRECTORY]) +fi + +AC_SUBST(USE_RCYNIC_JAIL) +AC_SUBST(RCYNIC_JAIL_DIRECTORY) + # Now a bunch of checks to figure out what we can do with Python. If # we don't have Python at all, none of the rest of this matters. If # we do have Python, we need to check for required packages and diff --git a/rcynic/Makefile.in b/rcynic/Makefile.in index 777fe18f..12f3cfe7 100644 --- a/rcynic/Makefile.in +++ b/rcynic/Makefile.in @@ -24,6 +24,9 @@ abs_top_builddir = @abs_top_builddir@ host_os = @host_os@ +USE_RCYNIC_JAIL = @USE_RCYNIC_JAIL@ +RCYNIC_JAIL_DIRECTORY = @RCYNIC_JAIL_DIRECTORY@ + SCRIPTS = rcynic-text rcynic-html rcynic-svn validation_status all: ${BIN} ${SCRIPTS} @@ -53,7 +56,7 @@ test: ${BIN} fi install: ${BIN} installation-scripts/install.sh - cd installation-scripts; host_os="${host_os}"; DESTDIR="${DESTDIR}"; AWK="${AWK}"; SORT="${SORT}"; . ./install.sh + cd installation-scripts; host_os="${host_os}"; jaildir="${RCYNIC_JAIL_DIR}" DESTDIR="${DESTDIR}"; AWK="${AWK}"; SORT="${SORT}"; . ./install.sh uninstall deinstall: cd installation-scripts; host_os="${host_os}"; DESTDIR="${DESTDIR}"; . ./deinstall.sh diff --git a/rcynic/installation-scripts/deinstall.sh b/rcynic/installation-scripts/deinstall.sh index 113794a4..d94d7ed8 100644 --- a/rcynic/installation-scripts/deinstall.sh +++ b/rcynic/installation-scripts/deinstall.sh @@ -2,4 +2,4 @@ # $Id$ echo Sorry, automated deinstallation of rcynic is not implemented yet -exit 1 +#exit 1 @@ -29,6 +29,7 @@ import os import subprocess from distutils.core import setup, Extension, Command from distutils.command.build_ext import build_ext as _build_ext +from distutils.command.sdist import sdist as _sdist ac = None @@ -102,6 +103,17 @@ class build_ext(_build_ext): return _build_ext.run(self) +# The following hack uses "svn ls -R" to generate the manifest. +# Haven't decided yet whether that's a good idea or not, commented out +# of cmdclass for now. + +class sdist(_sdist): + def add_defaults(self): + try: + self.filelist.extend(subprocess.check_output(("svn", "ls", "-R")).splitlines()) + except CalledProcessError: + return _sdist.add_default(self) + # Be careful constructing data_files, empty file lists here appear to # confuse setup into putting dangerous nonsense into the list of # installed files. @@ -151,7 +163,9 @@ setup(name = "rpkitoolkit", url = "http://www.rpki.net/", cmdclass = {"autoconf" : autoconf, "build_ext" : build_ext, - "build_openssl" : build_openssl}, + "build_openssl" : build_openssl, + # "sdist" : sdist, + }, package_dir = {"" : "rpkid"}, packages = ["rpki", "rpki.POW", "rpki.irdb", "rpki.gui", "rpki.gui.app", "rpki.gui.cacheview", |