====== RPM: install, list and uninstall ======
Packages sources :
http://www.perzl.org/aix/
Install / Update an RPM package (option i instead U for install only, it's better to use U in any case):
# rpm -Uhv httpd-2.2.15-1.aix5.1.ppc.rpm
force options: - -nodeps (ignore dependency) , - -ignoreos (to install a package build with an earlier version of AIX)
Downgrade a package
# rpm -Uvh --oldpackage [downloaded_lower_version_package]
List rpm packages installed:
# rpm -qa
List files into an RPM package installed:
# rpm -qlv zabbix-agent
-rwxr-xr-x 1 root system 1457 Oct 19 15:44 /etc/rc.d/init.d/zabbix-agent
lrwxrwxrwx 1 root system 22 Oct 19 15:44 /etc/rc.d/rc2.d/Kzabbix-agent -> ../init.d/zabbix-agent
lrwxrwxrwx 1 root system 22 Oct 19 15:44 /etc/rc.d/rc2.d/Szabbix-agent -> ../init.d/zabbix-agent
-rw-r--r-- 1 root system 15575 Oct 19 15:44 /etc/zabbix/zabbix_agentd.conf
drwxr-xr-x 2 root system 0 Oct 19 15:44 /etc/zabbix/zabbix_agentd.d
-rwxr-xr-x 1 root system 6341227 Oct 19 15:44 /opt/freeware/bin/zabbix_get
-rwxr-xr-x 1 root system 7522635 Oct 19 15:44 /opt/freeware/bin/zabbix_sender
-rw-r--r-- 1 root system 4901 Oct 19 15:44 /opt/freeware/man/man1/zabbix_get.1
-rw-r--r-- 1 root system 14962 Oct 19 15:44 /opt/freeware/man/man1/zabbix_sender.1
-rw-r--r-- 1 root system 3899 Oct 19 15:44 /opt/freeware/man/man8/zabbix_agentd.8
-rwxr-xr-x 1 root system 9719766 Oct 19 15:44 /opt/freeware/sbin/zabbix_agentd
lrwxrwxrwx 1 root system 33 Oct 19 15:44 /usr/bin/zabbix_get -> ../../opt/freeware/bin/zabbix_get
lrwxrwxrwx 1 root system 36 Oct 19 15:44 /usr/bin/zabbix_sender -> ../../opt/freeware/bin/zabbix_sender
lrwxrwxrwx 1 root system 37 Oct 19 15:44 /usr/sbin/zabbix_agentd -> ../../opt/freeware/sbin/zabbix_agentd
drwxr-xr-x 2 zabbix zabbix 0 Oct 19 15:44 /var/log/zabbix
drwxr-xr-x 2 zabbix zabbix 0 Oct 19 15:44 /var/run/zabbix
List package from which the file depend:
# rpm -qf /usr/bin/mysql
mysql-3.23.52-3
Uninstall an rpm package:
# rpm -e zip-3.0-1
To extract RPM files from a package => use CPIO from freeware
[root@aix01]/export/softs/zabbix/zabbix_agent_5.0.17-1# rpm2cpio zabbix-agent-5.0.17-1.aix7.2.ppc.rpm | /opt/freeware/bin/cpio -idmv
./etc/rc.d/init.d/zabbix-agent
./etc/rc.d/rc2.d/Kzabbix-agent
./etc/rc.d/rc2.d/Szabbix-agent
./etc/zabbix/zabbix_agentd.conf
./etc/zabbix/zabbix_agentd.d
...
Check rpm package checksum
# rpm -Kvv libqb-2.0.2-1.db2pcmk.el8.x86_64.rpm
D: loading keyring from pubkeys in /var/lib/rpm/pubkeys/*.key
D: couldn't find any keys in /var/lib/rpm/pubkeys/*.key
D: loading keyring from rpmdb
D: serialize failed, using private dbenv
D: opening db environment /var/lib/rpm cdb:private:0x401
D: opening db index /var/lib/rpm/Packages 0x400 mode=0x0
D: locked db index /var/lib/rpm/Packages
D: opening db index /var/lib/rpm/Name 0x400 mode=0x0
D: read h# 431 Header SHA1 digest: OK (7607620a7fc71d534fe59a60dece8de02703e63c)
D: added key gpg-pubkey-d88e42b4-52371eca to keyring
D: read h# 437 Header SHA1 digest: OK (22824a5fcbad49190bcc2dd45d06b4b53aad2447)
D: added key gpg-pubkey-fd431d51-4ae0493b to keyring
D: read h# 438 Header SHA1 digest: OK (2355c07f9978587c537d385c0bdd9353214f7032)
D: added key gpg-pubkey-2fa658e0-45700c69 to keyring
D: read h# 442 Header SHA1 digest: OK (dd737a402556b7653c2bc971f343532046e26384)
D: added key gpg-pubkey-352c64e5-52ae6884 to keyring
D: read h# 457 Header SHA1 digest: OK (a2d8377102268dd4cf467cd46d9413c29832e110)
D: added key gpg-pubkey-a14fe591-578876fd to keyring
D: read h# 835 Header SHA1 digest: OK (cd1fc24b8ab1b1eec4021a4e5828eddd4554adb0)
D: added key gpg-pubkey-00f97f56-467e318a to keyring
D: read h# 890 Header SHA1 digest: OK (6fd848e1a8354d69e3f3728c8717e4ecbf325def)
D: added key gpg-pubkey-a663d36e-3cd9959a to keyring
D: read h# 924 Header SHA1 digest: OK (f4c664d12065958014b7271dfa93fda80055d732)
D: added key gpg-pubkey-06d62707-582074e8 to keyring
D: Using legacy gpg-pubkey(s) from rpmdb
D: Expected size: 118112 = lead(96)+sigs(4404)+pad(4)+data(113608)
D: Actual size: 118112
libqb-2.0.2-1.db2pcmk.el8.x86_64.rpm:
Header SHA1 digest: OK (6c728acd3bb8c2fa1f6aa63dd3b5f1c1f7e2c6c0)
MD5 digest: OK (5dbaf4cdeeb948a011927e29ac62165f)
D: closed db index /var/lib/rpm/Name
D: closed db index /var/lib/rpm/Packages
D: closed db environment /var/lib/rpm
# rpm -K libqb-2.0.2-1.db2pcmk.el8.x86_64.rpm
libqb-2.0.2-1.db2pcmk.el8.x86_64.rpm: sha1 md5 OK
====== RPM: informations about an RPM package before install ======
List files into RPM package:
# rpm -qpl freetype2-2.3.11-1.aix5.1.ppc.rpm
/opt/freeware/doc/freetype2-2.3.11
/opt/freeware/doc/freetype2-2.3.11/ChangeLog
/opt/freeware/doc/freetype2-2.3.11/README
/opt/freeware/lib/libfreetype.a
/usr/lib/libfreetype.a
List RPM package description:
# rpm -qpi rpm2/freetype2-2.3.11-1.aix5.1.ppc.rpm
Name : freetype2 Relocations: (not relocateable)
Version : 2.3.11 Vendor: (none)
Release : 1 Build Date: Tue Nov 17 11:26:18 GMT+01:00 2009
Install date: (not installed) Build Host: aix51.perzl.org
Group : System Environment/Libraries Source RPM: freetype2-2.3.11-1.src.rpm
Size : 1945384 License: BSD/GPL dual license
URL : http://www.freetype.org
Summary : A free and portable font rendering engine
Description :
The FreeType engine is a free and portable font rendering
engine, developed to provide advanced font support for a variety of
platforms and environments. FreeType is a library which can open and
manages font files as well as efficiently load, hint and render
individual glyphs. FreeType is not a font server or a complete
text-rendering library.
The library is available as 32-bit and 64-bit.
List requirements to install an RPM package:
# rpm --requires -qp freetype2-2.3.11-1.aix5.1.ppc.rpm
zlib
libc.a(shr.o)
libz.a(libz.so.1)
Print the scripts (postinstall, preinstall, unistall) contained into an RPM package:
# rpm --scripts -qp httpd-2.2.15-1.aix5.1.ppc.rpm
preinstall script (through /bin/sh):
# add the "apache" group
/usr/bin/mkgroup -A id=64500 apache 2> /dev/null || :
# add the "apache" user
/usr/bin/mkuser id=64500 pgrp='apache' gecos='Apache User' \
login='false' rlogin='false' apache 2> /dev/null || :
preuninstall script (through /bin/sh):
if [ $1 = 0 ]; then
/etc/rc.d/init.d/httpd stop > /dev/null 2>&1
fi
# remove "apache" user and group
/usr/sbin/rmuser -p apache || :
/usr/sbin/rmgroup apache || :
====== RPM: create a package ======
Compile your libraries and binaries and put them on the relative target path starting to /opt/freeware/src/packages/BUILD
Create a spec file with the files names
[root@labo]/opt/freeware/src/packages# cat SPECS/libssh2\-1.11.1.spec
Name: libssh2
Version: 1.11.1
Release: 2
Summary: A library implementing the SSH2 protocol
Group: System Environment/Libraries
License: BSD
URL: https://app-bldns01-h.oi.bdl.lu/doku.php?id=aix:libssh2_compile
Source0: https://github.com/libssh2/libssh2.git
BuildRequires: zlib-devel
BuildRequires: pkg-config, make
BuildRequires: libgcc >= 6.3.0-1
Requires: zlib
Requires: libgcc >= 8.3.0-1
%description
libssh2 is a library implementing the SSH2 protocol as defined by
Internet Drafts: SECSH-TRANS(22), SECSH-USERAUTH(25),
SECSH-CONNECTION(23), SECSH-ARCH(20), SECSH-FILEXFER(06)*,
SECSH-DHGEX(04), and SECSH-NUMBERS(10).
The library is available as 32-bit and 64-bit.
%files
/opt/freeware/lib/libssh2.a
/opt/freeware/lib64/libssh2.a
%changelog
* Tue Jun 04 2024 - 1.11.1-1
- Build custom
Test package creation, and adapt the file location (depnding from RPM generation!)
[root@labo]/opt/freeware/src/packages# /usr/bin/rpmbuild -bb SPECS/libssh2-1.11.1.spec
Processing files: libssh2-1.11.1-2.ppc
error: File not found: /var/tmp/libssh2-1.11.1-2.ppc/opt/freeware/lib/libssh2.a
error: File not found: /var/tmp/libssh2-1.11.1-2.ppc/opt/freeware/lib64/libssh2.a
RPM build errors:
File not found: /var/tmp/libssh2-1.11.1-2.ppc/opt/freeware/lib/libssh2.a
File not found: /var/tmp/libssh2-1.11.1-2.ppc/opt/freeware/lib64/libssh2.a
[root@labo]/opt/freeware/src/packages# mkdir -p /var/tmp/libssh2-1.11.1-2.ppc/opt/freeware/lib
[root@labo]/opt/freeware/src/packages# mkdir -p /var/tmp/libssh2-1.11.1-2.ppc/opt/freeware/lib64/
[root@labo]/opt/freeware/src/packages# cp BUILD/opt/freeware/lib/libssh2.a /var/tmp/libssh2-1.11.1-2.ppc/opt/freeware/lib
[root@labo]/opt/freeware/src/packages# cp BUILD/opt/freeware/lib64/libssh2.a /var/tmp/libssh2-1.11.1-2.ppc/opt/freeware/lib64
Now you are ready to build the RPM package
[root@systemh]/opt/freeware/src/packages# /usr/bin/rpmbuild -bb SPECS/libssh2\-1.11.1.spec
Processing files: libssh2-1.11.1-2.ppc
warning: Deprecated external dependency generator is used!
Finding Provides: /usr/opt/rpm/lib/rpm/find-provides
Finding Requires(interp):
Finding Requires(rpmlib):
Finding Requires(verify):
Finding Requires(pre):
Finding Requires(post):
Finding Requires(preun):
Finding Requires(postun):
Finding Requires(pretrans):
Finding Requires(posttrans):
Finding Requires: /usr/opt/rpm/lib/rpm/find-requires
Finding Conflicts:
Finding Obsoletes:
Finding Recommends:
Finding Suggests:
Finding Supplements:
Finding Enhances:
Provides: libssh2 = 1.11.1-2 libssh2.a(libssh2.so.1)
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: libc.a(shr.o) libc.a(shr_64.o) libcrypto.a(libcrypto.so.3) libgcc_s.a(shr.o)
Wrote: /opt/freeware/src/packages/RPMS/ppc/libssh2-1.11.1-2.aix7.2.ppc.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.DJB7ea
+ umask 022
+ cd /opt/freeware/src/packages/BUILD
+ /bin/rm -rf /var/tmp/libssh2-1.11.1-2.ppc
+ RPM_EC=0
+ jobs -p
+ exit 0
[root@systemh]/opt/freeware/src/packages# ll /opt/freeware/src/packages/RPMS/ppc/libssh2-1.11.1-2.aix7.2.ppc.rpm
684 -rw-r--r-- 1 root system 697152 Jun 4 17:23 /opt/freeware/src/packages/RPMS/ppc/libssh2-1.11.1-2.aix7.2.ppc.rpm
[root@systemh]/opt/freeware/src/packages# rpm -qpl /opt/freeware/src/packages/RPMS/ppc/libssh2-1.11.1-2.aix7.2.ppc.rpm
/opt/freeware/lib/libssh2.a
/opt/freeware/lib64/libssh2.a
Another example of spec file
create a spec file .spec dans /opt/freeware/src/packages/SPECS
Ex : logrorate-3.5.9.spec
Summary : A utility for rotate log following different parmeters.
Name : logrotate
Version : 3.5.9
Release : 1
Copyright : Copyright (C) 1995-2001 Red Hat, Inc.
Group : ?
Source RPM : http://iain.cx/src/logrotate/logrotate
AutoReqProv : no
BuildRoot : /usr/src/packages/BUILD
%description
This may be freely redistributed under the terms of the GNU Public License
Usage: logrotate [-m command] [-s statefile] [--usage] [OPTION...]
/etc/logrotate.conf
%files
/usr/bin/logrotate
/opt/freeware/bin/logrotate
/opt/freeware/man/man8/logrotate.8
/etc/logrotate.conf
Puis copier les fichiers dans /opt/freeware/src/packages/BUILD, avec l’arborescence necessaire :
usr
opt
etc …
Les binaires doivent être compilés pour AIX. Sinon on peut utiliser la commande rpm-built qui compile et créé le package rpm.
lancer rpm –bb /opt/freeware/src/packages/SPECS/logrorate-3.5.9.spec
Un fichier /opt/freeware/src/packages/RPMS/ppc/logrotate-3.5.9-1.aix5.1.ppc.rpm est alors créé, et installable
Vérification :
rpm –qlpv /opt/freeware/src/packages/RPMS/ppc/logrotate-3.5.9-1.aix5.1.ppc.rpm
rpm –qpi /opt/freeware/src/packages/RPMS/ppc/logrotate-3.5.9-1.aix5.1.ppc.rpm
rpm --scripts –qp /opt/freeware/src/packages/RPMS/ppc/logrotate-3.5.9-1.aix5.1.ppc.rpm
ATTENTION :
On ne peut installer des rpm que de version d’AIX >= à celle de l’OS de compilation
===== Script to upgrade rpm packages =====
Script to sort rpm package to find the latest version in a directory using ls -1v human sort (include in the coreutils package)
root@devsrv - /mnt/rpm # for i in $(rpm -qa | grep -v AIX-rpm | rev | cut -d'-' -f3- | rev | tac)
do
pkg=$(/opt/freeware/bin/ls -1v $i-[0-9]* | grep -v src | tail -1)
rpm -Uhv $pkg
done
Find the latest rpm (version) package available in a folder:
root@devsrv - /mnt/rpm # for rpm in $(ls | grep rpm | sed 's/\-[0-9]/\ /g' | awk '{print $1}' | sort -u)
do
echo $rpm
latest=""
latest=$(ls ${rpm}-[0-9]* | sed -e 's/\-/\ ;\ /g' -e 's/\./\ /g' | sort -n -k3 -k4 -k5 -k7 -k8 -k9 | tail -1 | sed -e 's/\ ;\ /\-/g' -e 's/\ /\./g')
mv $latest latest
done
====== ERRORS ======
===== YUM lua_newuserdata =====
After upgrading the rpm package db4, RPMDB is corrupt
root@devsrv - /mnt/rpm # yum update
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
rtld: 0712-001 Symbol lua_newuserdata was referenced
from module /usr/opt/rpm/lib/librpmio.so(), but a runtime definition
of the symbol was not found.
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.7.18 (default, Dec 15 2022, 05:12:43)
[GCC 8.3.0]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
uninstall the packages yum (rpm -qa | grep yum)
yum-metadata-parser-1.1.4-2.ppc
yum-3.4.3-8.noarch
Download and install the DNF bundle instead from https://public.dhe.ibm.com/aix/freeSoftware/aixtoolbox/ezinstall/ppc/
root@devsrv - /mnt/dnf_bundle_aix_71_72_v8# ./install_dnf.sh -d
===== RPM DB corrupt =====
After upgrading the rpm package db4, RPMDB is corrupt
root@devsrv - /mnt/rpm # rpm -Uhv db4-4.8.30-1.rpm
Updating / installing...
1:db4-4.8.30-1 ################################# [ 50%]
Cleaning up / removing...
2:db4-4.7.25-2 ################################# [100%]
root@devsrv - /mnt/rpm # rpm -qa
error: db4 error(-30971) from dbenv->open: DB_VERSION_MISMATCH: Database environment version mismatch
error: cannot open Packages index using db4 - (-30971)
error: cannot open Packages database in /opt/freeware/packages
===== Error during upgrade rpm.rte from 3 to 4 =====
[root@aixnim] /root> lslpp -Lc | grep open
error: incorrect format: unknown tag
**Uninstall openssl AIX package and reinstall:**
make a backup of /etc/ssh (new keys will be generated!)
cd /etc; tar cvf ssh.tar ssh
Uninstall (will also uninstall openssh and sysmgt.cim)
installp -ug openssl.base openssl.license openssl.man.en_US
Reinstall openssh and openssl (sysmgt.cim not necessary)
restore the ssh keys
cd /etc; tar xvf ssh.tar
Just remove the DB files into **/var/lib/rpm**
root@devsrv - /root # cd /var/lib/rpm
root@devsrv - /var/lib/rpm # mkdir old_db_rpm_2017
root@devsrv - /var/lib/rpm # mv __db.001 __db.002 __db.003 __db.004 old_db_rpm_2017
root@devsrv - /var/lib/rpm # rpm -qa
expect-5.42.1-3.ppc
freetype2-2.5.5-1.ppc
AIX-rpm-7.2.2.0-7.ppc
db4-4.8.30-1.ppc
...
If the database is not refreshed, the use the command
rpm --rebuilddb
Change folder : /export/packages/RPMS/noarch
> rpm -Uhv bash-4.4-4.aix5.1.ppc.rpm
> rpm -Uhv info-6.4-1.aix5.1.ppc.rpm gettext-0.10.40-8.aix5.2.ppc.rpm libiconv-1.15-1.aix5.1.ppc.rpm
Preparing... ################################# [100%]
Updating / installing...
1:gettext-0.10.40-8 ################################# [ 33%]
2:libiconv-1.15-1 ################################# [ 67%]
3:info-6.4-1 ################################# [100%]
Please check that /etc/info-dir does exist.
You might have to rename it from /etc/info-dir.rpmsave to /etc/info-dir.
exec(): 0509-036 Cannot load program /usr/opt/freeware/bin/rpm because of the following errors:
0509-150 Dependent module /opt/freeware/lib/libintl.a(libintl.so.8) could not be loaded.
0509-152 Member libintl.so.8 is not found in archive
rpm_share: 0645-007 ATTENTION: get_rpm_inst_root_list() returned an unexpected result.
rpm_share: 0645-007 ATTENTION: update_inst_root() returned an unexpected result.
Problem with RPM Databse
root@nimprod /var/lib/rpm> rm /var/lib/rpm/__db.00*
You need to force the reinstallation of package rpm.rte
root@nimprod /export/lpp/aix7200/aix7200-01-02-lpp> installp -F -acYN -d ./ rpm.rte
===== Yum cleanup repository =====
The "simple" way is to just dump everything in a directory and run:
# rm $(repomanage --keep=2 --old /path/to/repo)
# createrepo /path/to/repo
===== Yum errors =====
Install the right level of popt (as this include into rpm.rte is too old)
/aixtoolbox/RPMS> rpm -Uhv ppc/popt-1.16-3.aix6.1.ppc.rpm
root@nimprod /root> yum search logrotate
Symbol resolution failed for /usr/opt/rpm/lib/librpm.so because:
Symbol poptSaveInt (number 266) is not exported from dependent
module /usr/lib/libpopt.so.
===== Library debug =====
Please update git to 2.20.2-1 to resolve this issue.
To avoid these kind of issues. we have recently taken the approach of hardcoding the library path of libiconv in the loader section of the applications which depends on libiconv library. So LIBPATH won't have any effect on the library search path of libiconv.
root@aix01 # dump -X64 -Hov /opt/freeware/bin/git
***Import File Strings***
INDEX PATH BASE MEMBER
0 /opt/freeware/lib64:/opt/freeware/lib:/usr/lib:/lib
1 libc.a shr_64.o
2 libpthreads.a shr_xpg5_64.o
3 libintl.a libintl.so.8
4 /opt/freeware/lib libiconv.a libiconv.so.2
5 libz.a libz.so.1