aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sysutils/xen-tools/Makefile22
-rw-r--r--sysutils/xen-tools/distinfo6
-rw-r--r--sysutils/xen-tools/files/xe-daemon.in28
-rw-r--r--sysutils/xen-tools/files/xe_wrapper91
4 files changed, 142 insertions, 5 deletions
diff --git a/sysutils/xen-tools/Makefile b/sysutils/xen-tools/Makefile
index 6354015c3d98..1cc9fccda14a 100644
--- a/sysutils/xen-tools/Makefile
+++ b/sysutils/xen-tools/Makefile
@@ -5,14 +5,23 @@
# $FreeBSD$
PORTNAME= xen-tools
-PORTVERSION= 4.0.1
+PORTVERSION= 4.1.3
CATEGORIES= sysutils
DISTNAME= xen-${PORTVERSION}
MAINTAINER= feld@feld.me
COMMENT= Xen tools within FreeBSD domU
-MASTER_SITES= http://bits.xensource.com/oss-xen/release/${PORTVERSION}/
+MASTER_SITES= http://bits.xensource.com/oss-xen/release/${PORTVERSION}/:xensource \
+ https://github.com/${GIT_ACCOUNT}/${GIT_PROJECT}/tarball/${GIT_VERSION}/:github
+DISTFILES= xen-${PORTVERSION}.tar.gz:xensource \
+ ${GIT_ACCOUNT}-${GIT_PROJECT}-${GIT_VERSION}.tar.gz:github
+
+FETCH_ARGS= -pRr
+GIT_ACCOUNT= felderado
+GIT_PROJECT= freebsd-xen-tools-scripts
+GIT_VERSION= bfb06da
+GITSRC= ${WRKDIR}/${GIT_ACCOUNT}-${GIT_PROJECT}-${GIT_VERSION}/src/
USE_GMAKE= yes
USE_PYTHON= yes
@@ -30,7 +39,11 @@ PLIST_FILES= lib/libxenstore.so.3.0 \
bin/xenstore-ls \
bin/xenstore-read \
bin/xenstore-rm \
- bin/xenstore-write
+ bin/xenstore-write \
+ sbin/xe-daemon \
+ sbin/xe-update-guest-attrs \
+ sbin/xe_wrapper
+
do-build:
cd ${WRKSRC}/tools && ${GMAKE} -C include
cd ${WRKSRC}/tools/misc && ${GMAKE} xen-detect
@@ -41,6 +54,9 @@ do-install:
${INSTALL_PROGRAM} ${WRKSRC}/tools/xenstore/xenstore ${PREFIX}/bin
${INSTALL_PROGRAM} ${WRKSRC}/tools/xenstore/xenstore-control ${PREFIX}/bin
${INSTALL_PROGRAM} ${WRKSRC}/tools/xenstore/libxenstore.so.3.0 ${PREFIX}/lib
+ ${INSTALL_SCRIPT} ${GITSRC}/usr/local/sbin/xe-daemon ${PREFIX}/sbin
+ ${INSTALL_SCRIPT} ${GITSRC}/usr/local/sbin/xe-update-guest-attrs ${PREFIX}/sbin
+ ${INSTALL_SCRIPT} ${FILESDIR}/xe_wrapper ${PREFIX}/sbin
post-install:
${LN} -sf ${PREFIX}/bin/xenstore ${PREFIX}/bin/xenstore-chmod
diff --git a/sysutils/xen-tools/distinfo b/sysutils/xen-tools/distinfo
index 84aa81d10bf8..76202528fcc6 100644
--- a/sysutils/xen-tools/distinfo
+++ b/sysutils/xen-tools/distinfo
@@ -1,2 +1,4 @@
-SHA256 (xen-4.0.1.tar.gz) = 6e6d1d29400db93cb8095e034138aa8748b1bd4cffb4d3fd07af4ba15c918873
-SIZE (xen-4.0.1.tar.gz) = 11909200
+SHA256 (xen-4.1.3.tar.gz) = 178ef186aca2490126aef69ceb41fc509baf89e0d582768cfa33b17fd145c0e4
+SIZE (xen-4.1.3.tar.gz) = 10382132
+SHA256 (felderado-freebsd-xen-tools-scripts-bfb06da.tar.gz) = 58b5c5bb51bccb6843506bbb9c8ce3381ff262e6b221577496468f48226ab038
+SIZE (felderado-freebsd-xen-tools-scripts-bfb06da.tar.gz) = 50775
diff --git a/sysutils/xen-tools/files/xe-daemon.in b/sysutils/xen-tools/files/xe-daemon.in
new file mode 100644
index 000000000000..d261bcde5c2f
--- /dev/null
+++ b/sysutils/xen-tools/files/xe-daemon.in
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# PROVIDE: xe_daemon
+# REQUIRE: login
+# KEYWORD: nojail shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# xe_daemon_enable (bool): Set to NO by default.
+# Set it to YES to enable xe_daemon.
+#
+
+. /etc/rc.subr
+
+name=xe_daemon
+rcvar=xe_daemon_enable
+
+command="%%PREFIX%%/sbin/xe_wrapper"
+command_interpreter="/bin/sh -T"
+command_args="%%PREFIX%%/sbin/xe-daemon &"
+
+load_rc_config $name
+
+pidfile="/var/run/xe_wrapper.pid"
+: ${xe_daemon_enable="NO"}
+
+run_rc_command "$1"
diff --git a/sysutils/xen-tools/files/xe_wrapper b/sysutils/xen-tools/files/xe_wrapper
new file mode 100644
index 000000000000..266e6d85c0e7
--- /dev/null
+++ b/sysutils/xen-tools/files/xe_wrapper
@@ -0,0 +1,91 @@
+#!/bin/sh -T
+#
+#-
+# Copyright 2009 Thomas-Martin Seck. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted providing that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+# socat_wrapper socat [options]
+#
+# A simple wrapper script for socat (or any other program that does not
+# daemonize itself and logs to stdout).
+#
+# This wrapper tries to emulate part of the functionality usually supplied by
+# software like daemontools or runit. It can be used by a FreeBSD port rc.d
+# script to start a program that does not daemonize itself and logs to
+# stdout/stderr. It redirects stdout and stderr to logger(1) via a fifo.
+#
+# Note: We need a shell that can offer us asynchronous trap handling in order
+# to be able to abort the infinite loop from outside. FreeBSD's /bin/sh offers
+# the "-T" switch for this purpose.
+#
+# TODO: send fd 2 output to never-never land to get rid of "Terminated" when we
+# kill this script but provide a way for errx() to communicate with the outside
+# world via stderr.
+#
+
+errx() {
+ echo "${me}: $@" >&2
+ exit 1
+}
+
+cleanup() {
+ rm -rf ${tmpdir}
+ rm -f ${pidfile}
+}
+
+PATH=/bin:/sbin:/usr/bin:/usr/sbin
+
+me=${0##*/}
+logger=/usr/bin/logger
+daemon_log_facility=daemon.notice
+self_log_facility=daemon.notice
+pidfile=/var/run/${me}.pid
+daemon_name=xe_daemon
+daemon_program="$1"
+shift
+
+test -x "${daemon_program}" || errx "cannot execute ${daemon_program}!"
+test -x ${logger} || errx "cannot execute ${logger}!"
+test -f ${pidfile} && errx "${pidfile} is already present -- is another instance of ${me} running?"
+echo $$ >${pidfile} || errx "cannot write to ${pidfile}!"
+tmpdir=`mktemp -d /tmp/${me}.XXXXXXXXXX` || errx "cannot generate tmpdir!"
+
+logfifo=${tmpdir}/fifo
+mkfifo -m 0600 ${logfifo} || errx "cannot generate fifo!"
+
+while true; do
+ trap 'break' 1 2 3 6 9 15
+ ${logger} -i -p ${daemon_log_facility} -t ${daemon_name} <${logfifo} &
+ log_pid=$!
+ "${daemon_program}" $@ >${logfifo} 2>&1 &
+ daemon_pid=$!
+ wait ${daemon_pid}
+ ${logger} -i -p ${self_log_facility} -t ${me} "${daemon_program} died -- restarting..."
+ sleep 2
+done
+
+kill -TERM ${daemon_pid} 2>/dev/null
+wait
+cleanup