working with yum and rpm
download the latest repodata
yum clean
yum repolist
list current repos
yum repolist
Querying data from the RPM database
List the available tags
rpm --querytags
you can specify 1 or more tags plus what ever formatting you want /n /t etc..
rpm -q -qf "%{TAGNAME}\n" fake-rpm
or
rpm -q --qf "%{INSTALLTID}\n%{FILENAMES}\n%{BUILDTIME}\n" fake-rpm
determine which rpm has the largest file on the server
rpm -qa --queryformat "[%-15{NAME} %-50{FILENAMES} %{FILESIZES}\n]" | sort -n -k 3 | tail -20 # -k 3 = sort on third field
determine when an rpm was installed, displayed in human readable time
rpm -q --qf "%{NAME}-%{VERSION}-%{RELEASE} %{INSTALLTIME:date}\n" fake-rpm
determine inter dependencies
rpm -q --whatrequires /usr/lib/libstdc++.so.5
rpm -q --whatprovides /usr/lib/libstdc++.so.5
disable yum plugins on RHEL if your not registering the server with a satellite server
Resigning a vendor package with the example GPG key
[root@server ~]# rpm -qip spacewalk-selinux-1.4.1-1.el5-test.src.rpm
Name : spacewalk-selinux Relocations: (not relocatable)
Version : 1.4.1 Vendor: Koji
Release : 1.el5 Build Date: Thu 03 Mar 2011 08:57:31 PM EST
Install Date: (not installed) Build Host: domU-12-31-38-00-09-D1
Group : System Environment/Base Source RPM: (none)
Size : 144 License: GPLv2+
Signature : DSA/SHA1, Tue 26 Apr 2011 03:57:18 AM EST, Key ID ed635379b3892132
Packager : Koji
URL : http://fedorahosted.org/spacewalk
Summary : SELinux policy module supporting Spacewalk Server
Description :
SELinux policy module supporting Spacewalk Server.
[root@server ~]# rpm --resign spacewalk-selinux-1.4.1-1.el5-test.src.rpm
Enter pass phrase:
Pass phrase is good.
spacewalk-selinux-1.4.1-1.el5-test.src.rpm:
gpg: WARNING: standard input reopened
gpg: WARNING: standard input reopened
[root@server ~]# rpm -qip spacewalk-selinux-1.4.1-1.el5-test.src.rpm
Name : spacewalk-selinux Relocations: (not relocatable)
Version : 1.4.1 Vendor: Koji
Release : 1.el5 Build Date: Thu 03 Mar 2011 08:57:31 PM EST
Install Date: (not installed) Build Host: domU-12-31-38-00-09-D1
Group : System Environment/Base Source RPM: (none)
Size : 144 License: GPLv2+
Signature : DSA/SHA1, Mon 19 Aug 2013 12:21:12 PM EST, Key ID 6cf907deb8607f33 ## Key has changed
Packager : Koji
URL : http://fedorahosted.org/spacewalk
Summary : SELinux policy module supporting Spacewalk Server
Description :
SELinux policy module supporting Spacewalk Server.
RPM packaging and development
Building a custom meta package that encompasses multiple customer child package
source files /usr/src/redhat/SOURCES/example-1.1.tar.gz
member packages
- example-1.1-4.el5.i386.rpm (meta-package)
- example-tools-1.1-4.el5.i386.rpm
- example-devops-1.1-4.el5.i386.rpm
- example-security-1.1-4.el5.i386.rpm
- example-vmware-1.1-4.el5.i386.rpm
RPM Package development server.
- The RPM build directory is /usr/src/redhat/
- packages are built as the root user
- You will need the pass-phrase for the example gpg signing key
- When building the example-tools there are distribution specific dependencies.
- example meta package is built as 32bit. as it contains no binary executables it will work on both 32 & 64bit.
Walk though of updating/modifying the example package
Delete the previously extracted package tarball, this is required in case someone has made changes to the files
rm -R /usr/src/redhat/BUILD/example-1.1
Extract the package tar ball that was created during the previous RPM creation
cd /usr/src/redhat/BUILD/
tar xvf /usr/src/redhat/SOURCES/example-1.1.tar.gz
Make the desired change to the files in the rpm. eg...
vi /usr/src/redhat/BUILD/example-1.1/etc/cron.daily/housekeeping-daily
Create a compressed tarball of the files that will be including in the RPM
cd /usr/src/redhat/BUILD/
tar zcvf /usr/src/redhat/SOURCES/example-1.1.tar.gz ./example-1.1
Update the release version and change log in the spec file
vi /usr/src/redhat/SPECS/example.spec
Build the rpms for the various distribution targets
rpmbuild --define 'dist .el5' --target=i386 -ba --sign /usr/src/redhat/SPECS/example.spec
rpmbuild --define 'dist .el6' --target=i386 -ba --sign /usr/src/redhat/SPECS/example.spec.el6
Repo locations...
/data/redhat/linux/enterprise/5Server/en/example/i386/
/data/redhat/linux/enterprise/5Server/en/example/x86_64/
/data/redhat/linux/enterprise/6Server/en/example/x86_64/
/data/redhat/linux/enterprise/7Server/en/example/x86_64/
Copy new RPMs to the repo directories
NEWVERSION="1.1-4" # set to the desired version
cp -v /usr/src/redhat/RPMS/i386/example*$NEWVERSION.el5.i386.rpm /data/redhat/linux/enterprise/5Server/en/example/i386/
cp -v /usr/src/redhat/RPMS/i386/example*$NEWVERSION.el6.i386.rpm /data/redhat/linux/enterprise/6Server/en/example/x86_64/
cp -v /usr/src/redhat/RPMS/i386/example*$NEWVERSION.el5.i386.rpm /data/redhat/linux/enterprise/5Server/en/example/x86_64/
cp -v /usr/src/redhat/RPMS/i386/example*$NEWVERSION.el7.i386.rpm /data/redhat/linux/enterprise/7Server/en/example/x86_64/
Updating the repos
cd /data/redhat/linux/enterprise/5Server/en/example/i386/
createrepo .
cd /data/redhat/linux/enterprise/6Server/en/example/x86_64/
createrepo .
cd /data/redhat/linux/enterprise/5Server/en/example/x86_64/
createrepo .
cd /data/redhat/linux/enterprise/7Server/en/example/x86_64/
createrepo .
Syncing the YUM repos with the satellite server
Login to the REDHAT satellite server and sync the channels individually
spacewalk-repo-sync --channel rhel6-x86_64-example --type yum
spacewalk-repo-sync --channel rhel5-x86_64-example --type yum
spacewalk-repo-sync --channel rhel5-i386-example --type yum
spacewalk-repo-sync --channel rhel7-x86_64-example --type yum
or
Sync all the channels including to RedHat ( warning this will take a long time )
[root@satellite1 ~]# /opt/example/bin/satellite-sync.sh
No new packages to sync.
Repo http://server.example.local/redhat/linux/enterprise/5Server/en/rhel-example/x86_64/ has 0 errata.
Sync completed.
Total time: 0:00:00
Repo URL: http://server.example.local/redhat/linux/enterprise/5Server/en/vmware-tools/latest/x86_64/
Packages in repo: 46
Packages already synced: 37
Packages to sync: 9
1/9 : kmod-vmware-tools-pvscsi-1.0.2.0-2.6.18.8.el5.3-0.x86_64
2/9 : vmware-tools-xorg-drv-mouse-12.6.4.0-4-0.x86_64
3/9 : kmod-vmware-tools-vsock-1.0.0.0-2.6.18.8.el5.3-0.x86_64
4/9 : kmod-vmware-tools-vmsync-1.1.0.1-2.6.18.8.el5.3-0.x86_64
5/9 : kmod-vmware-tools-vmci-9.0.1.1-2.6.18.8.el5.3-0.x86_64
6/9 : kmod-vmware-tools-vmmemctl-1.2.1.2-2.6.18.8.el5.3-0.x86_64
7/9 : kmod-vmware-tools-vmblock-1.1.2.0-2.6.18.8.el5.3-0.x86_64
8/9 : kmod-vmware-tools-vmhgfs-1.4.1.1-2.6.18.8.el5.3-0.x86_64
9/9 : vmware-tools-xorg-drv-display-11.0.2.10-4-0.x86_64
Repo http://server.example.local/redhat/linux/enterprise/5Server/en/vmware-tools/latest/x86_64/ has 0 errata.
Sync completed.
Total time: 0:00:04
Repo URL: http://server.example.local/redhat/linux/enterprise/5Server/en/example/i386/
Packages in repo: 90
Packages already synced: 86
Packages to sync: 4
1/4 : example-tools-1.1-4.el5-0.i386
2/4 : example-tools-1.1-213.el5-0.i386
3/4 : tidalagent-3.1.0.13-8-0.i386
Repo http://server.example.local/redhat/linux/enterprise/5Server/en/example/i386/ has 0 errata.
Sync completed.
Dealing with a package interdependency issue of my own creation....
To explain the issue, in the package dependencies we have:
- example-tools requires example at the same version
- example-devops requires example at the same version
- There is no version lock between tools and devops
The upgrade appears to go as follows: (Assume installed version is ‘1’, target version is ‘2’ and latest in repo is ‘3’
- All three packages installed at version 1
- Request example-tools upgrade to version 2, requires example also at version 2.
- Conflict as example-devops is at version 1, and requires example at version 1
- yum attempts to resolve conflict, by trying to upgrade example-devops. (This is an upgrade that will just pick the latest available, so picks version 3
- example-devops version 3 depends on example version 3
- Conflict now between example and example-tools, so upgrade example-tools to resolve
- All packages now at version 3.
Two things to try:
- Version lock all of the packages together (This will work)
-
Create a RHN errata, and try applying it.
yum install example-devops --exclude=1.1-2 --exclude=1.1-3
Installed: example-devops.i386 0:1.1-207.el5