[Rpm-maint] [rpm-software-management/rpm] %pre runs after existing filesystem is inspected (Issue #1934)
Alex Iribarren
notifications at github.com
Wed Feb 23 15:42:08 UTC 2022
I'm trying to create an RPM to start packaging some config files that were previously created manually and I've discovered a weird behavior I wasn't aware of. It seems the `%pre` scriptlet runs later than I would expect, after the existing filesystem has been analyzed.
Consider the following spec file:
```
Name: scripts
Version: 1.0
Release: 1
Summary: Testing script behavior
Group: Testing
License: GPL
BuildArch: noarch
%description
%{summary}
%install
mkdir -p %{buildroot}/tmp/test/
echo "hello" > %{buildroot}/tmp/test/test.conf
%files
%defattr(-,root,root,-)
%config(noreplace) /tmp/test/test.conf
%pre
echo %{name}-%{version}-%{release} PRE $*
if [[ $1 -eq 1 ]]; then
[[ ! -s /tmp/test/test.conf ]] && rm -f /tmp/test/test.conf
fi
ls -l /tmp/test/
echo %{name}-%{version}-%{release} PRE DONE
exit 0
```
Build the RPM and then run the following commands: `mkdir -p /tmp/test/ && touch /tmp/test/test.conf`
If you then install the RPM, you'll see the following:
```
...
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: scripts-1.0-1.noarch 1/1
scripts-1.0-1 PRE 1
total 0
scripts-1.0-1 PRE DONE
Installing : scripts-1.0-1.noarch 1/1
warning: /tmp/test/test.conf created as /tmp/test/test.conf.rpmnew
Verifying : scripts-1.0-1.noarch 1/1
Installed:
scripts-1.0-1.noarch
```
Notice that the `%pre` script deleted the empty `/tmp/test/test.conf`, as it should. However, the new config file is created as `/tmp/test/test.conf.rpmnew`, even though `/tmp/test/test.conf` no longer exists!
Is this behavior expected?
--
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1934
You are receiving this because you are subscribed to this thread.
Message ID: <rpm-software-management/rpm/issues/1934 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20220223/4b394938/attachment-0001.html>
More information about the Rpm-maint
mailing list