Bug 1953372 - rpmbuild fails with symbolic links
Summary: rpmbuild fails with symbolic links
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 34
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-04-25 20:50 UTC by dns
Modified: 2021-08-17 09:27 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-08-17 09:27:05 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
.spec file (528 bytes, text/plain)
2021-04-25 20:50 UTC, dns
no flags Details

Description dns 2021-04-25 20:50:58 UTC
Created attachment 1775335 [details]
.spec file

Description of problem:
On my Arch Linux (5.10.16-arch1-1) I cannot build a simple spec file (see attachment) depending the directory from whcih 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 current 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 the 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.

Comment 1 Florian Festi 2021-08-17 09:27:05 UTC
OK, this turns out to an kernel issue that is hopefully going to get fixed. Closing here.

See https://github.com/rpm-software-management/rpm/issues/1682 and https://github.com/rpm-software-management/rpm/pull/1740 for reference.


Note You need to log in before you can comment on or make changes to this bug.