Skip to content
Advertisement

rpm.spec hide warning that comes after %post

I’m trying to solve this problem for a few days now but still nothing…

Let’s say for example this is my upgrade.sh:

Finished upgrading...

And this is my rpm.spec file:

Name: Hi
Summary:  Discover Server
Source: %{name}-%{version}.%{release}.tar.gz
Version:    %{version}
Release:    %{release}
Group:   Discover Server
License: Commercial
Vendor:  Software
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Obsoletes: %{name}

%description
 Discover Server

%prep

%setup -n %{name} -q

%install
something that is not relevant

%post
sh ./upgrade.sh
echo "finished post"

%pre

%preun

%clean
echo "cleaning"
rm -rf ($RPM_BUILD_ROOT) &> /dev/null

%files -f %{name}-%{version}-filelist

Now I got example.rpm file. After I’m running the command rpm -U example.rpm this is the output I’m getting:

Finished upgrading
Finished post

warning: XYXYXY: remove failed: No such file or directory
warning: XXXX: remove failed: No such file or directory

Everything works fine with the upgrade, my only problem is that I don’t want to show the warnings that coming after the post commanded is finish. How can I do it? Every time we release a new upgrade the name of the files are different, cause they have the version name on them so maybe that’s the problem.

Is there an easy way to make these warning messages just to go to dev/null or something? Also it is important to see the "Finished upgrading..." message.

Advertisement

Answer

The warning means that rpm is trying to remove the files from the old package, but they are not on the file system anymore. So you should ask yourself why that is so, and what to do about this:

  • Are you removing them manually? Don’t, and let rpm remove them for you.
  • Are they not guaranteed to be on the system? In that case you could make them %ghost files. These files will be removed when present, but you won’t get no warning if they don’t exist. (more on %ghost files here)
%files
%ghost /path/to/file-that-might-or-not-be-there

If you wonder why this error appears after the %post section is executed, then here is a good read for you where the order of all scriptlets during an upgrade is well shown: https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#ordering

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement