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

How to get RPM to place all files from a local folder inside a specific folder when installed (without including the local folder itself) #2050

Open
AdwaitLele opened this issue Feb 22, 2024 · 1 comment

Comments

@AdwaitLele
Copy link

AdwaitLele commented Feb 22, 2024

I have a use case where I want an RPM to put a bunch of files from a folder (called files/) into /usr/share/pki/ca-trust-source/anchors/.

I know I can individually list out each file in the fpm command but that makes the command very long for a large number of files and I have to write some basic bash code to generate a string to append onto the fpm command.

I also know I can point to the whole files/ folder, but then the folder itself gets put into /usr/share/pki/ca-trust-source/anchors/. I want the files within the folder to be put there, but not the folder itself.

I can't seem to specify a wildcard to do this, like below, for example:
fpm -s dir -t rpm -n files -a amd64 files/*=/usr/share/pki/ca-trust-source/anchors/
In the above case I get an error saying files/* is not found.

My current workaround is to have the RPM "install" the files by putting the whole files folder in /tmp and then running a postinstall script that moves them to /usr/share/pki/ca-trust-source/anchors/ and then deletes the /tmp/files folder. This isn't ideal though because the files are listed with a /tmp/files/ prefix in the %files section in the RPM spec. This means that for an uninstall/remove, I have to add a postuninstall/postremove script that goes through this %files list, removes the /tmp/files/ prefix, prepends the actual full path of the files, and deletes them. This all works but feels a little hacky...

@AdwaitLele
Copy link
Author

Update: I have a workaround by using mkdir --parents to create the full path for where the files need to be installed by the RPM, but within the /tmp folder. Then I copy files/* into this folder. And then I pass $(find /tmp/usr/share/pki/ca-trust-source/anchors/* | cut -d '/' -f3-) to the fpm command with the --chdir /tmp flag.

This works so that the %files section in the RPM spec has the files listed with their actual paths, and uninstalling/removing works as expected. But it would still be good to know if there was a way to just add a * after a folder name and point it to another installation location (using the = operator in fpm), so that you don't have to create a directory structure temporarily.

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

No branches or pull requests

1 participant