rpmbuild unable to find the custom installed package - perl

There are plenty of perl packages missing in Centos 8 and Rocky Linux. So, I try to get the rpm spec by cpanspec and build rpm by myself. But, it seems like that rpmbuild could not find the rpm I built.
This is the script for me to build rpm.
cd /root/rpmbuild
cpanspec --packer 'Example <example#example.com>' <Perl-Package-Name>
mkdir SOURCES
cp <Perl-Package-Name>.tar.gz SOURCES
rpmbuild -ba perl-<Package-Name>.spec
Let's say we have two package A and B. A is needed by B.
I try to build both of the packages through the script above. I build A first, switch into /root/rpmbuild/RPMS/noarch and install A.rpm. Then, I try to build package B.
I got
error: Failed build dependencies:
perl(A) is needed by perl-<B>
I try to check the existence of package A.
yum list installed | grep A
and
perldoc -l A
Both of the commands show that A exists.
Did I miss something?
update 2022/06/07
I just gave up and commented the BuildRequires: A in B package. This is not a good approach but it works.

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.

Install perl module Net:SSH2 on redhat/centos 7

As the title says I am trying to install the perl module perl-Net-SSH2. I have tried via yum but get an error that no package is available.
yum install perl-Net-SSH2
I have tried by downloading an rpm file but the only one I can find is for el6 and it complains about the version of perl
yum localinstall perl-Net-SSH2-0.45-4.el6.x86_64.rpm
Requires: perl(:MODULE_COMPAT_5.10.1)
I have tried downloading the source code but get told "Unable to find a working version of library ssh2 in the following directories" even though it is installed. (via yum install libssh2 libssh2-devel)
I have tried via cpan but get the same error "Unable to find a working version of library ssh2 in the following directories"
Any ideas? Google is very sketchy on this and only
OK, I solved this while writing the question. Seeing as information on this is limited I thought it would be worth posting the question anyway. The error message was giving the wrong information in that it was actually gcc that was missing, not libssh2. These are the steps I followed. I've tried to make it as verbatim as possible. I have not verified all these modules are required but this is what I installed before compiling it.
yum install libssh2 libssh2-devel
yum install openssl openssl-devel
yum install perl-Net-SSLeay
yum install gcc
Search for Net::SSH2 in google
Click the link "Net::SSH2 - search.cpan.org"
Download source code (tar.gz file)
Copy it to your redhat 7 machine
tar -xvf Net-SSH2-0.62.tar.gz
cd Net-SSH2-x.xx
perl Makefile.PL
make
make install
Should all be working now, test it with
perl -e 'use Net::SSH2;'

How to bundle perl libraries with my cross platform script?

I developped a script in Perl that uses 2 extra libraries, Net::SSH::Perl and Spreadsheet::WriteExcel, which I installed easily using CPAN on my Debian laptop.
Ultimatly, my goal is to deploy this script on a solaris server. However, this server is not connected to internet and thus cannot auto install missing dependencies.
So far, I tried using PP, which allowed me to run this script on another Ubuntu computer without needing to install manually the extra libraries, but returned an error : Cannot find /lib64/ld-linux-x86-64.so.2 on Solaris.
As I suspected this was due to the differences between both architectures, I packed my script with a ./lib folder containing all dependencies (the ./lib was obtained by doing pp -B -p -o script.par myscript.pl and extracting the resulting ./lib folder).
Following the leads I found in this question, I tried with use lib "./lib and with BEGIN { unshift #INC, "lib"; } at the start of my script, but I got an error saying I didn't include my libraries when I ran it.
Is there a way to port those libraries ? Is there another approach ?
Net::SSH::Perl relies upon several XS modules, such as Math::GMP, Math::Pari and others. There's no way around actually compiling them (as in compiling them with C, not Perl) on the Solaris box.
You will also need the underlying C libraries (i.e. libgmp, libpari). The Math::Pari build script will download its library, but you've indicated that's not possible on your target Solaris box.
cpanm can help you download the Perl dependencies in preparation for moving them to your target machine and build them on it.
If you have proper dependency entries in your project's Makefile.PL or cpanfile, running
cpanm --installdeps -L deps --save-dists dists .
on your devel machine in your project directory (note the trailing dot) will download all of its dependencies into the dists directory.
You can then copy that directory to your target Solaris box (along with cpanm) and pass it to cpanm using its --mirror option.
For example, I just did this for Net::SSH::Perl's dependencies:
cpanm --installdeps -L deps --save-dists dists Net::SSH::Perl
It downloaded and installed 34 distributions into deps, saving the archives in dists.
I can build Net::SSH::Perl using the downloaded distributions via:
cpanm --mirror file://${PWD}/dists Net::SSH::Perl
Note that while cpanm is handy, you don't actually need it to install the required modules. You can manually install them (in the correct order) by unpacking them and then running
perl Makefile.PL
make
make install
or
perl Build.PL
./Build
./Build install
as appropriate for the specific module

How to install XML::Parser without expat-devel?

XML::Parser fails to build on a quite fresh 64-bit Debian box. After issuing cpan XML::Parser, cpan fails with lots of errors about Expat.c and Expat.xs:
[...]
Expat.xs:2182: error: ‘CallbackVector’ has no member named ‘skip_until’
Expat.c: In function ‘XS_XML__Parser__Expat_Do_External_Parse’:
Expat.c:2904: error: ‘XML_Parser’ undeclared (first use in this function)
Expat.c:2904: error: expected ‘;’ before ‘parser’
Expat.xs:2194: error: ‘parser’ undeclared (first use in this function)
make[1]: *** [Expat.o] Error 1
make[1]: Leaving directory `/root/.cpan/build/XML-Parser-2.41-rpV6ok/Expat'
make: *** [subdirs] Error 2
TODDR/XML-Parser-2.41.tar.gz
/usr/bin/make -- NOT OK
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible
Message at the start of the output explains that expat-devel is needed for building.
Expat must be installed prior to building XML::Parser and I can't find
it in the standard library directories. Install 'expat-devel' package with your
OS package manager. See 'README'.
But expat-devel is not in Debian repository.
Is it possible to get over this without need to build/install expat from source?
The package you want to install is named libexpat1-dev. You could also just install libxml-parser-perl via apt-get. Or if you really want to install via CPAN try installing the Debian packages dependencies first via apt-get build-dep libxml-parser-perl.
libexpat1-dev contains both libexpat and expat.h, which are both mentioned in the message as well:
If expat is installed, but in a non-standard directory, then use the
following options to Makefile.PL:
EXPATLIBPATH=... To set the directory in which to find libexpat
EXPATINCPATH=... To set the directory in which to find expat.h
Installing libexpat1-dev seems to solve the problem:
$ aptitude install libexpat1-dev
There is always the manual method - to build/install expat from source.
(This example shows installing to an alternative location for XAMPP | LAMPP)
Download from:
http://sourceforge.net/projects/expat/files/expat/
tar zxf /[where-ever]/expat-2.1.0.tar.gz -C /tmp
cd /tmp/expat-2.1.0
/opt/lampp/bin/perl ./configure --prefix=/opt/lampp LDFLAGS=-L/opt/lampp/lib
make
make install
http://search.cpan.org - search for and download - XML::Parser
tar zxf /[where-ever]/XML-Parser-2.41.tar.gz -C /tmp
cd /tmp/XML-Parser-2.41
/opt/lampp/bin/perl ./Makefile.PL EXPATLIBPATH=/opt/lampp/lib EXPATINCPATH=/opt/lampp/include
make
make test
make install
Work like a charm in Ubuntu 15.04. The only thing that I need is install Perl XML Parser with:
sudo apt-get install libxml-parser-perl
And following the instructions here, I was able to import successfully all my ratings into Rhythmbox. Now, the only work that I need to do is create again the smart play lists, that is nothing compared with my entire libray ratings.
Today I had the same issue wanting to complile the new GIMP 2.9.4 beta on OSX 10.8 and the aid of homebrew.
First install perl
brew install perl
Then the XML::Parser module by going into the perl shell with
perl -MCPAN -e shell
And inside the shell install XML::Parser by typing
install XML::Parser
Exit shell
exit
Now, verify it has been installed successfully. If everything is ok, you will not see an error.
perl -e "require XML::Parser"
If the ./configure still fails missing XML::Parser, then intltools is not using the perl you have installed. Looking at the script tells me it does the test with $INTLTOOL_PERL -e "require XML::Parser". Trying a echo $INTLTOOL_PERL gave out nothing, so the magic is to set it with
export $INTLTOOL_PERL=perl
Now run ./configure again.
None of the above methods worked for me. I had the right environment variables setup but they were somehow not picked up by cpanm that I use to install perl modules. Expat was also installed.
Here is what I did to overcome the same problem that OP is reporting.
This is very close to what #LadyBuzz suggested.
Download the XML::Parser from cpan.org
Extract the tarball into directory and descend to it.
Open the Makefile.pl and edit the first lines to actually have the absolute paths to both: EXPATLIBPATH and EXPATINCPATH
Save the Makefile.pl, go up one level and create a new tarball with the Makefile.pl that you just edited.
Execute cpanm on the newly created tarball.
This resulted in successful installation of the module.

Check a list of packages to install with apt-get

I am writing a post-install script for Ubuntu in Perl (same script as seen here). One of the steps is to install a list of packages. The problem is that if apt-get install fails in some of many different ways for any one of the packages the script dies badly. I would like to prevent that from happening.
This happens because of the ways that apt-get install fails for packages that it doesn't like. For example when I try to install a nonsense word (i.e. typed in the wrong package name)
$ sudo apt-get install oblihbyvl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package oblihbyvl
but if instead the package name has been obsoleted (installing handbrake from ppa)
$ sudo apt-get install handbrake
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package handbrake is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'handbrake' has no installation candidate
$ apt-cache search handbrake
handbrake-cli - versatile DVD ripper and video transcoder - command line
handbrake-gtk - versatile DVD ripper and video transcoder - GTK GUI
etc, etc ...
I have tried parsing the results of apt-cache and apt-get -s install to try to catch all possibilities before doing the install, but I seem to keep finding new ways to allow failures to continue to the actual install system command.
My question is, is there some facility either in Perl (e.g. a module, though I would like to avoid installing modules if possible as this is supposed to be the first thing run after a new install of Ubuntu) or apt-* or dpkg that would let me be sure that the packages are all available to be installed before installing and if not fail gracefully in some way that lets the user decide what to do?
N.B. I am doing something along the lines of:
my #list_of_install_candidates = (...);
my #to_install = grep { my $output = qx{ apt-get -s install $_ }; parse_output($output); } #list_of_install_candidates;
system('apt-get', 'install', #to_install);
You might try apt-cache policy. examples:
$ apt-cache policy handbrake
handbrake:
Installed: (none)
Candidate: (none)
Version table:
$ apt-cache policy foo
N: Unable to locate package foo
$ apt-cache policy openbox
openbox:
Installed: 3.4.11.1-1
Candidate: 3.4.11.1-1
Version table:
*** 3.4.11.1-1 0
500 http://mirrors.xmission.com/ubuntu/ maverick/universe i386 Packages
100 /var/lib/dpkg/status
Anything with a non-blank version table should be installable.