How to check for RedHat (RHEL) minor version in rpm spec file? - rpmbuild

Need to differentiate a package dependency between RHEL 7.2/7.3 v/s RHEL 7.4 and above. There is rhel macro available in rpm spec file but that evaluates to 7 for all RHEL 7.x and 6 for all RHEL 6.x versions.
I can possibly read /etc/redhat-release file and determine the minor version in %pre section but unclear whether that's too late to specify package dependency using Requires directive.
I tried defining a macro that reads /etc/redhat-release file and then using the macro like following
%define rhel_minor_version %(rhel_version_file="/etc/redhat-release";
if [ -f $rhel_version_file ]; then echo $(cat $rhel_version_file |
grep -oP '.*7\.\K([0-9]+)'); else echo 0; fi)
%if 0%{?rhel} == 7
%if 0%{?rhel_minor_version} >= 4
Requires: iperf3
%endif
%endif
However this macro gets evaluated on the system where rpmbuild is invoked to build the rpm package and not the system where the rpm package is installed. So doesn't work.

There is a mechanism to specify weak dependency i.e. optional dependency in rpm spec file. This way if the package is available it’ll be installed else dependency will be ignored.
https://rpm.org/user_doc/dependencies.html
“Recommends” directive appears valid on Fedora but not available on RHEL
https://bugzilla.redhat.com/show_bug.cgi?id=1427674
After much thought I don't think it's possible to differentiate dependencies based on RHEL minor version without shipping different el7 packages for RHEL 7.2/7.3 v/s RHEL 7.4+ which is not an option...

Related

Building glibc from source causes an error

I'm trying to compile glibc (CORRECTION: 2.34, not 2.3.4) on a RedHat system. I get this error while trying to run configure:
*** These critical programs are missing or too old: make compiler
*** Check the INSTALL file for required versions.
I installed the latest version of 'make':
> make --version
GNU Make 4.3
However, even with the latest version of 'make', I still get the same error. What is causing the problem?
glibc's configure prefers gnumake and gmake over make if they are available on the PATH command search path. Chances is that you have gmake binary that is version 3.81.
I think you should make with gcc version 6.5.0,
ct-ng may help you to build glibc. ct-ng http://crosstool-ng.github.io/docs/
1. ct-ng menuconfig
2. ct-ng build
You can choose gcc version at step 1.
As an reminder, glibc-2.34 remove some libs and no longer create like *-2.33.so under dir sysroot/lib/ . link:https://lwn.net/Articles/864920/
I ran into this issue as well and noticed that the config.txt was looking for gmake and found it in /usr/bin/gmake which was strange.
Listing shows that there is a symlink to make.
ls -l /usr/bin/gmake
lrwxrwxrwx. 1 root root 4 Jun 11 18:18 /usr/bin/gmake -> make
I installed make 4.3 in a custom path AND ensured that it was on $PATH but I was still getting the same error. Making a symlink to my custom installed version of make resolved the problem.
ln -s <custom path>/bin/make <custom path>/bin/gmake
Solved this by setting the MAKE variable. When looking in the configure script, it checks against "if test -n "$MAKE"; then", i.e.
MAKE=//make
export MAKE

Getting libevent error when running installing tmux

configure: error: "libevent not found" when installing tmux
I downloaded the tmux tarball and trying to install it. I cannot connect to git on the server i am trying to install. This for a new Red Hat Enterprise Linux Server release 6.5 (Santiago) server.
I am new to Linux and never did installation as a root :)
[tmux-master]# ./configure && make
...
configure: error: "libevent not found"
Can you please suggest me how to get it working?
tmux depends on libevent. If you are using RHEL there is a libevent-devel package you can install.
But I think on RHEL6.5 it is libevent 1.4 which is very old (you normally need 2.x). 1.4 will still work with tmux but you need to make this change in tmux's control.c around line 79:
- line = evbuffer_readln(c->stdin_data, NULL, EVBUFFER_EOL_LF);
+ /* line = evbuffer_readln(c->stdin_data, NULL, EVBUFFER_EOL_LF); */
Another option is to build libevent 2.x yourself but that is probably more complicated for you.
I fixed the issue by using an alias as mentioned in the below link:
https://unix.stackexchange.com/questions/17907/why-cant-gcc-find-libevent-when-building-tmux-from-source/17918
Really, the real answer to this question is installing event2 with yum.
Use the following two commands--one erase, and then install:
sudo yum erase libevent-devel
sudo yum install libevent2-devel
TMUX should work after this.
If you want to keep the older version for consistency sake, you should not use the first (erase) command.

RPM Spec file conditional Requires per distribution AFTER build

I want to build RPM files and I want them to be commonly used and beeing not depending on which distribution is installed.
Now I found a requirement which name is different on RHEL and SLES.
I found this as possible solution:
%if 0%{?suse_version}
Requires: jdk >= 2000:1.8.0_00-fcs, netcat, telnet, at
%else
Requires: jdk >= 2000:1.8.0_00-fcs, nc, telnet, at
%endif
But my problem with is, that it's an if query for the Build process, what I wish to have is depending on the distribution I install, the already build rpm file would solve this.
Because with this solution, I would need to build RPM files for every kind of centos and rhel and sles distribution on all these different OSes while only the name of nc and netcat differ as Required packages.
Any idea how I can do that?
Thanks
rpm-4.13 will solve my issue: http://www.rpm.org/wiki/PackagerDocs/BooleanDependencies
or - requires one of the operands to be fulfilled
Requires: (pkgA >= 3.2 or pkgB)
You cannot do what you are asking at install-time. However, you can require the executable itself, e.g. /bin/netcat and it should work... unless it was part of the great UsrMove...

tinyos make: *** No rule to make target 'telosb'. Stop

I installed tinyos on ubuntu 15.04 following this tutorial: http://tinyos.stanford.edu/tinyos-wiki/index.php/Automatic_installation
My telosb is well detected:
root#liberty:/opt/tinyos-release-tinyos-2_1_2/apps/Blink# motelist
Reference Device Description
---------- ---------------- ---------------------------------------------
FTYP7UJV /dev/ttyUSB0 FTDI MTM-CM5000MSP
My tinyos.env:
root#liberty:/opt/tinyos-release-tinyos-2_1_2# cat tinyos.env
# Here we setup the environment
# variables needed by the tinyos
# make system
export TOSROOT="/opt/tinyos-release-tinyos-2_1_2/"
export TOSDIR="$TOSROOT/tos"
export CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java
export MAKERULES="$TOSROOT/support/make/Makerules"
export PYTHONPATH=$PYTHONPATH:$TOSROOT/support/sdk/python
echo "setting up TinyOS on source path $TOSROOT"
My tos-check-env:
tomski#liberty:~$ tos-check-env
Path:
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
Classpath:
/usr/src/tinyos/support/sdk/java/tinyos.jar
/opt/tinyos-2.1.2/support/sdk/java
/opt/tinyos-2.1.2/support/sdk/java/tinyos.jar
.
/usr/lib/jvm/java-6-openjdk-i386/lib
/usr/lib/jvm/java-6-openjdk-i386/lib
rpms:
/usr/bin/rpm
nesc:
/usr/bin/nescc
Version: nescc: 1.3.4
perl:
/usr/bin/perl
Version: v5.20.2) built for i686-linux-gnu-thread-multi-64int
flex:
bison:
java:
/usr/bin/java
--> WARNING: The JAVA version found first by tos-check-env may not be version 1.4 or version 1.5, one of which is required by TOS. Please ensure that the located Java version is 1.4 or 1.5
graphviz:
/usr/bin/dot
dot - graphviz version 2.38.0 (20140413.2041)
--> WARNING: The graphviz (dot) version found by tos-check-env is not 1.10. Please update your graphviz version if you'd like to use the nescdoc documentation generator.
tos-check-env completed with errors:
--> WARNING: The JAVA version found first by tos-check-env may not be version 1.4 or version 1.5one of which is required by TOS. Please ensure that the located Java version is 1.4 or 1.5
--> WARNING: The graphviz (dot) version found by tos-check-env is not 1.10. Please update your graphviz version if you'd like to use the nescdoc documentation generator.
My java version:
tomski#liberty:~$ java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.15.04.1)
OpenJDK Server VM (build 24.79-b02, mixed mode)
when I compile:
root#liberty:/opt/tinyos-release-tinyos-2_1_2/apps/Blink# make telosb
make: *** No rule to make target 'telosb'. Stop.
I have build-essentials, nescc, gcc, make etc..
Many thanks in advance for your help
perform every task as a super user and the queries will be resolved.
for e.g.:
$ sudo touch tinyos-env
$ sudo nano tinyos-env
perform the copy and change the TOSROOT path accordingly also copy the same file to your ~/.bashrc file and perform every application as a super user
$ sudo su
Though this post is bit too late, the last comment of the thread helped to resolve this query for TinyOS on Ubuntu-15.04 for me recently.
maybe you can do it without the root privileges, but under the user privileges.
then: cd /opt/tinyos-release-tinyos-2_1_2/apps/Blink
then: sudo chmod -R 777 .
then: make telosb
Old post, but the previous answers are not completely clear.
You have to point to that tinyos.env file.
In order to do that, from your home directory:
Open the .bashrc file:
sudo nano .bashrc
On the bottom of your .bashrc file, add the line:
source <path_to_tinyos_folder>/tinyos.env
Of course the file tinyos.env contains the setup enviroment variables.

Rpmbuild subpackage definition causes error in tmp file

I try to create an rpm package with some subpackages.
running the rpmbuild command results in an error when preparing the first subpackage.
This is the result when running rpmbuild -ba specfile:
[root#RHEL510-BUILD SPECS]# rpmbuild -ba kapsch-icinga.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.88616
+ umask 022
+ cd /usr/src/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ -n autoconf
/var/tmp/rpm-tmp.88616: line 27: -n: command not found
error: Bad exit status from /var/tmp/rpm-tmp.88616 (%prep)
I don't see any error in the spec file defined.
As described in the rpm documentation the parameter -n defines that a subpackage will use the name defined without the prefix name of the main package.
My SPEC file:
%define _topdir /usr/src/rpmbuild
Name: my-icinga
Version: 1.0
Release: 1
License: GPLv2
Summary: defined installation of ICINGA and all it's components inclugins plugins
Group: Monitoring
%description
In this package all dependancies for a complete installation for icinga/nagios server and client(s)are included.
Each subpackage can be created separately.
#--------------
# define some global configuration parameters
#--------------
%define _nagiosUser icinga
%define _nagiosGrp icinga
%package -n autoconf
Version: 2.69
Release: 1
License: GPLv2
Source: http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
Summary: autoconf with a version > 2.65
Group: Monitoring
%description -n autoconf
autoconf will be needed with a version > 2.65 to be able to build some additional subpackages
%package -n my-nagios-plugins
Version: 1.0
Release: 1
License: GPLv2
Summary: Plugins from nagios and ConSol for Kapsch ICINGA cient installation
Group: Monitoring
%description -n my-nagios-plugins
These package includes the standard nagios plugins as well als ConSol plugins check_oracle_health and check_logfiles
#-----------------------------------------------------------------------------------------------
# Build area
# here starts the build section for each subpackage
#-----------------------------------------------------------------------------------------------
%prep -n autoconf
%setup -n autoconf
%build -n autoconf
./configure
./make
#%%prep my-nagios-plugins
#%%setup my-nagios-plugins
#
#%%build my-nagios-plugins
##first build the standard nagios plugins
#cd nagios-plugins-2.0.3
#./configure
#./make
Any hint what's wrong with my SPEC file?
I know that the SPEC file is not complete but the missing parts should not be the cause of the error.
Don't override %_topdir in your spec file. %_topdir
is expanded before the spec file is parsed.
Instead, configure in ~/.rpmmacros
As the error message says, %prep does not take -n as an argument.
There are parts of the spec that are common to all subpackages
There are other underlying issues with your spec file:
If you need autoconf to build packages, you need to install it BEFORE your rpm, typically defining it as a dependency.
Also, I maintain a similar .spec to install icinga and all its dependencies; a very good piece of advice here is the old "KISS" (keep it simple st ...). Make tiny rpms for individual plugins or groups of plugins and create a metapackage that has all of them as dependecy.
Also I advise you to install your custom nagios-plugins to a different location that nagios-plugin:
EG: on centos nagios-plugins install at: /usr/lib/nagios/plugins
our custom built nagios-plugins are installed at: /usr/lib/nagios/plugins/mycompany
NOTE: nagios-plugins from git pulls its own spec file, that can be easily modified to be used with your custom plugins

Resources