sbt-native-packager: Set systemd service file to non config - sbt-native-packager

I have sbt-native-packager 1.3.6 and generate rpm packet. In spec file i see:
%config(noreplace) %attr(0644,root,root) /usr/lib/systemd/system/my-app.service
Is there some trick to make it non config?

Related

How to get rpm file path in spec file

I want to copy the installed rpm file to some directory during %post. Like
%post
cp rpm_path %_prefix/rpm/
Is there any way to get rpm file path in spec file?
It is not possible.
However, you can achieve it on the DNF level, by using local plugin. Or writing a similar plugin.
https://github.com/rpm-software-management/dnf-plugins-core/blob/master/plugins/local.py

Modify rpm using rpmrebuild

I have a rpm created for dev environment and CONTAINS a configuration file that points to dev. Now I have to create the rpm for another environment for which I need to replace just one file in the SOURCES folder and update the reference in .spec and rebuild it. Issue is that I don't have the .spec file that I used to create the rpm for dev.
So upon searching, came across rpmrebuild and I was able to see the .spec file in the editor.
When I give rpmrebuild command, the spec file opens in the editor.
Here's the small snippet from the file
/root/rpmbuild/SOURCES /root/rpmbuild/SOURCES
%files
%attr(0755, root, root) "/opt/**{replace/with/newfile/path**}"
But updating that that gives me - File not found: /root/.tmp/rpmrebuild.2345/work/root/opt/{path/to/newfile}
I don't know if I have to use rpmrebuild command with any --params in order to replace the file in the SOURCES and its reference in the .spec. There are no other changes to be made.
Please guide.
Note: I am a unix novice
I presume you do not have the src.rpm for this package. If you do, then it's very easy, simply install that with rpm -ihv /path/to/src/rpm as you would do with any RPM file. The contents, unless specified otherwise, will be extracted to ~/rpmbuild. The spec will be under ~/rpmbuild/SPECS, the sources under ~/rpmbuild/SOURCES, etc.
If you do not have the src.rpm but only the RPM itself, install the rpmrebuild package from the EPEL repos and then:
$ rpmrebuild -e -p /path/to/package
It will open the spec in your default editor. Edit it and save the spec wherever you want.
Then, assuming you have all the needed source files (declared in the spec using the SourceN directives), you can call:
$ rpmbuild -bb /path/to/spec
To rebuild the RPM from the edited spec.

rpm verify - ignore config files

From man rpm
rpm {-V|--verify} [select-options] [verify-options]
Files that have been changed after installation will be listed by this rpm verify command.
But this lists the configuration files also (files that are marked with %config in this spec file.
Is there a way to skip/ignore the verification for the config files?
yes and no:
I don't know any method for ignoring some files with rpm -V
But in your spec file you can add verify attributes for some files to specify how they should be verified.
This way you could specify for example to check only the owner and group of your config file:
%verify(owner group) /path/to/your/config-file
for further reference; look here: http://www.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html

How do I set optional configuration files in an RPM SPEC file?

Is there a way I can flag a configuration file as optional so when verification is invoked (rpm -v), it will ignore a missing configuration file?
I have an RPM package which I include a default configuration file for my application. The configuration file is not required for my application but I'd like to include it for easy configuration purposes. If the file was deleted, the application will work as expected (with some internal defaults). The problem I'm facing is that if I delete my configuration file and then run a verification on my installed RPM, the RPM indicates the package is not in good standing:
rpm -V test-rpm
(outputs)
missing c /etc/test/test.conf
Minimized SPEC definition:
Version: 0.0.1
Name: test-rpm
...
%install
install -m 644 $resource_directory/test.conf %{buildroot}/etc/test/test.conf
...
%files
%defattr(-,root,root)
%config(noreplace) /etc/test/test.conf
...
Is there some option I haven't found yet or am I misunderstanding something about RPMs?
This is what %config(missingok) is for I believe.
The %config(missingok) indicates that the file need not exist on the installed machine. The %config(missingok) is frequently used for files like /etc/rc.d/rc2.d/S55named where the (non-)existence of the symlink is part of the configuration in %post, and the file may need to be removed when this package is removed. This file is not required to exist at either install or uninstall time.

Unable to run logstash config file (permission denied)

my config file is stored in
/etc/logstash/
and I ran the command
$ /etc/logstash -f /etc/logstash/logstash.conf
as root.
However, they told me that permission denied when I tried to do that. Is there any way to solve this?
As said, you need to run /opt/logstash/bin/logstash -f /etc/logstash/logstash.conf instead of /etc/logstash -f /etc/logstash/logstash.conf.
This is caused by the default directory structure of your Linux system which logstash uses to put its files in. Wikipedia: Filesystem Hierarchy Standard
/opt stands for optional and contains third party packages which are not part of the default linux distribution. Therefore logstash puts its binaries and some dependencies there (e.g. jRuby stuff). Here you can find the logstash program /opt/logstash/bin/logstash or the plugin manager /opt/logstash/bin/plugin.
/etc means et cetera and is often used for configuration files (like logstash uses it).
There are also other system folders which are used by logstash. For example /var/log/logstash where you can find logstash's own logs. So, when you run the logstash installation (in Ubuntu perhaps with apt-get or dpkg) it puts all the needed files in folders corresponding to the directory structure of your OS.
As you see, you cannot run /etc/logstash -f /etc/logstash/logstash.conf because /etc/logstash is not an executable but a directory.
However, if you run logstash in a command prompt you may also specify other paths for your config file (e.g. /opt/logstash/bin/logstash -f /home/user/logstash.conf). If you run it as a service you cannot provide a path to your config file. Then the default behaviour of logstash is to look for config files in /etc/logstash/
Just a complement to the accepted answer. Perhaps you could check another two places:
the right absoluate file path provided in your *.conf input;
try to start by sudo bin/logstash -f your_config_file;

Resources