RPM Build Demo

From Outrun Wiki
Jump to: navigation, search


Outrun provides a pre-configured build environment for custom packages. It also provides a few demo packages that demonstrate how to setup your own YUM repository.

The outrun-build package comes with a few demo source RPM packages that show you how to setup and operate your custom YUM repo. The packages are located in /usr/share/build/demo/


The script /usr/share/build/bin/make-demo sets up a demo environment using a special user 'rpmdemo'.

# If this system is installed from Outrun ISO, enable 'base' first:
yum-config-manager --enable base
# Install outrun-build
yum install outrun-build
# Setup demo build user and FTP share
# Login as rpmdemo
su - rpmdemo

Now as rpmdemo user, create the release package:

# Rebuild the release package and update the repos
rebuild /usr/share/build/release-template.spec
# Check if the release RPM is available on FTP
curl -l ftp://localhost/rpmdemo/rpms/

# Note down the client host install instructions
rpm -qip demo-release*|grep yum

Rebuilding DEMO packages

Installing source RPMS

Demo source packages are provided. We will build RPM packages from all of them to demo RPM functionality.

# Install all SRPM packages
rpm -i /usr/share/build/demo/*
# Check for the SPEC and SOURCE files
# Note that some packages don't have a source tarball
ls -l
ls -l

Creating DEMO RPMs

Building some packages, be careful NOT to build demo-obsoletes and demo-requires as we will do that later to show update behaviour.

# Change to the SPEC dir
# Build demo package - creates 1 source RPM and 2 binary RPMs
rebuild demo.spec

reviewing all RPMS:

# Change to the rpmdir/noarch directory
cd noarch
# List files - you should see the demo and demo-lib RPMs
ls -al

Client setup

As root (can be on the build host or another testhost in the same network)

# Use the recorded YUM install instructions
yum install ftp://<buildhost>/rpmdemo/rpms/demo-release-1.0-1.noarch.rpm
# Review the correct working of the repo definition
yum repolist demo

# Review available packages
# The command to list available packages is 'yum list available'. However, 
# we need to temporarily disable all repositories except 'demo',
# otherwise we will get ALL available packages from ALL enabled repositories.
yum --disablerepo="*" --enablerepo="demo" list available

Using the Demo RPMS

Assuming we have the demo YUM repository enabled and built the demo packages (demo RPM and demo-lib RPM).

Installing demo package

As root:

# Install demo package. Note that this will fail due to missing dependencies for demo-requires.
yum install demo ### Fails!

# ---> Go back to the build environment (rpmdemo user) and build the demo-requires package.

# Clear YUM cache (it is not aware of the new package so we need to rebuild the cache
yum clean all
# Retry installing the package
yum install demo ### Should work now

Testing demo package

Assuming the install of demo package succeeded, let's inspect the results.

# Verify package info
rpm -qi demo
# Verify package contents
rpm -qlv demo
# Verify package scripts
rpm -q --scripts demo

# Verify the results of the package pre- and postinstall scripts
# Check if user and group are created
getent group demo
getent passwd demo
# Check if preinstall updated our networking configuration
grep -i demo /etc/sysconfig/network
# Check if postinstall created the /etc/demo file
cat /etc/demo
# Start a new shell (Sources the new environment - causes to read /etc/profile.d/demo.sh)
# We should have $MANPATH and $PATH showing 'demo' entries
set|grep -i demo
# Check if hello mirrored output to /etc/demo
cat /etc/demo

Requires and obsoletes

To demonstrate how a package can replace (obsolete) another, the RPM build demo includes a source package 'demo-obsoletes'.

The demo RPM requires a package named demo-requires. The demo-obsoletes package marks demo-requires as obsoleted and replaces the other package. So updating the system to demo-obsoletes would uninstall demo-requires - but this is not allowed because 'demo' requires demo-requires. The obsoletes package therefore has to 'provide' the same service so it has a tag "Provides: demo-requires" to satisfy dependencies.

# ---> Go back to the build environment (rpmdemo user) and build the demo-obsoletes package.
# Flush the YUM cache
yum clean all
# Update the system
yum update
# Verify packages - check that 'demo-requires' is no longer installed and replaced by demo-obsoletes
rpm -qa "demo*"

Upgrading packages

Let's upgrade the demo package to a higher release number.

As build user (rpmdemo):

# Update release number of demo.spec
rpmdev-bumpspec demo.spec
# Verify new release number
awk '/Release/' demo.spec
# Rebuild the package
rebuild demo.spec

On the client machine (as root) run YUM update:

# Update system
yum clean all
yum update
# Verify demo RPM to be release 2 (version 1.0-2)
rpm -qa "demo*"

Downgrading packages & locking

Sometimes, for whatever reason, we want to downgrade a package or stick with an older version. We also want to prevent YUM to update the downgraded package to the most recent version every time.

# Downgrade demo
yum downgrade demo
# update system
yum update

# As you can see, YUM tries to update our downgraded package every time. If we have yum-plugin-versionlock installed,
# we can prevent this. Check if it's installed:
rpm -qi yum-plugin-versionlock

# Downgrade demo again to release 1
yum downgrade demo

# Prevent demo from updating
yum versionlock demo

# Attempt updates
yum update

# List installed versionlocks
yum versionlock list

# Remove the lock - note that you need to specify the lock as displayed with the RPM 'Epoch' id (usually 0):
yum versionlock del 0:demo*

# Attempt updates
yum update

Customizing Outrun with RPM packages

It is possible to customize many configuration settings in Outrun. As one of the purposes of Outrun is to provide a consistent install method, one of the best ways to achieve consistency is to have the customized configuration settings in an RPM package. It can then be included with PXE installs via the Local YUM repository.

An example source package (demo-system) is included to demonstrate how to do this. Demo-system will provide the following configuration changes:

  • A custom /etc/motd file (displayed after login)
  • A custom /etc/issue file (displayed on the system console before login)
  • Profile settings that disable 'ls' colors
  • Profile settings that define some additional aliases
  • A daily cron job that updates packages in the demo repository.

Demo-system is depending on Confetti so this is a good example of how a package depends on another one.

# ---> Go back to the build environment (rpmdemo user) and build the demo-system package.
# Install demo-system
yum clean all
yum install demo-system

# ---> Re-login and watch the login message
# ---> Check the system console and check out the login prompt
# ---> Run an 'ls -l' and watch the display colors (should be all black and white)
# ---> Check some new aliases

# The same way you can add updates to all sorts of config files. As an example, check out
# how Outrun itself manages this:
rpm -qil outrun-system