error: unpacking of archive failed: cpio: Bad magic when installing an rpm - cmake

I packaged an rpm using
make package
command, and copied the resulting rpm to another machine which has a company specific OS. Now when I try to install the rpm using
rpm --nodeps -i filename.rpm
I get the error the same as the one in the title.
So I ran
rpm -qa | grep rpm
on the machine used to build the rpm package, and got this:
rpm-4.8.0-37.el6.x86_64
rpm-devel-4.8.0-37.el6.x86_64
rpm-python-4.8.0-37.el6.x86_64
rpm-libs-4.8.0-37.el6.x86_64
rpm-build-4.8.0-37.el6.x86_64
redhat-rpm-config-9.0.3-51.el6.noarch
After a bit of investigation, I tried removing the redhat-rpm-config package and bam, rpm installation worked on the other machine. Now, this is a solution and all but I don't think I can just uninstall this package for every machine that we're going to use in creating the rpm. Is there any other way to ignore this redhat-rpm-config-9.0.3-51.el6.noarch when creating an rpm package using cmake?

What is the RPM version of the system you are installing on? Are its sources publicly available somewhere?
There could be various compatibility issues if you build binary RPMs using a newer RPM/distribution. In general, we build binary RPMs using the RPM and redhat-rpm-config versions in the buildroot (which is created by mock) itself, which matches the target RPM version, even if the build host has a newer RPM version.
If this is not an option for you, I would look at specific RPM features controlled by redhat-rpm-config. The one that sticks out to me immediately is payload compression:
# Use XZ compression for binary payloads
%_binary_payload w2.xzdio
Other changes include support for larger files, but this does not seem to be the issue here because it would not change by uninstalling the redhat-rpm-config package.

You very likely made binary RPM using rpmbuild on different OS than was the target OS. You should use "mock" for building the package.
dnf install mock
mock -r epel-6-x86_64 yourpackage.src.rpm

To solve "error: unpacking of archive failed: cpio: Bad magic" issue at RPM package installation on your machine:
1/ List rpm pkgs which are installed on the server machine (the machine on which the rpm pkg is generated):
$ rpm -qa | grep rpm
….
….
2/ If pkg redhat-rpm-config-9.0.3-51.el6.noarch is present in the given list, desinstall it:
$ rpm -e redhat-rpm-config-9.0.3-51.el6.noarch
3/ Generate now the pkg and tranfer it on your dev machine. Pkg installation should work.
Philippe.

Related

rpm build with local Required: some_local_package.rpm

Requires: in the spec files sets the package dependencies, but what will happen if the repo of the requirements is not in the repolist?
Is there a way to use pre downloaded rpm files and tell the rpmbuild that the dependencies should be installed from the local file like yum localinstall.
You're conflating rpm and yum when you mention repolist.
rpm is a lower level and only knows about RPM files
yum collects sets of RPMs into repositories and sits on top of RPM to handle dependencies
Now, to answer the question - rpmbuild does not need anything from the Requires field to build the RPM. If it does, then the RPMs should be listed as BuildRequires in the specfile and only be in Requires if the end user needs it to be installed to run the final product. For example, to build you might need foo-devel but at runtime you only need libfoo. Those should be declared appropriately.
Even if you fix the Requires vs. BuildRequires fields, it still won't help you - rpmbuild cannot install RPMs itself because you should never run rpmbuild as root. An error in a specfile can very easily nuke an entire machine if it's run as root.

How do I install an older ethtool version on a machine?

I need to test if some firmware is compatible with older ethtool versions.
The machine I am using currently have ethtool version 5.16, but I need to install ethtool version 5.13
I got the compressed file from https://mirrors.edge.kernel.org/pub/software/network/ethtool/ and have used tar -zxvf https... to extract the files. This extracts a directory with the contents shown below:
After reading the INSTALL file, I ran ./configure but it gave me the following error: configure: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config
This meant that I could not run make or make install and thus am stuck.
After speaking to colleagues, the solution was found:
apt-get install -y pkg-config. Thereafter the following package was also needed: apt-get install -y libmnl-dev
Simple installed it with ./configure, make and make install and saw the ethtool version was as desired.

Installing / Building the newest version of Inkscape (v 1.2) on Linux Ubuntu 20.04

I am trying to install Inkscape 1.2beta on Linux Ubuntu 20.04. The website currently only offers an AppImage and a source tarball. Since I would like to access the newest features of Inkscape via the command line, I need to build and install the source tarball.
INSTALL.md states that I need all submodules and dependencies before install.
How do I find these dependencies to successfully build and install Inkscape?
This list should satisfy all required dependencies on Linux Ubuntu:
apt install
cmake
imagemagick
libdouble-conversion-dev
libgdl-3-dev
libagg-dev
libpotrace-dev
libboost-all-dev
libsoup2.4-dev
libgc-dev
libwpg-dev
poppler-utils
libpoppler-dev
libpoppler-glib-dev
libpoppler-private-dev
libvisio-dev libvisio-tools
libcdr-dev
libgtkmm-3.0-dev
libgspell-1-dev
libxslt-dev libxslt1-dev
libreadline6-dev
lib2geom-dev
lib2geom-dev is needed to solve error "<ieeefp.h> not found".
For building Inkscape:
Download source tarball for Inkscape v1.2 from inkscape.org and extract
cd <extracted inkscape directory>
mkdir build && cd build
cmake ..
make
make install
If you still get an error during cmake .., please comment below with the names of the missing modules in the error message.
The details on how to build Inkscape (and the dependencies) could be found in the repository itself, or Inkscape website (For completness, the steps are copied from the website here):
To obtain the latest source code, use the following command (downloads into a subdirectory of your current working directory called "inkscape" by default):
git clone --recurse-submodules https://gitlab.com/inkscape/inkscape.git
To update this code later, change into the download folder and use:
git pull --recurse-submodules && git submodule update
By default, git will download every branch and every commit. If you are on a slow machine, have limited disk space, or limited internet bandwidth, you can use shallow clone and single branch clone options to limit the amount of data it will download:
git clone --depth=1 --single-branch --recurse-submodules --shallow-submodule https://gitlab.com/inkscape/inkscape.git
Building Inkscape on Linux
Open a terminal at the root of the folder into which you downloaded the source code in the previous step.
Install build dependencies
Download and run the script to install everything required for compiling Inkscape (check script to see if your distribution is supported):
wget -v https://gitlab.com/inkscape/inkscape-ci-docker/-/raw/master/install_dependencies.sh -O install_dependencies.sh
bash install_dependencies.sh --recommended
Compile
To compile with CMake, do the following:
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${PWD}/install_dir -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
make -j8
make install
Notes:
Using ccache is optional but speeds up compilation.
The optional -j8 argument to make tells it to run 8 jobs in parallel. Feel free to adjust this to the number of hardware threads (physical cores) available on your computer.
The recommended -DCMAKE_INSTALL_PREFIX argument allows to specify a custom isolated installation location (in the example above install_dir/ inside the build folder). It avoids installation into system locations (where it could conflict with other versions of Inkscape) and allows running multiple versions of Inkscape in parallel. It will still use all the files (including the preferences.xml) that reside in the ~/.config/inkscape directory.
Run
Run it from the build directory:
install_dir/bin/inkscape

How to create RPM package that uses setcap and works on both dnf/yum (fedora/redhat) and zypper (openSuse)

I'm developing an RPM package for a service that requires the command setcap for setting capabilities. The purpose of using setcap is to listen to port numbers below 1024.
RPM packages have a 'Requires' section that is a comma-separated list of other required packages, and in theory I can use that to make sure the target system installs the packages needed.
Now here's the problem:
setcap is available for Fedora in package libcap and for openSUSE in package libcap-progs.
the package libcap is not available on openSUSE, and libcap-progs is not available on Fedora.
Is it possible to create a single RPM package that installs setcap and works on both Fedora and openSUSE?
It's possible to write the following:
Requires: /usr/sbin/setcap
This will resolve on both Fedora and openSUSE to their corresponding library

How can I build an RPM package in a Debian based system?

I'd like to build packages using a build system (i.e. jenkins, travis, etc) but all I have are Ubuntu 12.04 VMs.
I've found this [1] instructions but mach does not support CentOS 7.0.
[1] http://blog.burghardt.pl/2008/12/how-to-build-rpm-packages-in-centos-chroot-on-debian/
http://mojo.codehaus.org/rpm-maven-plugin/ <- rpm plugin for the maven build system
sudo apt-get install rpm # for Ubuntu
Check out the command that it installs called rpmbuild.
Found it! There is actually a tool called rinse: "Rinse is a simple tool which is designed to carry out the installation of a new RPM-based distribution".
rinse --distribution="centos-7" --directory="/tmp/centos-7"
http://collab-maint.alioth.debian.org/rinse/