Installing rpm-package to systemd?
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")
}
}
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 addParentDirs
option:
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)