Skip to content

Commit

Permalink
nut-common.tmpfiles.in: fix systemd magic vs autoconf magic
Browse files Browse the repository at this point in the history
Follows up from PR networkupstools#1037 for issue networkupstools#1030 to let the trick work for
distcheck and similar out-of-tree builds.
  • Loading branch information
jimklimov committed Sep 30, 2021
1 parent 4722a4f commit f9a052c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ then
fi

if [ ! -e scripts/systemd/nut-common.tmpfiles.in ]; then
echo '# autoconf requires this file exists before generating configure script' > scripts/systemd/nut-common.tmpfiles.in
echo '# autoconf requires this file exists before generating configure script; it will be overwritten by configure during a build' > scripts/systemd/nut-common.tmpfiles.in
fi

# now we can safely call autoreconf
Expand Down
26 changes: 21 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2165,29 +2165,45 @@ AC_MSG_RESULT(["${nut_enable_Werror}"])
dnl Finally restore warnings settings that the caller might have provided in CFLAGS etc
NUT_POP_WARNINGS

dnl Due to possibly repetitive content, generate unique settings:
dnl Due to possibly repetitive content, generate unique settings
dnl relative to the top_builddir (distcheck and all):
AC_MSG_CHECKING([for top build dir for this configure run])
TOP_BUILDDIR=""
AS_IF([test -n "${ac_abs_top_builddir}" && test -d "${ac_abs_top_builddir}"],
[TOP_BUILDDIR="${ac_abs_top_builddir}"],
[AS_IF([test -n "${ac_pwd}" && test -d "${ac_pwd}"],
[TOP_BUILDDIR="${ac_pwd}"],
[TOP_BUILDDIR="`dirname "$0"`"
TOP_BUILDDIR="`cd "$TOP_BUILDDIR" && pwd`"]
)]
)
AC_MSG_RESULT(["${TOP_BUILDDIR}"])

AC_MSG_CHECKING([whether to customize ${TOP_BUILDDIR}/scripts/systemd/nut-common.tmpfiles.in for this system])
AS_IF([test -n "$systemdtmpfilesdir"],
[cat > scripts/systemd/nut-common.tmpfiles.in << EOF
[mkdir -p "${TOP_BUILDDIR}"/scripts/systemd
cat > "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF
# State file (e.g. upsd to driver) and pidfile location for NUT:
d @STATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
X @STATEPATH@/nut
EOF
AS_IF([test "$STATEPATH" != "$PIDPATH"],
[cat >> scripts/systemd/nut-common.tmpfiles.in << EOF
[cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF
d @PIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
X @PIDPATH@/nut
EOF])
AS_IF([test -n "$ALTPIDPATH" && test "$STATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTPIDPATH"],
[cat >> scripts/systemd/nut-common.tmpfiles.in << EOF
[cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF
d @ALTPIDPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
X @ALTPIDPATH@/nut
EOF])
AS_IF([test -n "$ALTSTATEPATH" && test "$STATEPATH" != "$ALTSTATEPATH" && test "$ALTSTATEPATH" != "$ALTPIDPATH" && test "$PIDPATH" != "$ALTSTATEPATH"],
[cat >> scripts/systemd/nut-common.tmpfiles.in << EOF
[cat >> "${TOP_BUILDDIR}"/scripts/systemd/nut-common.tmpfiles.in << EOF
d @ALTSTATEPATH@/nut 0770 @RUN_AS_USER@ @RUN_AS_GROUP@ - -
X @ALTSTATEPATH@/nut
EOF])
])
AC_MSG_RESULT([done])

AC_MSG_NOTICE([Generating "data" files from templates, see below for executable scripts])
AC_CONFIG_FILES([
Expand Down
4 changes: 3 additions & 1 deletion scripts/systemd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ sbin_SCRIPTS = ../upsdrvsvcctl/upsdrvsvcctl

else
EXTRA_DIST += \
nut-common.tmpfiles.in nut-[email protected] nut-monitor.service.in \
[email protected] nut-monitor.service.in \
nut-server.service.in nutshutdown.in nut-driver.target nut.target \
nut-driver-enumerator.path.in nut-driver-enumerator.service.in

# NOTE: Do not EXTRA_DIST nut-common.tmpfiles.in - it is generated per build
endif

0 comments on commit f9a052c

Please sign in to comment.