0

i build a rpm called rsv-1.0, it will automatically install a rsv.cfg file to /etc when you install rsv-1.0.rpm

the package only contain one file etc/rsc.cfg

what if i want to do a change in the file rsv.cfg for a updated rpm say rsv-2.0.rpm

i then created a empty dir and tared it to rsv-2.0.tar.gz including this in new SPEC file

%post
if [ -f /etc/rsv.cfg ]; then
    /bin/echo "hello-2.0" > /etc/rsv.cfg
fi

as a shell command

but i find it only works when you use rpm -ivh rsv-2.0.rpm

if you use rpm -Uvh rsv-2.0.rpm, the file in /etc/rsv.cfg disappear

so my question is, how to make an update rpm which dose nothing but run a shell command?

update spec file for v2

Name: rsv
Version: 2.0
Release: 1
Summary: rsv rpm

Group:  rsv
License: GPL+
URL: 
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

#BuildRequires:
#Requires:

%description
%{summary}

%prep
%setup -q


%build


%install
rm -rf %{buildroot}
mkdir -p  %{buildroot}

#cp -a * %{buildroot}


%clean
rm -rf %{buildroot}

%post
if [ -f /etc/rsv.cfg ]; then
    /bin/echo "hello-2.0" > /etc/rsv.cfg
fi


%files
%defattr(-,root,root,-)
%doc

#%config %{_sysconfdir}/%{name}.cfg

%changelog

the spec file for v1.0 is just uncomment %config and #cp

user2124498
  • 121
  • 1
  • 5

1 Answers1

0

Because the original spec file was incorrect and didn't explicitly list the file as a configuration file, I think that is what is erasing it.

A possible fix for this is to have the version 2 %pre section see if it exists and copy it somewhere.

The script ordering for upgrade can be confusing. A second copy is installed, with their %pre/%post called, and then the first copy's %preun/%postun is called.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39