大网数据广告活动
服务器运维问答

Installing rpm-package to systemd?

· 52CE 我爱测

I am new to systemd, and trying to get an in-house app packaged as rpm, to install on systemd host (RHEL7). The rpm tries to place the systemd .service-file: myapp.service into: /etc/systemd/system But that generates an error, I …

问题原文

原帖链接 · Rop · CC BY-SA 3.0

I am new to systemd, and trying to get an in-house app packaged as rpm, to install on systemd host (RHEL7).

The rpm tries to place the systemd .service-file: myapp.service into: /etc/systemd/system

But that generates an error, I dont understand:

file /etc/systemd from install of myapp-0:1-.i386 conflicts with file from package systemd-219-19.el7.x86_64
file /etc/systemd/system from install of myapp-0:1-.i386 conflicts with file from package systemd-219-19.el7.x86_64  

and the installation aborts.

The install-related contents from .service-file is:

[Unit]
Description=MyApp
After=syslog.target network.target activemq.service
Requires=activemq.service

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
...

Any idea what the conflict might be?

Or how to troubleshoot?

EDIT: Adding the rpm-stuff from gradle build-file:

myappRpm {
    dependsOn build
    packageName 'myapp'
    arch I386
    os LINUX
    version buildVersion

    preInstall file('./deploy/rpm/preinstall')
    postInstall file('./deploy/rpm/postinstall')
    preUninstall file('./deploy/rpm/preuninstall')

    directory('/var/log/myapp', 755)
    directory('/opt/myapp/app', 755)
    directory('/opt/myapp/bin', 755)
    directory('/opt/myapp/config', 755)

    into '/opt/myapp'

    from('MyApp/build/libs/MyApp.war') {
        into '/opt/myapp/app/'
        fileMode 0755
    }

    from('deploy/systemd/myapp.sh') {
        into '/opt/myapp/bin/'
        fileMode 0755
    }

    from('deploy/systemd/myapp.env') {
        into '/opt/myapp/systemd/'
        fileMode 0755
    }

    from('deploy/systemd/myapp.service') {
        into '/etc/systemd/system/'
        fileMode 0755
    }

    doLast {
        file("$buildDir/distributions/myapp-${buildVersion}.i386.rpm").renameTo("$buildDir/distributions/myapp.rpm")
    }
}

已采纳解答

原帖链接 · Chris Maes · CC BY-SA 3.0

each rpm specifies a list of files and directories that it installs. Two rpms cannot install the same files or directories. In your spec file (or whatever file you use to describe the rpm you build) you should not install the /etc/systemd/ and /etc/systemd/system/ directories. In a spec file; you should NOT use:

%files
/etc/systemd/

but

%files
/etc/systemd/system/*

(or specify each file separately)

EDIT

looking around for your gradle-plugin; You should use the addParentDirsoption:

from('deploy/systemd/myapp.service') {
    // Will tell redline-rpm not to auto create directories, which
    // is sometimes necessary to avoid rpm directory conflicts
    addParentDirs = false
    into '/etc/systemd/system/'
    fileMode 0755
}

(look at the full usage example on the nebula-gradle-plugin github page for more info)

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。