我可以在distcheck期间使用$ dc_install_base安装systemd文件吗? [英] Can I install a systemd file during distcheck using $dc_install_base?

查看:118
本文介绍了我可以在distcheck期间使用$ dc_install_base安装systemd文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有以下用于安装systemd服务文件的Autotools代码,该文件必须安装在$prefix之外,并安装到pkg-config变量指定的目录中:

I have the following Autotools code for installing a systemd service file, which must be installed outside of $prefix to a directory given by a pkg-config variable:

(我知道这不合适,但是我无法更改systemd的工作方式.)

(I know this is not proper, but I can't change the way systemd works.)

configure.ac

AC_ARG_WITH([systemdsystemunitdir],
    AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
        [Directory for systemd service files]),
    [],
    [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])

运行make distcheck时,程序包将安装到临时暂存目录中,然后卸载.由于在$prefix之外安装某些东西会破坏它,因此我必须覆盖distcheck的--with-systemdsystemunitdir配置选项.我这样做是因为,临时目录的位置在变量$dc_install_base中可用.我不能在此处传递绝对路径,并且$prefix或任何其他$prefix派生的变量(例如$libdir)在distcheck运行期间将不正确.

When you run make distcheck, your package gets installed into a temporary staging directory and then uninstalled. Since installing something outside of $prefix will break that, I must override the --with-systemdsystemunitdir configuration option for distcheck. I do it like so, since the location of the staging directory is available in the variable $dc_install_base. I can't pass an absolute path here, and $prefix or any other $prefix-derived variable such as $libdir will not be correct during the distcheck run itself.

Makefile.am

AM_DISTCHECK_CONFIGURE_FLAGS = \
    --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)

我的问题有两个:

  • 此功能($dc_install_base)似乎在任何地方都没有记录.是官方支持还是实现细节?我相信,通常Automake-private变量中有两个连续的下划线.

  • This feature ($dc_install_base) doesn't seem to be documented anywhere. Is it officially supported or an implementation detail? Usually Automake-private variables have two consecutive underscores in them, I believe.

是否有更好的方法来做我想做的事情?我知道Autotools的方式是将systemdsystemunitdir默认设置为$prefix的子目录,并让用户或发行版覆盖它.但是,对我来说,一个重要的要求是,应该能够从tarball中提取包,运行./configure && makesudo make install并使一切正常.如果将systemd文件安装在pkg-config指定的位置之外的其他位置,则它将无法正常工作,而且,它会以静默方式失败.

Is there a better way to do what I'm trying to do? I know the Autotools way would be to set systemdsystemunitdir to a subdirectory of $prefix by default, and let the user or the distro override it. However, it's an important requirement to me that one should be able to extract the package from the tarball, run ./configure && make and sudo make install and have everything just work. If the systemd file were installed anywhere else besides the location given by pkg-config, it would not work, and what's more, fail silently.

推荐答案

有点晚了,但是...

A bit late but...

我在gobject-introspection上遇到了类似的问题,我(希望)通过添加几个配置选项和类似的东西来解决了该问题:

I had a similar problem with gobject-introspection and I (hopefully) resolved by adding a couple of configure options and something like:

AM_DISTCHECK_CONFIGURE_FLAGS= \
    --with-girdir='$$(datadir)/gir-1.0' \
    --with-typelibdir='$$(libdir)/girepository-1.0'

在您的情况下,我认为以下方法应该有效:

In your case I think the following should work:

AM_DISTCHECK_CONFIGURE_FLAGS = \
    --with-systemdsystemunitdir='$$(prefix)/$(systemdsystemunitdir)'

诀窍在于,您必须保护$(prefix)不受两个扩展的影响:make扩展(因此为$$的两倍)和在configure调用期间执行的shell扩展(将单引号引起来).

The trick is that you must protect $(prefix) against two expansions: the make expansion (hence the double $$) and the shell expansion performed during the configure call (hance the single quotes).

这篇关于我可以在distcheck期间使用$ dc_install_base安装systemd文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆