Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpm: Escape { and } characters in filenames #2088

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

jordansissel
Copy link
Owner

  • Add test coverage for escaping { and } filename characters

Fixes #2087

* Add test coverage for escaping { and } filename characters

Fixes #2087
@jordansissel
Copy link
Owner Author

Looks like this fails on the Github ubuntu-22.04 runner, but I'm not sure how to debug further as I cannot find the actual image Github uses published anywhere. There's tooling to build all the images, but the instructions appear to require Azure which I do not have resources to use.

Tests pass locally for me, but I'm on macOS with rpm v4.19.1.1. The Github actions documentation claims that the Ubuntu 22.04 image includes rpm 4.17.0

I don't know anything more about the failure at this time. I won't merge until I understand that problem.

@jordansissel
Copy link
Owner Author

I'm unable to find a way to use Github Actions images, so I tried to reproduce this outside.

Best I can tell, rpm v4.19 works, but v4.17 does not.

I tested manually with this rpm spec:

Name: test
Version: 1.0
Release: 1
Summary: Nope
License: Nope

%description
none

%prep
# noop
%build
# noop
%install
cp -R . %{buildroot}

%clean
# noop

%files
/[\{][\{]?label?[\}][\}].text
  • ✅ On macOS and rpm v4.19, this builds an rpm successfully.
  • ❌ On Ubuntu 22.04 and rpm v4.17, this fails.
  • ❌ On Ubuntu 24.04 and rpm v4.18, this fails.

Looking at the rpm release notes, I found this excerpt:

Improve shell-like globbing and escaping in %files (#1749)

This refers to rpm-software-management/rpm#1749 which seems pretty relevant.

Times like these remind me that maybe #54 would be a nice improvement.

I did a bit of testing and learned a few small things:

  • This PR only works on RPM v4.19 or newer
  • When buliding RPMs on RPM v4.18 or older, fpm will fail because rpmbuild errors.
  • All GitHub Action images use versions of RPM that are too old, so all the test machines will fail.
  • RPMs built on rpm v4.19 with these weird files will correctly install on RPM v4.18 and older!

They install fine on rpm v4.18 and older:

root@efed807b289b:/rpmbuild/RPMS/aarch64# rpm --version
RPM version 4.18.2
root@efed807b289b:/rpmbuild/RPMS/aarch64# rpm -qp test-1.0-1.aarch64.rpm -l
/{{ label }}.text
root@efed807b289b:/rpmbuild/RPMS/aarch64# rpm -Uvh test-1.0-1.aarch64.rpm
...
root@efed807b289b:/rpmbuild/RPMS/aarch64# ls /\{\{\ label\ \}\}.text
'/{{ label }}.text'

@jordansissel
Copy link
Owner Author

I think I can make this specific test skip if rpmbuild is older than rpm v4.19

@jordansissel jordansissel changed the title Escape { and } characters in filenames rpm: Escape { and } characters in filenames Dec 20, 2024
RPM 4.19 added some changes to make it easier or at least more
consistent to escape 'unusual' filename characters. However, RPM v4.18
and earlier do not benefit from this change, so I'm hoping that
replacing {} with ? (wild-card single) characters will work on those
versions. It works fine on v4.19.
@jordansissel
Copy link
Owner Author

Escaping { with [\{] builds fine with rpm v4.19, but fails on anything older. I'm gonna try replacing { with ?. If this works, maybe fpm can query the version of rpmbuild and use the best escaping method available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An issue with fpm 1.16 in OL8 not reading the special character in dir name
1 participant