[Rpm-maint] [rpm-software-management/rpm] rpmbuild fails with symbolic links (#1682)

skysley notifications at github.com
Tue May 11 07:34:39 UTC 2021


I Initially submitted this bug at [bugzilla.redhat.com](https://bugzilla.redhat.com/show_bug.cgi?id=1953372).

**Description of problem:**
On my Arch Linux (5.10.16-arch1-1) I cannot build a simple spec file (see attachment at the bottom) depending the directory from which the package is being built.

**Version-Release number of selected component (if applicable):**
* 4.16.1.2 (from Arch Linux rpm-tools)
* rpm-4.16.0-alpha-417-ge1fbd486e (git: e1fbd486e9bdd52fa7c5b5efea4ce9de13e48955)

**How reproducible:**
Not sure. May depend on filesystem.

**Steps to Reproduce:**
1. Copy spec file to different locations on system

2. On each location, build the attached spec file using this command:
`rpmbuild -bb --define 'input_dir input' --buildroot ${PWD}/build <path to spec file>`


**Actual results:**
If you are lucky, observe error on some locations:
```
error: create archive failed: cpio: write failed - No such file or directory


RPM build errors:
    create archive failed: cpio: write failed - No such file or directory
```


**Expected results:**
Having a working .rpm package.


**Additional info:**

I debugged through the git version shown above. Please note that I am not very confident with all of the internals.

The attached spec file compiles a simple C++ program and adds this to the build root. For reasons I don't know rpmbuild creates a symbolic link to this program. Depending on the directory I build the rpm in, the symbolic link has a file size of either 24 Bytes or 34 Bytes. Notice: 24 is also the length of the path that the symbolic link points to.

In files.c (function `addFile`) the file size is read using `lstat`. In cpio.c the expected file end is computed as 

`cpio->fileend = cpio->offset + st->st_size;`

In rpmfi.c (function `iterWriteArchiveNext`) the length of the path is taken that the symbolic link points to. This string is written into the archive and `offset` is incremented by the length of the path. 

Since the path length is not necessarily equal to the size of the symbolic link the rpmbuild may fail at the end when `fileend` is checked to be equal to `offset`.

What I haven't looked into is whether this has something to do with encrypted file systems. I am using luks and fscrypt.

.spec file: [hello.spec.txt](https://github.com/rpm-software-management/rpm/files/6457257/hello.spec.txt)



-- 
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/1682
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20210511/fd094c42/attachment.html>


More information about the Rpm-maint mailing list