From 97ba4062f892f349bc9695420bcd3e269b5747a7 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 10 Sep 2018 12:40:56 +0200 Subject: Install systemd services with autotools Change-Id: I103bf3468d53578045593eac31b61f7e0248495e --- Makefile.am | 4 ++++ configure.ac | 18 ++++++++++++++++++ contrib/Makefile.am | 1 + contrib/systemd/Makefile.am | 9 +++++++++ debian/control | 1 + debian/osmo-gbproxy.install | 1 + debian/osmo-gbproxy.service | 1 - debian/osmo-gtphub.install | 1 + debian/osmo-gtphub.service | 1 - debian/osmo-sgsn.install | 1 + debian/osmo-sgsn.service | 1 - debian/rules | 2 +- 12 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 contrib/Makefile.am create mode 100644 contrib/systemd/Makefile.am delete mode 120000 debian/osmo-gbproxy.service delete mode 120000 debian/osmo-gtphub.service delete mode 120000 debian/osmo-sgsn.service diff --git a/Makefile.am b/Makefile.am index 38fdcba2a..1883ab5fc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,6 +12,7 @@ SUBDIRS = \ doc \ include \ src \ + contrib \ tests \ $(NULL) @@ -21,6 +22,9 @@ pkgconfig_DATA = osmo-sgsn.pc BUILT_SOURCES = $(top_srcdir)/.version EXTRA_DIST = git-version-gen osmoappdesc.py .version +DISTCHECK_CONFIGURE_FLAGS = \ + --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) + @RELMAKE@ $(top_srcdir)/.version: diff --git a/configure.ac b/configure.ac index c233fa3e2..73b6dce8d 100644 --- a/configure.ac +++ b/configure.ac @@ -176,6 +176,22 @@ AC_MSG_CHECKING([whether to enable VTY/CTRL tests]) AC_MSG_RESULT([$enable_ext_tests]) AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes") +# https://www.freedesktop.org/software/systemd/man/daemon.html +AC_ARG_WITH([systemdsystemunitdir], + [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],, + [with_systemdsystemunitdir=auto]) +AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [ + def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd) + + AS_IF([test "x$def_systemdsystemunitdir" = "x"], + [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"], + [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])]) + with_systemdsystemunitdir=no], + [with_systemdsystemunitdir="$def_systemdsystemunitdir"])]) +AS_IF([test "x$with_systemdsystemunitdir" != "xno"], + [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])]) +AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"]) + AC_MSG_RESULT([CFLAGS="$CFLAGS"]) AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"]) @@ -201,4 +217,6 @@ AC_OUTPUT( tests/v42bis/Makefile doc/Makefile doc/examples/Makefile + contrib/Makefile + contrib/systemd/Makefile Makefile) diff --git a/contrib/Makefile.am b/contrib/Makefile.am new file mode 100644 index 000000000..3439c97be --- /dev/null +++ b/contrib/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = systemd diff --git a/contrib/systemd/Makefile.am b/contrib/systemd/Makefile.am new file mode 100644 index 000000000..b644f3401 --- /dev/null +++ b/contrib/systemd/Makefile.am @@ -0,0 +1,9 @@ +if HAVE_SYSTEMD +SYSTEMD_SERVICES = \ + osmo-gbproxy.service \ + osmo-gtphub.service \ + osmo-sgsn.service + +EXTRA_DIST = $(SYSTEMD_SERVICES) +systemdsystemunit_DATA = $(SYSTEMD_SERVICES) +endif diff --git a/debian/control b/debian/control index 330945fc0..46a6b67cf 100644 --- a/debian/control +++ b/debian/control @@ -4,6 +4,7 @@ Priority: extra Maintainer: Alexander Couzens Build-Depends: debhelper (>=9), dh-autoreconf, + dh-systemd (>= 1.5), autotools-dev, autoconf, automake, diff --git a/debian/osmo-gbproxy.install b/debian/osmo-gbproxy.install index 8272551d8..9c7fb77f9 100644 --- a/debian/osmo-gbproxy.install +++ b/debian/osmo-gbproxy.install @@ -1,3 +1,4 @@ +lib/systemd/system/osmo-gbproxy.service usr/bin/osmo-gbproxy usr/share/doc/osmo-sgsn/examples/osmo-gbproxy/osmo-gbproxy-legacy.cfg usr/share/doc/osmo-gbproxy/examples usr/share/doc/osmo-sgsn/examples/osmo-gbproxy/osmo-gbproxy.cfg usr/share/doc/osmo-gbproxy/examples diff --git a/debian/osmo-gbproxy.service b/debian/osmo-gbproxy.service deleted file mode 120000 index d23c64920..000000000 --- a/debian/osmo-gbproxy.service +++ /dev/null @@ -1 +0,0 @@ -../contrib/systemd/osmo-gbproxy.service \ No newline at end of file diff --git a/debian/osmo-gtphub.install b/debian/osmo-gtphub.install index ed0bd1b75..568caaff2 100644 --- a/debian/osmo-gtphub.install +++ b/debian/osmo-gtphub.install @@ -1,3 +1,4 @@ +lib/systemd/system/osmo-gtphub.service usr/bin/osmo-gtphub usr/share/doc/osmo-sgsn/examples/osmo-gtphub/osmo-gtphub-1iface.cfg usr/share/doc/osmo-gtphub/examples usr/share/doc/osmo-sgsn/examples/osmo-gtphub/osmo-gtphub.cfg usr/share/doc/osmo-gtphub/examples diff --git a/debian/osmo-gtphub.service b/debian/osmo-gtphub.service deleted file mode 120000 index 81a0eb473..000000000 --- a/debian/osmo-gtphub.service +++ /dev/null @@ -1 +0,0 @@ -../contrib/systemd/osmo-gtphub.service \ No newline at end of file diff --git a/debian/osmo-sgsn.install b/debian/osmo-sgsn.install index 9390deba5..9d603f9bc 100644 --- a/debian/osmo-sgsn.install +++ b/debian/osmo-sgsn.install @@ -1,3 +1,4 @@ +lib/systemd/system/osmo-sgsn.service usr/bin/osmo-sgsn usr/share/doc/osmo-sgsn/examples/osmo-sgsn/osmo-sgsn.cfg usr/share/doc/osmo-sgsn/examples usr/share/doc/osmo-sgsn/examples/osmo-sgsn/osmo-sgsn-accept-all.cfg usr/share/doc/osmo-sgsn/examples diff --git a/debian/osmo-sgsn.service b/debian/osmo-sgsn.service deleted file mode 120000 index de22d9096..000000000 --- a/debian/osmo-sgsn.service +++ /dev/null @@ -1 +0,0 @@ -../contrib/systemd/osmo-sgsn.service \ No newline at end of file diff --git a/debian/rules b/debian/rules index fb31c5830..af6b5b6e4 100755 --- a/debian/rules +++ b/debian/rules @@ -46,7 +46,7 @@ # debmake generated override targets # Set options for ./configure -CONFIGURE_FLAGS += --enable-iu +CONFIGURE_FLAGS += --enable-iu --with-systemdsystemunitdir=/lib/systemd/system override_dh_auto_configure: dh_auto_configure -- $(CONFIGURE_FLAGS) # -- cgit v1.2.3