2

I've been trying to use fpm to create an rpm, but have ran into a problem. After I install the package, there are files I no longer need which are deleted in a post-install script in order to save space. Unfortunately, when the packages in uninstalled, it complains about the files not being there, as they are still registered by the rpm as part of the package. When I looked into how to fix this via the rpm, I stumbled on the %config(missingok) macro which seems ideal. However, it doesn't seem like there is a way to set this via fpm.

My current options for possible solutions are changing the -edit flag from using vi to edit the spec file to using a script by setting the fpm_editor variable, or touching the file in a pre-remove script to try and trick the rpm into thinking these problematic file still exist. Neither of these option are very appealing.

So my question is this: Is there a way to use fpm to either a: remove the package from the "sight" of the rpm post-install, or b: mark the file as noconfig(missingok) via fpm? Without utilizing the two solutions above of course.

1 Answers1

1

The usual way of doing this is rm -f these files at the end of the %install section, instead of doing this in the post-install scriptlet. This way the useless files will not be packaged in the final rpm.

I never packaged an rpm with fpm, but looking at the source code I see the command-line switches --exclude and --exclude-file that should be the ones you're looking for:

  option ["-x", "--exclude"], "EXCLUDE_PATTERN",
    "Exclude paths matching pattern (shell wildcard globs valid here). " \
    "If you have multiple file patterns to exclude, specify this flag " \
    "multiple times.", :attribute_name => :excludes do |val|
    excludes << val
    next excludes
  end # -x / --exclude

  option "--exclude-file", "EXCLUDE_PATH",
    "The path to a file containing a newline-sparated list of "\
    "patterns to exclude from input."
Davide Madrisan
  • 1,969
  • 2
  • 14
  • 22
  • If I understand these options, they exclude the path from the rpm build all together. This is not what I require. It needs to be placed in the build, then removed after the build is complete. Then rpm needs to be ok with the file not existing on removal. I ended up going with the file touching option ultimately, but would be interested to hear other solutions. – EphemeralTile Oct 20 '21 at 18:08
  • So I think there's no solution supported by fpm interactively. Your specfile is already too complex for this tool. Why don't you customize it yourself and run a plain `rpmbuild -ba` for creating the final binary and source rpm packages? – Davide Madrisan Oct 20 '21 at 18:36
  • Another solution may be patching the installation script or makefile to avoid the installation of these unrequired files. The `%install` section will be a standard one and you will be able to use fpm. – Davide Madrisan Oct 20 '21 at 18:43