How does% config work in RPM builds?

0

I'm trying to make an update on an application in GO that I have. For the build, I have a .spec file that RPM uses to build, the problem is that I have the following case:

I have 3 configuration files, which I need never to be removed / changed by my package.

When I remove anything related to these files from the .spec file, it even removes the file from my server when I install the package. Then I saw that there is an option to mark these files as %config , which was not a success, since in the build as these files do not exist the RPM returns a file error not found File not found: /caminho/do/arquivo .

I'm new to RPM, can you give me a light? heh

I'll leave below 2 versions of my .spec file (hiding some peculiarities)

First summer (marking the files as config, the build fails because it can not find the files):

%define debug_package %{nil}
%define _unpackaged_files_terminate_build 0
%undefine _missing_build_ids_terminate_build
%global srcname app-name
%global version 1.4.5

Name: %{srcname}
Version: %{version}
Release: 1
Summary: App name Manager
Group: dev
License: Empresa
URL: url_do_repo
Source: %{srcname}.tar.gz
Requires(pre): /usr/sbin/adduser, /usr/bin/getent

%description
App name manager.

%prep
%setup -q -n %{srcname}

%build
cd /go/src/app-name
make build_centos buildroot=/go/src/app-name/build/usr/bin

%install
%{__mkdir_p} %{buildroot}/var/www/app-name/config
%{__mkdir_p} %{buildroot}/lib/systemd/scripts
%{__mkdir_p} %{buildroot}/lib/systemd/system
%{__mkdir_p} %{buildroot}/usr/sbin
%{__install} -m 755 redhat/systemd.app-name.script %{buildroot}/lib/systemd/scripts/app-name
%{__install} -m 644 redhat/systemd.app-name.service %{buildroot}/lib/systemd/system/app-name.service
%{__install} -m 755 /go/src/app-name/build/usr/bin/app-name %{buildroot}/usr/sbin/app-name
%{__install} -m 755 config/certificate.pem %{buildroot}/var/www/app-name/config/certificate.pem

%clean
%{__rm} -rf %{buildroot}
%{__rm} -rf %{builddir}/%{name}

%files
%defattr(-,root,root,-)
%attr(0755,app-name,app-name) /usr/sbin/app-name
%attr(0644,app-name,app-name) /var/www/app-name/config/certificate.pem
%attr(0755,root,root) /lib/systemd/scripts/app-name
%attr(0644,root,root) /lib/systemd/system/app-name.service
%config(noreplace) /var/www/app-name/config/auth.yml
%config(noreplace) /var/www/app-name/config/app-name.yml
%config(noreplace) /var/www/app-name/config/app-name.conf

%pre
/usr/bin/getent passwd app-name || /usr/sbin/adduser --home "/var/www/app-name" app-name

%changelog

Second version, not referencing the files auth.yml , app-name.yml , app-name.conf , on installation, these files are removed from the server:

%define debug_package %{nil}
%define _unpackaged_files_terminate_build 0
%undefine _missing_build_ids_terminate_build
%global srcname app-name
%global version 1.4.5

Name: %{srcname}
Version: %{version}
Release: 1
Summary: App Name Manager
Group: dev
License: Empresa
URL: url_do_repo
Source: %{srcname}.tar.gz
Requires(pre): /usr/sbin/adduser, /usr/bin/getent

%description
App name manager.

%prep
%setup -q -n %{srcname}

%build
cd /go/src/app-name
make build_centos buildroot=/go/src/app-name/build/usr/bin

%install
%{__mkdir_p} %{buildroot}/var/www/app-name/config
%{__mkdir_p} %{buildroot}/lib/systemd/scripts
%{__mkdir_p} %{buildroot}/lib/systemd/system
%{__mkdir_p} %{buildroot}/usr/sbin
%{__install} -m 755 redhat/systemd.app-name.script %{buildroot}/lib/systemd/scripts/app-name
%{__install} -m 644 redhat/systemd.app-name.service %{buildroot}/lib/systemd/system/app-name.service
%{__install} -m 755 /go/src/app-name/build/usr/bin/app-name %{buildroot}/usr/sbin/app-name
%{__install} -m 755 config/certificate.pem %{buildroot}/var/www/app-name/config/certificate.pem

%clean
%{__rm} -rf %{buildroot}
%{__rm} -rf %{builddir}/%{name}

%files
%defattr(-,root,root,-)
%attr(0755,app-name,app-name) /usr/sbin/app-name
%attr(0644,app-name,app-name) /var/www/app-name/config/certificate.pem
%attr(0755,root,root) /lib/systemd/scripts/app-name
%attr(0644,root,root) /lib/systemd/system/app-name.service

%pre
/usr/bin/getent passwd app-name || /usr/sbin/adduser --home "/var/www/app-name" app-name

%changelog
    
asked by anonymous 28.11.2018 / 14:25

0 answers