Yum
將 rpm-package 安裝到 systemd?
我是 systemd 的新手,並試圖將內部應用程序打包為 rpm,以安裝在 systemd 主機(RHEL7)上。
rpm 嘗試將 systemd .service-file: myapp.service 放入:/etc/systemd/system
但這會產生錯誤,我不明白:
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
並且安裝中止。
.service-file 中與安裝相關的內容是:
[Unit] Description=MyApp After=syslog.target network.target activemq.service Requires=activemq.service [Install] WantedBy=multi-user.target [Service] Type=simple ...
知道沖突可能是什麼嗎?
或者如何解決?
編輯:從 gradle build-file 添加 rpm-stuff:
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") } }
每個 rpm 都指定了它安裝的文件和目錄的列表。兩個 rpm 不能安裝相同的文件或目錄。在您的規範文件(或您用來描述您建構的 rpm 的任何文件)中,您不應該安裝and
/etc/systemd/
目錄/etc/systemd/system/
。在規範文件中;你不應該使用:%files /etc/systemd/
但
%files /etc/systemd/system/*
(或分別指定每個文件)
編輯
到處尋找你的 gradle-plugin;您應該使用以下
addParentDirs
選項: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 }
(查看nebula-gradle-plugin github 頁面上的完整用法範例以獲取更多資訊)