I'd like to improve the distribution and versioning of a program I've inherited, which is currently distributed as a .tar.gz file, by building a .rpm for RHEL7 that just extracts the contents to /usr/bin/. The tarball is not small, consisting in around 120 MB worth of files.
I'm new around package building so I've been following the bello example from https://rpm-packaging-guide.github.io, but the example is too simple for my needs.
So far I have this .spec file:
Name: my-app
Version: 2.0
Release: 1%{?dist}
Summary: My application
License: Internal license
URL: <my-website>
Source0: <my-website>/%{name}-%{version}.rhel7.x86_64.tar.gz
Requires: bash
BuildArch: x86_64
%description
My application
%prep
%setup -q
%build
%install
mkdir -p %{buildroot}/%{_bindir}
install -m 0755 %{name} %{buildroot}/%{_bindir}/%{name}
%files
%{_bindir}/%{name}
Which generates a very small .rpm with just /usr/bin/my-app. On installation if complains about many missing dependencies that are inside the tarball's lib directory, but of course not in my package.
As far as I understand, the %files directive must contain a list of all the files that are supposed to be inside the .rpm, but those are hundreds. So I'm assuming there's a better way to build the package, after all is just decompressing the tarball.
Do you have any pointers?
install -m 0755 %{name} %{buildroot}/%{_bindir}/%{name}
you are only installing the binary. You should also install the dependencies if they are in your tgz, Then make sure to package them as well under %files.
I am creating my first package using RPM on ubuntu machine.But I am getting so many difficulties.I tried so many commands to install rpmdevtools using "yum" but it is giving error as There are not repos enabled.
When I try to install it using apt-get it gives error as Unable to locate the package.
Can anybody suggest the proper start to end procedure with commands to build a package using RPM?
rpmdev is mostly optional. rpm is enough. The following describes the minimum steps to package a script program into a RPM file on Debian.
Install rpmbuild:
apt-get install rpm
Create a helloworld program:
cat > helloworld <<EOF
#! /bin/bash
printf "Hello World!\n"
EOF
chmod +x helloworld
Create a minimal specification helloworld.spec:
Name: helloworld
Version: 1.0
Release: 1%{?dist}
Summary: Hello World
License: GPLv3+
BuildArch: noarch
%description
Hello World!
%prep
%build
%install
mkdir -p %{buildroot}/%{_bindir}
install -m 0755 %{name} %{buildroot}/%{_bindir}/%{name}
%files
%{_bindir}/%{name}
%changelog
Build the RPMs:
rpmbuild -ba --build-in-place --define "_topdir $(pwd)/rpm" helloworld.spec
mv rpm/SRPMS/*.rpm .
mv rpm/RPMS/*/*.rpm .
rm -rf rpm
But you will not be able to install it on Debian or Ubuntu. The installation requires Fedora or Red Hat.
Im attempting to build apr-utils-1.6.1 from source on CentOS 7 (with the goal to get httpd-2.4.29) but I'm stuck with a dependancy issue:
# rpmbuild -tb apr-util-1.6.1.tar.bz2
error: Failed build dependencies:
db4-devel is needed by apr-util-1.6.1-1.x86_64
db4-devel isn't available in yum and libdb-devel provides version 5, which doesn't meet the dependency requirement.
I've tried downloading and installing db4-devel, but that has it's own dependencies that I can't meet:
# rpm -iv db4-devel-4.7.25-22.el6.x86_64.rpm
warning: db4-devel-4.7.25-22.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
db4 = 4.7.25-22.el6 is needed by db4-devel-4.7.25-22.el6.x86_64
db4-cxx = 4.7.25-22.el6 is needed by db4-devel-4.7.25-22.el6.x86_64
libdb-4.7.so()(64bit) is needed by db4-devel-4.7.25-22.el6.x86_64
libdb_cxx-4.7.so()(64bit) is needed by db4-devel-4.7.25-22.el6.x86_64
Trying to install db4 fails too because the the Berkely DB version 5 is already installed and in use on CentOS 7:
# rpm -iv db4-4.7.25-22.el6.x86_64.rpm
warning: db4-4.7.25-22.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
db4 < 5 is obsoleted by (installed) libdb-5.3.21-20.el7.x86_64
I'm not really sure how to proceed at this point. Do I just have to cut my losses and deploy a CentOS 6 box? It seems that CentOS 6 still has db4. I was thinking of modifying the spec file to remove the db4 requirement, but I'm not sure of the implications of that, or how to even do that properly.
Thanks.
rpmbuild -tb apr-util-1.6.1.tar.bz2
No spec file, but apr-util-1.6.1/build/rpm/apr-util.spec.in
Better use a source with a regular apr-util.spec file : apr-util-1.6.1-1.fc27.src.rpm http://dl.fedoraproject.org/pub/fedora/linux/updates/27/SRPMS/Packages/a/apr-util-1.6.1-1.fc27.src.rpm
Please do not build rpm packages as root, setup an unprivileged rpmbuild environment in /home/name/ : https://www.linuxquestions.org/questions/linux-software-2/need-rpm-package-for-php-version-5-2-7-and-up-on-redhat-5-1-a-766486/#13
Unpack the source with $ rpm -Uvh apr-util-1.6.1-1.fc27.src.rpm ... and $ cd rpms/SPECS/ ... edit 'apr-util.spec' to the new dependencies, and give it a try : $ rpmbuild -bb apr-util.spec
In Redhat release 7.5 is required to install the db4-devel package but it was replaced with libdb-devel. The below steps are necessary to create the packages for apr-util from the tar-ball file
yum install libdb-devel
rpmbuild -tb apr-util-1.6.1.tar.bz2
cd ~/rpmbuild
rm -rf BUILD BUILDROOT RPMS SRPMS
cp ../ apr-util-1.6.1.tar.bz2 SOURCES/
cd SPECS
vim apr-util.spec and replace db4-devel by libdb-devel
rpmbuild -bb apr-util.spec
cd ../RPMS/x86_64
All the packages for apr-util will be there.
I'm trying to build some code on Ubuntu 10.04 LTS that uses OpenSSL 1.0.0. When I run make, it invokes g++ with the "-lssl" option. The source includes:
#include <openssl/bio.h>
#include <openssl/buffer.h>
#include <openssl/des.h>
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
I ran:
$ sudo apt-get install openssl
Reading package lists... Done
Building dependency tree
Reading state information... Done
openssl is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
But I guess the openssl package doesn't include the library. I get these errors on make:
foo.cpp:21:25: error: openssl/bio.h: No such file or directory
foo.cpp:22:28: error: openssl/buffer.h: No such file or directory
foo.cpp:23:25: error: openssl/des.h: No such file or directory
foo.cpp:24:25: error: openssl/evp.h: No such file or directory
foo.cpp:25:25: error: openssl/pem.h: No such file or directory
foo.cpp:26:25: error: openssl/rsa.h: No such file or directory
How do I install the OpenSSL C++ library on Ubuntu 10.04 LTS?
I did a man g++ and (under "Options for Linking") for the -l option it states: " The linker searches a standard list of directories for the library..." and "The directories searched include several standard system directories..." What are those standard system directories?
You want to install the development package, which is libssl-dev:
sudo apt-get install libssl-dev
Run:
apt-get install libssl-dev
All of these answers are very outdated and from when the package was still being developed. You can now just use the "normal" command listed below:
sudo apt install openssl
Edit: OP's question is poorly worded... after all, OpenSSL is a library itself, so I read his question too quickly before answering. The command above installs "normal" OpenSSL.
Toward the bottom of his question he mentions that make fails, suggesting he is compiling the package manually. And yes, even if you download the TAR ball, it will include all of the openssl and libssl files, which you can then make from.
What OP is really asking for is the OpenSSL Development Library, in which case you can first install OpenSSL using the above command, and then run this afterwards:
sudo apt install libssl-dev
More info: https://linuxtect.com/how-to-install-openssl-libraries-on-ubuntu-debian-mint/
I found a detailed solution here: Install OpenSSL Manually On Linux
From the blog post...:
Steps to download, compile, and install are as follows (I'm installing version 1.0.1g below; please replace "1.0.1g" with your version number):
Step – 1 : Downloading OpenSSL:
Run the command as below :
$ wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz
Also, download the MD5 hash to verify the integrity of the downloaded file for just varifacation purpose. In the same folder where you have downloaded the OpenSSL file from the website :
$ wget http://www.openssl.org/source/openssl-1.0.1g.tar.gz.md5
$ md5sum openssl-1.0.1g.tar.gz
$ cat openssl-1.0.1g.tar.gz.md5
Step – 2 : Extract files from the downloaded package:
$ tar -xvzf openssl-1.0.1g.tar.gz
Now, enter the directory where the package is extracted like here is openssl-1.0.1g
$ cd openssl-1.0.1g
Step – 3 : Configuration OpenSSL
Run below command with optional condition to set prefix and directory where you want to copy files and folder.
$ ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl
You can replace “/usr/local/openssl” with the directory path where you want to copy the files and folders. But make sure while doing this steps check for any error message on terminal.
Step – 4 : Compiling OpenSSL
To compile openssl you will need to run 2 command : make, make install as below :
$ make
Note: check for any error message for verification purpose.
Step -5 : Installing OpenSSL:
$ sudo make install
Or without sudo,
$ make install
That’s it. OpenSSL has been successfully installed. You can run the version command to see if it worked or not as below :
$ /usr/local/openssl/bin/openssl version
OpenSSL 1.0.1g 7 Apr 2014
How could I have figured that out for
myself (other than asking this
question here)? Can I somehow tell
apt-get to list all packages, and grep
for ssl? Or do I need to know the
"lib*-dev" naming convention?
If you're linking with -lfoo then the library is likely libfoo.so. The library itself is probably part of the libfoo package, and the headers are in the libfoo-dev package as you've discovered.
Some people use the GUI "synaptic" app (sudo synaptic) to (locate and) install packages, but I prefer to use the command line. One thing that makes it easier to find the right package from the command line is the fact that apt-get supports bash completion.
Try typing sudo apt-get install libssl and then hit tab to see a list of matching package names (which can help when you need to select the correct version of a package that has multiple versions or other variations available).
Bash completion is actually very useful... for example, you can also get a list of commands that apt-get supports by typing sudo apt-get and then hitting tab.
Another way to install openssl library from source code on Ubuntu, follows steps below, here WORKDIR is your working directory:
sudo apt-get install pkg-config
cd WORKDIR
git clone https://github.com/openssl/openssl.git
cd openssl
./config
make
sudo make install
# Open file /etc/ld.so.conf, add a new line: "/usr/local/lib" at EOF
sudo ldconfig
You want the openssl-devel package.
At least I think it's -devel on Ubuntu. Might be -dev. It's one of the two.
As a general rule, when on Debian or Ubuntu and you're missing a development file (or any other file for that matter), use apt-file to figure out which package provides that file:
~ apt-file search openssl/bio.h
android-libboringssl-dev: /usr/include/android/openssl/bio.h
libssl-dev: /usr/include/openssl/bio.h
libwolfssl-dev: /usr/include/cyassl/openssl/bio.h
libwolfssl-dev: /usr/include/wolfssl/openssl/bio.h
A quick glance at each of the packages that are returned by the command, using apt show will tell you which among the packages is the one you're looking for:
~ apt show libssl-dev
Package: libssl-dev
Version: 1.1.1d-2
Priority: optional
Section: libdevel
Source: openssl
Maintainer: Debian OpenSSL Team <pkg-openssl-devel#lists.alioth.debian.org>
Installed-Size: 8,095 kB
Depends: libssl1.1 (= 1.1.1d-2)
Suggests: libssl-doc
Conflicts: libssl1.0-dev
Homepage: https://www.openssl.org/
Tag: devel::lang:c, devel::library, implemented-in::TODO, implemented-in::c,
protocol::ssl, role::devel-lib, security::cryptography
Download-Size: 1,797 kB
APT-Sources: http://ftp.fr.debian.org/debian unstable/main amd64 Packages
Description: Secure Sockets Layer toolkit - development files
This package is part of the OpenSSL project's implementation of the SSL
and TLS cryptographic protocols for secure communication over the
Internet.
.
It contains development libraries, header files, and manpages for libssl
and libcrypto.
N: There is 1 additional record. Please use the '-a' switch to see it
Go to the official website and download the source code for the version you need
Then unzip the update package and execute the following command
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl -Wl,-rpath,/usr/local/ssl/lib shared
Because the default is to generate only static libraries, if you want dynamic libraries, add the "shared" option
make && make install
sudo apt-get install libcurl4-openssl-dev
please advice why I cant find the rpm that I installed.
I am try to check by rpm -qa | grep test ( see the example in install the rpm: )
but seems that rpm isnt installed why?
build the RPM:
[root#linux /usr/src/redhat/SOURCES]# rpm -ba /usr/src/redhat/SPECS/my_spec.spec
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/test.sh
Wrote: /root/rpmbuild/SRPMS/test.sh-6.2-2.src.rpm
install the rpm:
[root#linux /usr/src/redhat/RPMS/i386]# rpm -Uvh /root/rpmbuild/SRPMS/test.sh-6.2-2.src.rpm
1:test.sh ########################################### [100%]
[root#linux /usr/src/redhat/RPMS/i386]# rpm -qa | grep test
no results ?
the spec file:
Summary: An example tool. To show a simple rpm build of the tool.
Name: test.sh
Version: 6.2
Release: 2
Source:/root/test.sh
Group: Development/Debuggers
BuildRoot:/var/tmp/test.sh
License: OtherLicense
%description
You installed the source rpm instead of the actual rpm:
rpm -Uvh /root/rpmbuild/RPMS/test.sh-6.2-2.rpm
rpmbuild outputs two files:
A source RPM (SRPM), located in SRPMS/
A binary RPM, located in RPMS//
As Wes noted, you've installed the SRPM. You need to install the RPM, which is located in your RPMS/i386/ subdir. Don't rename the SRPM, you need to look for the file located in the RPM folder and install it:
rpm -Uvh RPMS/i386s/test.sh-6.2-2.i386.rpm
When you install src.rpm it ends up in
~/rpmbuild/SPEC
~/rpmbuild/SOURCES
If you want to rebuild and get binary rpm you should:
rpmbuild -ba test.sh-6.2-2.src.rpm
or even better
mock test.sh-6.2-2.src.rpm
Try:
rpm -q test.sh-6.2-2
or
rpm -q test.sh-6.2-2.src