apache-2.2.34 and openssh-8.2p1 on EL6

Red Hat backports fixes and keep package versions as they are. At times, security scanners are not smart enough to know that. They’d complain the packages are out of date. Making it worse, apache 2.2 has reached EOL since 2018. And even though openssh is now on version 8.2, one will still find version 5.3 on EL6 systems.

Upgrading EL is not an easy task like Ubuntu. One will most likely need to build a new system and migrate things over. If that is an issue for you, install my repo and yum-plugin-priorities. Then install or update httpd-2.2.34 with yum.

curl -sqo /etc/yum.repos.d/headdesk.repo https://repo.headdesk.me/headdesk.repo
yum -y install yum-plugin-priorities

While this gives you the very last version of apache 2.2, you may be asked to upgrade to apache 2.4. That’s a different game. IUS and SCL offer apache 2.4. Problem is, IUS’s apache does not work with php in the same repo. Their php are built to work with apache 2.2. So as Remi’s. SCL’s httpd24 and php work together, but they put files under a completely different location. And they stop making php packages at version 7.0, which is EOL.

It’s a mess. Migrate to FPM if you can.

Use the packages at your own risk. I cannot promise future updates. Your best option is to migrate to newer OS and rely on updates from the official distro.

Building my first Linux package

Let’s take a look at how to build a really simple Linux package. The most common package formats are definitely .deb and .rpm. One will find them on Debian-variants and Redhat-variants respectively.

In the following examples, a package will be created and it will contain 1 script.The script depends on Python so I want the package management tool to handle that for me too. The script’s name is goldenRatio.sh and it will be installed to /usr/local/bin/

DEB

Create a directory structure for building

Here is what I created. Will talk about the control file in a minute. The usr subdirectory contains the path to where I want this script installed.

/root/goldenRatio
├── DEBIAN
│   └── control
└── usr
    └── local
        └── bin
            └── goldenRatio.sh

The control file

This file describe the package. It is pretty much self-explanatory.

Package: goldenRatio
Version: 0.1.2
Maintainer: XPK
Architecture: all
Depends: python3
Description: Script to calculate golden ratio 

Build & install the package

We are ready to build the deb package. The following command will create a package under /tmp/.

$ cd /root
$ dpkg-deb --build goldenRatio /tmp
dpkg-deb: building package 'goldenratio' in '/tmp/goldenratio_0.1.2_all.deb'.
$ apt install /tmp/goldenratio_0.1.2_all.deb

RPM

The RPM version is more involved. For rpm, we’ll need to write a spec file.

The spec file

The spec file does not just describe the package. It contains instructions to compile a software or in this case to copy the script to the target location.

Name: goldenRatio
Summary: Shell script for calculating golden ratio
Version: 0.1
Release : 3
License: GPLv3
Requires: python36

%description
Shell script for calculating golden ratio

%changelog
* Thu Jul 26 2018 XPK [email protected] 0.1-3
- Second build, adding python dependency

%prep
mkdir -p %{buildroot}%{_prefix}/local/bin
cp -pf goldenRatio.sh %{buildroot}%{_prefix}/local/bin/goldenRatio.sh
chmod 755 %{buildroot}%{_prefix}/local/bin/goldenRatio.sh

%files
%{_prefix}/local/bin/goldenRatio.sh

Install the build tool

$ yum install rpm-build

The build directory

After the previous step is performed, /root/rpmbuild is automatically created. Here, I’ll need to put my spec file in the SPECS directory, and my script under the BUILD directory.

/root/rpmbuild/
├── BUILD
│   └── goldenRatio.sh
├── BUILDROOT
├── RPMS
├── SOURCES
├── SPECS
│   └── goldenRatio.sh.spec
└── SRPMS

Build and install the package

$ cd /root/rpmbuild/SPECS
$ rpmbuild  -ba goldenRatio.sh.spec
$ yum localinstall /root/rpmbuild/RPMS/x86_64/goldenRatio-0.1-3.x86_64.rpm

Wrapping up

In both case, apt and yum will automatically resolve the dependency for Python, and prompt you to install them if you don’t have it already.

These are very simply examples. I’ll do a follow-up post once I learn more.