RPM upgrade skips file - linux

I have a rpm which installs .war file to /opt/myLocation/. This file is used by tomcat - it simply unzips it and moves the unzipped files to different location.
I want to make a rpm upgrade with rpm -U myPackage.rpm but it does not overwrite the file inside /opt/myLocation'
I used -vv to have a view what's going on and here is the problem:
D: fini 100644 1 ( 496, 492) 13245703 /opt/myLocation/myFile.war skip
I tried rpm -U --force -F but no luck.
Any idea what might be happening here?

Related

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.

Getting folder conflicts when running yum groupupdate inside a chroot environment

I have a chroot environment where i am getting folder conflicts when I am running the below command.
/usr/bin/yum --verbose --assumeyes --installroot /home/prateek/project/.ova_work_dir/mnt/dst_root --config=/home/prateek/project/.ova_work_dir/mnt/dst_root/etc/yum.repos.d/project-upgrade.repo --obsoletes groupupdate '*' project
Below is the error
Running transaction test
Transaction check error:
file /usr from install of messagebus_c-1.0.0-0.x86_64 conflicts with file from package filesystem-3.2-20.el7.x86_64
I have below two questions to ask:
1) Why i am getting folder conflict when yum is running transaction test as I have seen file conflicts but not folder conflicts.
2) How would I resolve this folder conflicts.
The messagebus_c RPM specfile needs to be edited to not "own" /usr but instead all the files in it, e.g. /usr/*.
Can you try this ?
/usr/bin/yum --verbose --assumeyes --installroot=/home/prateek/project/.ova_work_dir/mnt/dst_root --config=/home/prateek/project/.ova_work_dir/mnt/dst_root/etc/yum.repos.d/project-upgrade.repo --obsoletes groupupdate '*' project
issue was
missing equal to sign --installroot /home
expected like this --installroot=/home
This can happen when messagebus_c spec file has:
%install
touch %{buildroot}/usr
%files
/usr
I.e. here the /usr is a file. While filesystem provides it as a directory. You cannot have both. A directory cannot be a file. And vice versa.

How to run a bash script that installs rpms from a current rpm spec file?

I have this internal software installer that has a size > 4.9GBs,
it installs a bunch of rpms/libraries and set some configs at the end.
I need to create a RPM using rpmbuild(Im new to this rpm creation) in order to install the RPM and also proceed to install/execute this installer(its a bash file).
My rpm spec is currently doing this at (you can check the code below):
%install
Copy 2 zips files into a specific folder.
This are 2 zip files from the actual software folder, I just splitted its
content in 2 parts and zip them to avoid the max size limitations(4gbs if Im
not wrong).
%post
Unzip those files into a specific folder.
run the bash script installer that was inside those zip files (it will run silently because a -s flag that it has).
Complete the bash and rpm installation successfully.
I had alredy built the rpm, so when I try to:
yum install .rpm,
it does the zip part just fine but it stays forever doing nothing at the bash installation part, maybe because this rpm lock thing, but I'm not sure.
By the way, Im not sure at all if this is a good approach for this at the end, I mean combined this rpm and installation stuff
So because the install.sh part is giving me this issues I tried this different changes:
sudo /root/sotfware/install.sh -silent /root/software/silent_configfile.conf
/root/sotfware/install.sh -silent /root/software/silent_configfile.conf
./root/sotfware/install.sh -silent /root/software/silent_configfile.conf
What do you guys thisnk I'm doing wrong?,
Whats the best way to do this? or
Whats you recommendation for this?
This is the spec file:
Name: software-19
Version: 1.0
Release: 1
Summary: software 2019
License: N/A
URL: https://
AutoReqProv: no
AutoReq: no
%description
Some description
%install
mkdir -p %{buildroot}/root/software2019
cp /root/software/software-1.zip %{buildroot}/root/software2019/software-1.zip
cp /root/software/software-2.zip %{buildroot}/root/software2019/software-2.zip
%post
unzip /root/software/software-1.zip -d /root/software2019/
unzip /root/software/software-2.zip -d /root/software2019/rpm/
sudo /root/software/install.sh -s /root/software2019/silent_configfile.conf
rm -rf /root/software/
%clean
rm -rf %{buildroot}
%files
/root/software/*
%changelog
* Tue Jan 20 2019 1.0
- Initial release
Hopefully Im been clear, thanks in advance!
You have multiple issues here
You are building RPMs as root, which is dangerous and can wipe your machine if you don't write things correctly. Since you're just getting started, this is much more likely.
The source files shouldn't have absolute paths.
You shouldn't use sudo because RPM installation is always run as root.
silent_configfile.conf wasn't included in the RPM, so the target machine might not have it.
The %post deletes the files that you told RPM you would install, likely causing errors.
This would also break rpm -V verification.
You are misusing the RPM system by doing a third-party install in your %post.
This breaks things like rpm -q --whatprovides /root/software19/myfile.
This breaks rpm -V because it cannot verify the files you installed.
This breaks any concept of uninstall / upgrade because you don't provide %preun and related files to "do the right thing."
To do things right and not cause your admins headaches for years to come, you need to have those installers run during RPM creation (again, not as root!) with a target of %{buildroot} and then distributing the resulting file structure as an RPM. If this is not something that can be done, then RPM is probably not going to work for you and you need to look at other distribution options, like custom scripts.

Keep files generated by RPM after rerunning rpm -e

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).

How to delete some extra folder using rpm

I am using Fedora 10, I have created an rpm file for my software. It removes all the files from the installed directory. If i use yum remove command or rpm -e command. but after installation my application automatically creates some extra folders in home directory. If I uninstall my application then file from home directories do not get removed. So what I have to do. Is there anything that I have to write in my spec file?
You need to create a post-uninstall script inside your rpm.
The %postun Script
The %postun script executes after the package has been removed. It is the last chance for a package to clean up after itself. Quite often, %postun scripts are used to run ldconfig to remove newly erased shared libraries from ld.so.cache.
See: Maximum RPM: Taking the Red Hat Package Manager to the Limit

Resources