rpmbuild differences in RHEL 5.7 and RHEL 6.1 - rhel

I'm trying to build an RPM using rpmbuild, which would work for both RHEL 5.7 machines and RHEL 6.1 machines, and I'm having some trouble understanding how to structure my rpmbuild/SOURCE directory.
According to what I understood, if my package name is XXX, than I need to prepare rpmbuild/SOURCE/XXX.tar.gz, a tarball which contains:
1. A directory named XXX;
2. In it, all the directories and files I'm installing should be ordered as if their paths are relative to the root directory (i.e. /)
For instance, if I want to install a file called foo.sh to /tmp/XXXdir/, I need to have rpmbuild/SOURCE/XXX.tar.gz contain XXX/tpm/xxxdir/foo.sh
This is what I understood and this is what works when I install my RPM on my RHEL 5.7 machine (i.e. in the example above the file is installaed to /tmp/XXXdir/foo.sh).
However, on an RHEL 6.1 machine I get the undesired behaviour of having my files installed to a newly created /XXX directory, and from there I get the same tree structure I wanted for / (i.e. in the example above I get the file at /XXX/tmp/XXXdir/foo.sh).
Any idea why this happenes? Perhaps I've got it wrong and my rpmbuild/SOURCE structure is not as it should be? Any insights would be very helpful.
Thanks a lot in advance,
Lior

Related

Simple guide for installing Eclipse multi-user on Linux

Is there a simple guide available anywhere on how to install a recent version of Eclipse on Linux as a "normal" application?
The version in the Debian repositories, even for Debian 9, is a 3.X version of Eclipse, which must be very old, as they are now at V4.7.
The default method for the "eclipse.org" versions to install themselves is to put everything in the home directory, which is not a great approach for a system where the home directory is supposed to only contain user data (e.g. the whole home directory is backed up daily)
I can't believe that something so widely used does not have any good instructions for how to install it as a normal application would be - where all the application files are in a shared folder under /opt, and only user data is stored in the home folder.
I have found this thread, which may be promising:
https://www.eclipse.org/forums/index.php/t/1080525/
And a previous question seemed reasonably good, but on trying to follow it, the installer screens have changed, and everything about "bundle pools" became very confusing!
https://askubuntu.com/questions/695382/how-to-install-eclipse-using-its-installer
Not sure if you are still looking for an answer. This is how I have been doing for a few years now.
Download it from website and extract eclipse folder under /opt
Change ownership of the folder to your user and make it readonly recursively.
Create a desktop file to launch it as a regular user.
You can make the folder writable once in a month to make sure latest updates are installed then make the folder readonly again.
TL;DR give up now
I found this when Googling for how to do a multi-user install on Linux Mint 20.
Although Eclipse publish specific documentation on how to do a multi-user installation this little correlation with the current reality.
I first tried installing the package version of Eclipse. That installed the flatpak package, not a native package. It turns out that flatpak has a bug (opened in 2017) whereby it creates a new image each time you run the binary - and at 1.2G that was eating my enterprise storage very quickly. Although the package installed from the command line use apt it did not add any record to the installed package list - so I couldn't uninstall it with apt (using flatpak uninstall eclipse seems to have worked).
I then downloaded the tarball eclipse.
This has a GUI installer which would not run via [x]sudo - so I had to subvert the usual security model on Mint/Ubuntu and make the root user a logon account.
I specified the install location as /usr/local/eclipse. The installer did its thing. Sadly it did not provision a menu entry for the program. Since it actually installs in a sub-directory of the target named with versioning information (/usr/local/eclipse/jee-2019/12/) I created a shell script in /usr/local/bin/ to point to the binary (so when I upgrade, I just need to change the shell script to point to the new location). I then created a .desktop entry to run the shell script and ran:
xdg-desktop-menu install --novendor eclipse.desktop
I also copied the eclipse.desktop file to /etc/skel/Desktop and to /root/Desktop
From my root session, opening the .desktop file by double clicking, or running the shell script started eclipse.
Sadly, this did not create a start menu entry (it has worked for me with other applications).
Logging on a different user, copying the .desktop file to ~/Desktop and running it resulted in....
(Of course it would have been far too easy to display the failure reason in the dialog, or even put the path to the log file in a widget where I could copy and paste it)
Looking at /usr/local/eclipse/jee-2019/12//eclipse.ini, I find this:
-startup
plugins/org.eclipse.equinox.launcher_1.5.600.v20191014-2022.jar
--launcher.library
/root/.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.1100.v20190907-0426
-product
org.eclipse.epp.package.jee.product
-showsplash
/root/.p2/pool/plugins/org.eclipse.epp.package.common_4.14.0.20191212-1200
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
/usr/lib/jvm/java-11-openjdk-amd64/bin
-vmargs
-Dosgi.requiredJavaVersion=1.8
-Dosgi.instance.area.default=#user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=1.8
-Dosgi.dataAreaRequiresExplicitInit=true
-Xms256m
-Xmx1024m
--add-modules=ALL-SYSTEM
-Declipse.p2.max.threads=10
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
There is a whole catalog of issues here.
I replaced the relative path for -startup with an absolute one, copied /root/.p2/pool to /usr/local/eclipse/pool and updated the -startup and -showsplash entries in the file.
I got a whole new error message:
!SESSION Fri Feb 19 11:11:27 GMT 2021 ------------------------------------------
!ENTRY org.eclipse.equinox.launcher 4 0 2021-02-19 11:11:27.893
!MESSAGE Could not find extension: reference:file:org.eclipse.osgi.compatibility.state_1.1.600.v20190814-1451.jar
!ENTRY org.eclipse.equinox.launcher 4 0 2021-02-19 11:11:28.070
!MESSAGE Exception launching the Eclipse Platform:
!STACK
java.lang.ClassNotFoundException: org.eclipse.core.runtime.adaptor.EclipseStarter
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
...
I get exactly the same error after converting the Fedora 33 RPM to a .deb and installing that.
I'm going to go check the price of intellij licences.

Trying to make Host sFlow for XenServer 7.0

I spent all day trying to make Host sFlow 2.0.6-1 from sources (https://github.com/sflow/host-sflow/releases) for XenServer 7.0 using the XenServer DDK from this site: http://xenserver.org/overview-xenserver-open-source-virtualization/download.html
First I had to make 2 changes to the file hsflowd-xen.spec:
Changed line 3 to: "Version: 2.0.6" (it was still 2.0.1)
Changed line 20 to: "%setup -n hsflowd-2.0.6-1" (added the name because the default one was wrong).
Now my problem is that I dont have the xenstore.h file. After long searches I found that it's in the package libxen-dev (or libxen-devel) but I couldn't find it with its dependecies anywhere.
The four most probable solutions I think are :
1. (The lazy one) Get the iso file for Host sFlow already built for XenServer 7.0 (the official site stopped building at 6.5)
Set up a proper yum repository that will contain libxen-dev and its dependencies. I can't even connect to the official CentOS repositories because the files in /etc/yum.repos.d/ have a bad URL.
This is the content of /etc/centos-release: "XenServer DDK release 7.0.0-125770c (xenenterprise)"
Somehow manage to use 'xenstore.a' instead of 'xenstore.h'. I changed the code in src/Linux/mod_xen.c to include 'xenstore.a' instead of 'xenstore.h' but when I build it, it creates a new file with the old code and ignores my changes. I probably changed the wrong files because there are different copies of the whole code. I'm not even sure it would work though even if I did manage to include 'xenstore.a'.
Make xenstore from sources. I didn't try it because I only found old sources and I figured I'd miss the dependencies too.
PS: I'm n00b at CentOS and Makefiles in general so the solution might be obvious and I just don't know it.
With gratitude to lagange, I updated the host-sflow project with a XenServer 7 build. I also added a Docker recipe so you can replace all these steps with just "./docker_build_on xenserver". Please raise issues on https://github.com/sflow/host-sflow.
I finally succeeded in building it. That's what I had to do step by step:
Import the XenServer DDK 7.0.0 into XenCenter.
Extend xvda1 following these steps: https://support.citrix.com/article/CTX125405
Make these changes to hsflowd-xen.spec:
3rd line: Version: 2.0.6
20th line: %setup -n hsflowd-2.0.6-1
Add these two lines before %description:
%define debug_package %{nil}
%define _unpackaged_files_terminate_build 0
Change file /etc/yum.repos.d/CentOS-Base
Change all occurrences of "$releasever" to "7".
Change all occurrences of "$basearch" to "x86_64".
Change "enabled=0" to "enabled=1" for each repository.
Uncomment baseurl lines for each repository.
Mount the Development packages (binpkg.iso available on the xenserver.org download page) and add a file for it in /etc/yum.repos.d/
Mine looks like it:
[binpkg]
name=CitrixXenServer7
enabled=1
baseurl=file:///mnt/binpkg/
gpgcheck=0
Install the two following packages with Yum (dependencies should install correctly now):
xen-libs-devel.x86_64
xen-dom0-libs-devel.x86_64
Make the file and install it using this tutorial: https://raw.githubusercontent.com/sflow/host-sflow/v2.0.4/INSTALL.XenServer

RPM create a trigger that will use version information from the new (triggering) RPM

A little background - Since Redhat stopped updating gcc versions for RHEL6, we had to implement our own gcc5 deployment.
We can't upgrade to RHEL7 at this time, nor will it solve this problem as Redhat hadn't deployed gcc5 for rhel7 yet.
Our current issue is with /usr/src/kernels/$(uname -r)/include/linux/compiler-gcc5.h
That path and the compiler-gcc*.h files are owned by kernel-devel, and a gcc5 one exists only for fedora (only for distros where gcc5 has been introduced officialy).
I can easily create an rpm that will own the file (the reason is mainly so we will receive a conflict if RH ever deploys kerenl-devel with that file, so we can stop deploying our own) for the current kernel, but I'd like to use %triggerin to copy the file to any new kernel-devel installed on the system.
using uname -r wouldn't work for 2 reasons:
it's evaluated at rpmbuild time, not install time.
it evaluates the current running kernel, not the future one just installed.
I can overcome 1 by using a %post script, I think, but can't figure out how to overcome 2, nor how to own the file by my rpm in it's final location (can I %ghost a path I don't know in advance, or use something like dkms?)
Is there a way to know the exact version of the rpm that triggers the %triggerin and incorporate it into the path?
Is there an alternate solution?

How to get the COBRA toolbox working with proper SBML support under MATLAB in linux (such as Ubuntu 14.04)?

Consider these 4 pieces of software:
COBRA 2.05
LibSBML 5.10
MATLAB R2013a (Also known as 8.1, 64-bit; MATLAB no longer supports 32-bit Linux anyway)
A 64-bit Linux OS (such as Ubuntu 14.04 or the latest Mint but not restricted to them)
Intro
The COBRA toolbox is an optimization suite that runs on top of MATLAB aimed at the development of MATLAB code for metabolic network modelling. Such a "network" is a system of equations that can have a very large number of equations and variables (such as thousands). Therefore, routines to read and write those large models according to some format specification are a must-have, and COBRA uses the standard SBML for that.
Problem
Unlike the Windows versions, the Linux binary packages do not integrate well out-of-the-box: to begin with, the pre-compiled Linux binary of libSBML (open-source) available for download does not come with MATLAB support. If one tries to use the pre-compiled libSBML, COBRA won't find the "MATLAB bindings" and therefore won't be able to, for example, read and write SBML XML files from the disk in a m-script.
The question
What needs to be done to make COBRA 2.05 running on top of MATLAB R2013a under Linux (Ubuntu 14.04 or the latest Mint, but this is not likely distro-specific) able to read and write SBML XML files? In other words, what needs to be done system-wide to make COBRA pass its own testSBML test?
This is how I got it working and what I could learn from all the hassle regarding how my Linux box works. I hope I am not forgetting/missing/mistaking anything.
1. MATLAB
1.1. Install MATLAB
Install it in its default location (you will need root access for this), don't be stubborn like I tried to be. Why:
1.1.1. Integration
It is very likely you will want to install some other software that uses the MATLAB framework at some point, and in the real world software doesn't always find other software even if you know how to tell it where to look for.
1.1.2. Make your life easier
Even though it seems like a good idea to install a big software in a place where you have lots of available space and that you can use in multiple machines (specially in Linux, which doesn't have that abomination called Registry, and has symbolic links), that would only perhaps be a good idea - apart from item 1.1.1 - if that place is a partition with a Linux filesystem, since at some point, some executable/script will need execution permission, and mounting the entire partition with execution permission for all its files is rather unsafe. Therefore, do not put MATLAB in an NTFS partition of an external HD; perhaps creating a Linux partition in the external HD just for Linux-specific stuff could work for this matter, but how much hassle is that?
1.2. Setup MATLAB so people and other software can launch it
Even though I have seen somewhere that the MATLAB installer eventually shows an option to create symbolic links in the system path for convenience, it didn't in my case. But that is OK, since I would have to replace the symbolic link /usr/local/bin/matlab by the following shell-script (same path, same filename) anyway:
#!/bin/sh
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
exec /usr/local/MATLAB/R2013a/bin/matlab $*
OBS: That LD_LIBRARY_PATH is needed for MATLAB to find SBML bindings later and to be able to use them. Also, if you install some third-party solver such as TOMLAB, you will most likely need to add some more paths in this little launcher script.
OBS 2: In my case, the installation script didn't automatically create any launchers or shortcuts, but I have found an iconless and extension-less Matlab 8.01 file and a matlab icon as a png file, and that first file was a template .desktop file that I could edit to fit my needs and put in /usr/share/applications so the Unity Dash would find it. The contents of this Matlab.desktop file are:
[Desktop Entry]
Type=Application
Icon=/usr/local/MATLAB/R2013a/Matlab.png
Name=Matlab 8.01
Comment="Start Matlab 8.01"
Exec=/usr/local/MATLAB/R2013a/bin/matlab -desktop
Categories=Development;
Name=Matlab 8.01
GenericName=Matlab 8.01
Comment="Start Matlab 8.01"
2. libSBML
2.1. Install libSBML
libSBML is provided by a deb package specific for Ubuntu (and for CentOS), and also versions for several flavours of Windows and MacOSX (their home page: http://sbml.org/Software/libSBML). Guess which is the only platform whose binaries weren't compiled with MATLAB support? Linux, of course. That means you will need to compile from source (and that the deb package is therefore useless to you). To compile:
2.1.1. Install dependencies
The dependency libxml2-dev (from software manager or from a terminal):
sudo apt-get install libxml2-dev
2.1.2. Save yourself some time in the future
Usually, one would do configure, make and then make install. But this is not recommended for the same reason as installing anything that doesn't come in a pretty little package: you will loose control of which files went where, and will need to keep the source-code to be able to run make uninstall if you need to uninstall it later. So, install checkinstall and use it to replace the step make install, since checkinstall creates a package for your system that can be later uninstalled or reinstalled just as any regular packaged software (from software manager or from a terminal):
sudo apt-get install checkinstall
2.1.3. Configure the compiling-process
Get LibSBML source code and extract it to some folder. From a terminal, navigate to that folder and configure the compilation:
./configure --with-matlab
OBS: with the with-matlab flag, the configure script will fail it it cannot find an executable whose filename is matlab. If it fails, it outputs that the matlab file could not be found, but the test it performs is actually both for the existence of the file and whether it is executable. So, if the file is in an NTFS partition, configure will fail even if it finds the file, but will tell you the file couldn't be found. You can enforce it to look for the executable in /path/to/matlab/root by passing (it will look for a bin folder inside that path, and for the executable inside that bin folder):
./configure --with-matlab=/path/to/matlab/root
OBS: This will install libSBML in the default location: /usr/local/lib. Again, it is a good idea to just let it install in its default location, but if you need to change it, you can pass the path with the flag: --prefix=/your/installation/path
OBS 2: You might ask why libSBML needs to find and execute matlab to be compiled with support for it: it needs to fire up MATLAB later to build MEX-files (compiled MATLAB code), so I would speculate you wouldn't be able to install libSBML after all if your MATLAB has no compiler to generate MEX-files.
2.1.4. Build and install libSBML
make
checkinstall
VERY IMPORTANT OBS:
I) checkinstall asks for confirmation of the metadata of the package it is about to create. In my case, the string for the version field came by default as "Source" (without the quotes), which caused checkinstall to fail because dpkg (the system tool that actually builds the deb file) failed complaining the version number must start with, well, a number. So, save yourself some time and make sure the string in the version field starts with a number (i.e. "5.10", without the quotes obviously)
II) checkinstall asks if you want to exclude from the future package files that the make install command would put in your home folder and says it is a good idea to exclude them. LibSBML has a test.xml file that it needs to be in the $HOME folder later, or else it won't let you integrate with MATLAB. And even though it tells you a test.xml is missing, it doesn't tell you where that file should be or if that file was something that came with the library. I only noticed it because checkinstall had found a $HOME/test.xml reference earlier (that I excluded from the package, of course) and I had found that odd. So, save yourself some time and exclude $HOME/test.xml from the package generated by checkinstall, and then search for test.xml inside the source-code folder and copy it to $HOME as soon as libSBML finishes being installed by checkinstall.
2.2. Integrate libSBML to MATLAB
Fire up MATLAB, navigate to where the SBML MATLAB-bindings were installed in step 2.1.5 (in my case: /usr/local/lib) and run the file installSBML.m that should be there.
2.2.1. Shared libraries problems
In my case, I had an error due to an old unresolved issue: libstdc++.so.6 not having a reference to GLIBCXX_3.4.15. Turns out that MATLAB was trying to use a libstdc++.so.6.0.13 (libstdc++.so.6 was a symbolic link pointing to this file) that came with it in /usr/local/MATLAB/R2013a/sys/os/glnxa64, which indeed didn't have that reference (one could verify that by issuing:
strings /usr/local/MATLAB/R2013a/sys/os/glnxa64/libstdc++.so.6.0.13 | grep GLIBC
). My system has a libstdc++.so.6.0.19 located in /usr/lib/x86_64-linux-gnu that has that reference, so I enforced MATLAB to use 6.0.19 one by setting the LD_LIBRARY_PATH properly (refer to step 1.2) and also by renaming the libstdc++.so.6 that came with MATLAB to something else so it would not find it and would keep looking until it found my system's. A friend of mine running Linux Mint didn't need to rename anything: for him, setting the LD_LIBRARY_PATH was enough.
2.2.2. Other problems
installSBML.m will fail if it doesn't find that $HOME/test.xml file mentioned in step 2.1.5, regardless of whether the library actually works. It assumes that if it could not test itself using a file that it assumes to be in $HOME, the user shouldn't have the option to install it anyway.
3. COBRA / SBML toolbox
3.1. Setup COBRA
In MATLAB, navigate to <YOUR_COBRA_ROOT_FOLDER_HERE>/external/toolboxes/SBMLToolbox-4.1.0/toolbox and run the file install.m there. You should have all set so it finds the MATLAB-bindings you set up in step 2.2.
3.2. MATLAB setpaths problems
I had to manually edit the file /usr/local/MATLAB/R2013a/toolbox/local/pathdef.m as root to include the folder /usr/local/lib (where libSBML and its MATLAB-bindings are) to make that setting persistent. Every time I restarted MATLAB, its setpath had gone back to the default, no matter if I started MATLAB as root when setting its setpath via the MATLAB GUI.
3.3. Test
Now you have hopefully connected all the dots. Try it: in MATLAB, navigate to <YOUR_COBRA_ROOT_FOLDER_HERE> and issue:
initCobraToolbox
testAll
If you haven't got any third-party solvers installed and configured, it should pass 14 of the 19 tests, including the SBML test (testSBML). Now you can load SBML files into MATLAB and play with them.
I also needed to add a symbolic link from /usr/local/lib/libsbml.so.5 to the MATLAB sys folder by:
sudo ln -s /usr/local/lib/libsbml.so.5 /usr/local/MATLAB/R2014a/sys/os/glnxa64/
This finally made the installation possible.
I installed using Cmake. To do this it is necessary to find the FindMatlab.cmake in the source package and insert the MATLAB path manually!
.............
elseif(EXISTS "/Applications/MATLAB_R2008a.app/")
set(MATLAB_ROOT_PATH "/Applications/MATLAB_R2008a.app/")
endif()
else()
if (EXISTS "/usr/local/MATLAB/R2014a/")
set(MATLAB_ROOT_PATH "/usr/local/MATLAB/R2014a/")
endif()
endif()
..........
FYI, to resolve the shared library issue at point 2.2.1 I needed to install the package matlab-support (in Ubuntu repositories)

Run time installation directory of debian package contents

I have a debian package that I built that contains a tar ball of the files, a control file, and a postinst file. Its built using dpkg-deb and it installs properly using dpkg.
The modification I would like to make is to have the installation directory of the files be determined at runtime based on an environment variable that will be set when dpkg -i is run on the deb file. I echo out the environment variable in the postinst script and I can see that its set properly.
My questions:
1) Is it possible to dynamically determine the installation directory at runtime?
2) If its possible how would I go about this? I have read about the rules file and the mypackage.install files but I don't know if either of these would allow me to accomplish this.
I could hack it by copying the files to the target location in the posinst script but I would prefer to do it the right way if possible.
Thanks in advance!
So this is what I found out about this problem over the past couple of weeks.
With prepackaged binaries you can't build a debian package with a destination directory dynamicall determined at runtime. I believe that this might be possible if installing a package that is built from source where you can set the install directory using configure. But in this case since these are embedded Ubuntu machines they don't have make so I didn't pursue such an option. I did work out a non traditional method (hack) for installing that did work. Since debian packages simply contain a tar ball relative to / simply build your package relative to a directory under /tmp. In the postinst script you can then determine where to copy the files from the archive into a permanent location.
I expected that after rebooting and the automatic deletion of the subdirectory under /tmp that dpkg might not know that the file package existed. This wasn't a problem. When I ran 'dpkg -l myapp' it showed as still installed. Updating the package using dpkg/apt-get also worked without a hitch.
What I did find is that if you attempted to remove the package using 'dpkg -r myapp' that dpkg would try and remove /tmp which wasn't good. However /tmp isn't easily removed so it never succeeded. Plus in our situation we never remove packages but instead simply upgrade them.
I eventually had to abandon the universal package due to code differences in the sources resulting in having to recompile per platform but I would have left it this way and it did work.
I tried using --instdir to change the install directory of the package and it does relocate the files but dpkg fails since the dpkg file can't be found relative to the new instdir. Using --instdir is sort of like a chroot. I also tried --admindir and --root in various combinations to see if I could use the dpkg system relative to / but install relocate the files but they didn't work. I guess rpm has a relocate option that works but not Ubuntu.
You can also write a script that runs dpkg-deb with a different environment for 6 times, generating 6 different packages. When you make a modification, you simply have to run your script, and all 6 packages gets generated and you can install them on your machines avoiding postinst hacking!
Why not install to a standard location, and simply use a postinst script to create symbolic links to the desired location? This is much cleaner, and shouldn't break anything in dpk -I.

Resources