is RPM build conditional on build or on install? - redhat

I've already read this thread RPM conditional Requires in spec file possible but I just want to make sure with a yes/no answer.
I have the following in my spec file:
(from https://fedoraproject.org/wiki/Packaging:DistTag)
%if 0%{?rhel} == 6 || 0%{?rhel} == 7
Requires: XXX
%else
Requires: YYY
%endif
Does it mean that when I build the rpm if I'm building on RHEL 6 or 7 then the rpm would require XXX or does it mean that the rpm I have built will require XXX or YYY based on the installation target?
Please be simple in your answer, there is no need of overkill.
Thanks

Build-time. You need to build two different RPMs for the two different distros.

Related

CentOS 7 - how to install dependency using wget in an RPM spec file

I'm trying to write a spec RPM file to build an RPM package.
Here is in essence my spec file:
[...]
Requires: nodejs java-1.8.0-openjdk java-1.8.0-openjdk-devel log4j
%define _rpmdir ../
%define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
%define _unpackaged_files_terminate_build 0
%pre
[Some script]
%post
[Some script]
%preun
[Some script]
%postun
[Some script]
%install
[...]
%files
[...]
I've managed to install the package dependencies with the preamble Requires expect one that doesn't exist as a yum package (tomcat8). I found on the internet that the way to install it on centOS is:
wget https://harbottle.gitlab.io/harbottle-main/7/x86_64/00853071-tomcat8/tomcat8-8.5.37-2.el7.harbottle.x86_64.rpm
rpm -ivh tomcat8-8.5.37-2.el7.harbottle.x86_64.rpm
But where should I put it in the spec file? I tried to put it in the %pre script, but there is a lock on rpm that prevent its use. I tried to put it in the %install part, but it didn't seem right. Can you please help me to fix this problem? Is there a way to still put it in the Requires preamble?
Thanks!
this is not the way you should manage those dependencies. You should search for a way to make this rpm available in you repositories. I see multiple options:
add the harbottle repository:yum-config-manager --add-repo https://harbottle.gitlab.io/harbottle-main/7/x86_64/. Now your yum will be able to find the tomcat8 rpm by itself
If you want to make sure the package remains available; better copy the tomcat8.rpm inside your own repository besides your other rpms.

Error installing perl module (cpan and manually)

I'm trying to install the SQL::Translator module. Everything runs fine until it gets to this test:
DBD::SQLite::db do failed: not an error at t/sqlite-rename-field.t line 62.
# Failed test '-- Convert schema '' to '':;'
# at t/sqlite-rename-field.t line 62.
# died: Died at t/sqlite-rename-field.t line 62.
# Looks like you failed 1 test of 16.
Failed 1/72 test programs. 1/1901 subtests failed.
make: *** [test_dynamic] Error 1
Any help is much appreciated, I was not able to find any similar questions. Thanks.
cpan link: http://search.cpan.org/~ilmari/SQL-Translator-0.11021/lib/SQL/Translator.pm
It could be because of missing dependencies and/or mismatch in version of other perl modules. Try using CPANM to install your desired package. It will take care of dependencies for you.
You can also try to install libsql-translator-perl library if you are on debian based systems. I am sure there will be a compatible library on red hat based systems too.
Also if you want to install from cpan then use CPANM to install the module.
Personally i prefer to use distro libraries in place of installing modules.
In case anyone stumbles across this question, my solution was:
install perlbrew
install latest version of perl via perlbrew
download required libraries
install module
It was much easier than dealing with the older system

Strange behaviour of rpm command on error in %pre section of a rpm package

I've got several versions of some package. The last of it has an error in %pre section that terminates the install script:
mypak-0.0.1-1.el6.noarch.rpm
mypak-0.0.1-2.el6.noarch.rpm
mypak-0.0.1-3.el6.noarch.rpm <-- bad package
All of my packages have debug output in pre, post, preun and postun sections.
I install the first package:
rpm -Uhv mypak-0.0.1-1.el6.noarch.rpm
Output (param is the parameter passed to script sections) is:
Preparing... ########################################### [100%]
pre: 0.0.1-1.el6 ; param = 1
1:mypak ########################################### [100%]
post: 0.0.1-1.el6 ; param = 1
Then I try to update my package and (accidentally) launch rpm command with all the packages at once:
rpm -Uhv mypak-0.0.1-*
warning: package mypak = 0.0.1-1.el6 was already added, replacing with mypak > 0.0.1-2.el6
warning: package mypak = 0.0.1-2.el6 was already added, replacing with mypak > 0.0.1-3.el6
Preparing... ########################################### [100%]
pre: 0.0.1-3.el6 ; param = 2
!!!version 3 is bad!!!
error: %pre(mypak-0.0.1-3.el6.noarch) scriptlet failed, exit status 1
error: install: %pre scriptlet failed (2), skipping mypak-0.0.1-3.el6
preun: 0.0.1-1.el6 ; param = 0
postun: 0.0.1-1.el6 ; param = 0
As you can see, my package was removed in the end. Moreover, the package is removed even if other packages depend on it. I don't even get any warnings about corrupted dependencies!
If I install my packages one after another, I don't have that problem. In this case installation of the third package fails and that's all. The previous version of my package is still in place.
I think this is really a strange behaviour. Is it a bug in rpm or am I missing something?
I use rpm 4.8.0 on Centos 6.5.
RPM will ignore (by substituting newer version) older versions of identically named packages when installing. Either rename some of the packages, or don't install multiple versions of an identically named package in the same transactio
%pre failures when upgrading are tricky. The newer package will not install if %pre fails. and (on upgrade when there is an older version already installed) will remove the already installed package. The best answer here is don't rely on %pre failures in packaging while installing. Instead add Provides:/Requires:
so that the package (and transaction) failure occurs during dependency checking, or design a different means for testing a dynamic property than %pre,
either in configuration, or in documentation, or by renaming and obsoleteing the previous package to get a more reliable packaging.
I wrote about this behaviour to the RPM mailing list and Lubos Kardos answered that this is a bug and now it is fixed.
Mailing list thread: http://lists.rpm.org/pipermail/rpm-list/2015-April/001740.html
Commit: https://github.com/rpm-software-management/rpm/commit/c7fa7b2fd7205b73c833831ab9f8c311f40b2ff1

Installing module with cpan2dist blaims about missing module although it is available

i'd like to install some perl-modules with cpan2dist. Cpan2dist creates rpm's of perl-modules. I'd like to install Data-Dumper:
cpan2dist --format CPANPLUS::Dist::SUSE --verbose --buildprereq Data-Dumper .
Data-Dumper needs Test::More, which is installed:
cpan2dist ...
...
[MSG] 'perl-Test-Simple' is already installed (for Test::More)
...
Perl itself confirms it:
vm58820-6:~ # perl -MTest::More -e 'print "$Test::More::VERSION\n"'
1.001003
But later on cpan2dist complains about an unsatisfied dependency:
error: Failed build dependencies:
perl(Test::More) >= 0.98 is needed by perl-Data-Dumper-2.151-0.x86_64
[ERROR] unsatisfied builddeps!
Cpan2dist does not seem to be sure if Test::More is installed or not. But if it says Test::More is not installed, why doesn't it install the dependency ? The option --buildprereq should do that.
Thanks,
Bernd
SOLVED
Hi,
i found it out by myself. It seems that cpan2dist looks for already installed packages using different ways: the message "perl-Test-Simple' is already installed (for Test::More)" comes from cpan -l or autobundle in cpan, i believe. But cpan2dist also ask the rpm database, when it checks the dependencies. And "Test::More" has been installed with CPAN or it was included in the original perl-Installation. So the module is available for perl, but, because it was not installed with rpm, rpm knows nothing about it.
Bernd

GtkMozEmbed module in PyGtk

I'm working on a soloution that needs the gtkMozembed module for python.
I had installed the pygtk2 and genome-python-* packages.
But still i don't have the gtkmozembed module. Can any one tell me how can i install this module.?
I'm also searching for some good repositories for CentOS so that I can update the latest packages. All the repositories now I have, do not maintain the updated packages.
I use CentOs 6.0.
Before continuing, note that gtkmozembed is deprecated, abandoned by the authors and therefore not packaged in CentOS 6 or Ubuntu Oneiric and later:
https://lists.ubuntu.com/archives/ubuntu-devel/2011-May/033229.html
https://groups.google.com/forum/#!topic/mozilla.dev.embedding/c_NMcO-N8wo/discussion
Therefore any use of gtkmozembed is temporary. You may wish to consider the following alternatives which are available as RPM packages on CentOS 6:
pywebkitgtk : Python Bindings for WebKitGTK+
gnome-python2-gtkhtml2 : Python bindings for interacting with gtkhtml2
I managed to download gnome-python2-extras from CentOS 5 and build it on CentOS 6 with the following commands:
rpm -ivh http://vault.centos.org/5.7/os/SRPMS/gnome-python2-extras-2.14.2-7.el5.src.rpm
# edit ~/rpmbuild/SPECS/gnome-python-extras.spec
# comment out the line starting with %patch1
rpmbuild -ba ~/rpmbuild/SPECS/gnome-python-extras.spec