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
Related
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.
Can someone please list out the directories where the Apache RPM install files.
I searched over Internet but was not able to find any proper solution
You can use the query files list option of rpm command to find out the directory.
If you have installed the package
rpm -ql <package-name>
and if you have the rpm file
rpm -qlp <package-name>.rpm
You will get something like this(the sample is for httpd)
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf/extra/httpd-autoindex.conf
/etc/httpd/conf/extra/httpd-dav.conf
/etc/httpd/conf/extra/httpd-default.conf
/etc/httpd/conf/extra/httpd-info.conf
/etc/httpd/conf/extra/httpd-languages.conf
//
//Output truncated
The sample output shows /etc/httpd is a folder that httpd creates/installs to
Add the very verbose flag to the rpm command line to see all it does. E.g.:
rpm -Ivv <packagefile.rpm>
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.
Is it possible to keep RPM content in the filesystem after the uninstallation ?
Basically, I don't want to erase the files generated by the RPM when someone runs rpm -e, but still remove the package from the list of installed RPMs. I want to uninstall my application manually from the server and I cannot find a way to do so.
Thanks in advance.
Specfile creation
From this perspective as a package creator, you can flag files as configurations. John Warbrick at Cambridge Uni has a good rundown of the different file markings you can use in an RPM specfile and how they behave during upgrade.
Files marked %config, if changed, are:
left behind on uninstall but renamed with an .rpmsave extension
untouched on update or reinstall, but the payload copy is installed with an .rpmnew extension
Warbrick does not deal with straight package removal: if a file marked %config is unchanged, erasing the package will remove the file. (Bear in mind that, according to RPM scriptlet ordering, RPM update or reinstall begins with erasing the old package, before the new files are lain down. I.e., the old unchanged config is replaced with the new config.)
It would be an abuse of RPM file classification to mark something a %config that is not really a config. This is important because sysadmins need to be able to trust the package payload. Plus, you probably don't want such a file to be renamed with an extension.
Your best hope then is to create the file during RPM %post. Files copied to the filesystem in %install are checked against the %files list and stored in the RPM database, but files created in %post are not. Again, this an abuse of the RPM spec file format, but if you mention it in the %description and any other documentation, but especially if it's logically expected behavior in the context of your package, you'll maybe get some sympathy.
Existing packages
For sysadmins wanting to remove a package without removing its payload, you use rpm --justdb. First, check the file list:
# rpm -ql $PACKAGE | tee $PACKAGE.payload
[rpm returns list of files, tee saves it in the file $PACKAGE.payload]
# rpm -e --justdb $PACKAGE
(At this stage, you may get a complaint about deps, so repeat with --nodeps if you must.)
And finally, check that the package is gone, but payload is still there:
# rpm -q $PACKAGE
package $PACKAGE is not installed
# ls -l $(<$PACKAGE.payload)
[ls queries list of files saved in $PACKAGE.payload]
(Or for a more reliable ls if filenames contain spaces, which would be unconscionable in RPM.)
# cat $PACKAGE.payload|xargs -d '\n' ls -l
Other observations
Note that for a package created using the method outlined at the top of my answer, attempting to list the files it owns with rpm -ql $PACKAGE will not show those persistent files. Another consequence of throwing down files during %post is that another package which "owns" those files could overwrite them unexpectedly - they're not listed in the RPM database, so they're not protected.
The two methods I've outlined break Best Practices for both RPM package creation and sysadmin. Please be very careful how you use this dangerous "little bit of knowledge". Maybe there's something else you could do to create the desired situation.
(Finally, I know this is a question from four year back. It wasn't answered. It needed answering. Cheers.)
rpm -e --repackage package_name will drop a re-installable copy in /var/spool/repackage. You can extract from that rpm using rpm2cpio if you need those files back individually.
One of the advantages of RPMS is exactly that: you can uninstall (remove)
all the files easily.
If you want to install the files provided by an RPM manually,
simply unpack the RPM as root, with:
cd / &&
rpm2cpio *.rpm | cpio -idmv
It's not a good idea, but you can unpack RPMS like that elsewhere (e.g. under ${HOME}),
and that's very useful. You may need to adjust some environment variables though.
You don't pollute the RPM database but still use the contents of an RPM.
Of course your application may get broken by system updates,
because it is not protected by dependencies.
Anyway this is how you "install" and RPM if you are not root.
Removal is also easy (if installation path chosen suitably).
I want to deliver an rpm but the number of files to be delivered is very big.
Do I have to specify each file in the spec under %files section or can I just define the top level folder so that they can be inluded recursively?
If you include the top-level folder, all its files will be included as well. If you don't want the rpm to own the top-level folder, you can also use top-level-folder/*