The algorithm used for installing hardlinks does not handle the case where a 
package upgrade includes additional names for an inode. It iterates the list of 
files from the beginning until the end and only writes content and metadata for 
the last occurence of an inode.
For upgrades, there is no hardlink relationship though, the added file has a 
different inode. This means that the content and metadata are written only to 
the files from the old package.

Reproducer:

```
Name: pkg
Version: %{ver}
Release: 0
License: WTFPL
Summary: Package

%description
..

%install
mkdir -p %{buildroot}/usr
echo "content" > %{buildroot}/usr/file2
%if %{ver} == 1
ln %{buildroot}/usr/file2 %{buildroot}/usr/file1
%endif

%files
%if %{ver} == 1
/usr/file1
%endif
/usr/file2
```

To build:
```
rpmbuild -bb -D 'ver 0' pkg.spec
rpmbuild -bb -D 'ver 1' pkg.spec
```

To install:
```
localhost:~ # rpm -U --force pkg-0-0.x86_64.rpm
localhost:~ # ll /usr/file{1,2}
ls: cannot access '/usr/file1': No such file or directory
-rw-r--r-- 1 root root 8 Jun 19 17:03 /usr/file2
localhost:~ # ll /usr/file{1,2}
--w------- 1 root root 0 Jun 19 17:10 /usr/file1
-rw-r--r-- 1 root root 8 Jun 19 17:03 /usr/file2
```

As you can see, `/usr/file1` was created with wrong mode and no content. The 
two files do not share an inode. It works if the package is installed directly:

```
localhost:~ # rpm -e pkg
localhost:~ # rpm -U --force pkg-1-0.x86_64.rpm
localhost:~ # ll /usr/file{1,2}
-rw-r--r-- 2 root root 8 Jun 19 17:03 /usr/file1
-rw-r--r-- 2 root root 8 Jun 19 17:03 /usr/file2
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1278
_______________________________________________
Rpm-maint mailing list
Rpm-maint@lists.rpm.org
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to