jordansissel / fpm

Effing package management! Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.
http://fpm.readthedocs.io/en/latest/
Other
11.17k stars 1.07k forks source link

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 9 months ago

AdwaitLele commented 9 months ago

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 commented 9 months ago

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.