Next Previous Contents

5. Incorporating the updates

To incorporate the updates, you need write access to the distribution directory from a Linux machine, with a working version of rpm installed. There are three steps involved:

  1. Correct the file protection modes.
  2. Replace updated RPMs.
  3. Generate the hdlist file

If you maintain a mirror of the updates directory, you can at any time produce a CD including the current updates by repeating these steps.

5.1 Correcting the file protection modes

During the installation process, some programs are run directly off the CD. Unfortunately, the FTP program does not always preserve the protection modes of the files and directories that are copied. Therefore, it is necessary to make sure that execute permission is given to programs, shell scripts and shared libraries, before the directory is burned on the CD. This is done by running the updatePerm script on your local copy of the distribution:


#!/bin/bash

LIST=/tmp/er3hd3w25
CDDIR=/jaz/redhat-${RHVERSION}

# Find all directories, and make sure they have +x permission
find $CDDIR -type d -exec chmod -c 755 {} \;

# Find all files that are executables, shell or perl scripts
find $CDDIR -type f | file -f - | grep -v RPM \
   | egrep -i 'executable|perl|bourne|shell' | cut -f1 -d: > $LIST

# Find shared libraries
find $CDDIR -name \*.so >> $LIST

# Make them executable
while read file
do
   if [ ! -x $file ] ; then
      chmod -c 755 $file
   fi
done < $LIST

/bin/rm $LIST

exit 0

5.2 Replacing the updated RPMS

The following script called updateCD copies all files from the update directory to the RPMS directory. The script uses some nifty rpm tricks to determine what packages in the updates directory are more recent. Older packages are moved to the ${OLD} directory.


#! /bin/bash
# This script updates rpms in a RedHat distribution found in $RPMDIR.
# The old rpms will be placed in $OLDDIR.
# The new rpms should be located in $UPDDIR.
# The architechture is $ARCH.

RHVERSION=5.1

ARCH=i386
CDDIR=/jaz/redhat-${RHVERSION}
RPMDIR=${CDDIR}/${ARCH}/RedHat/RPMS
UPDDIR=${CDDIR}/updates/${ARCH}
OLDDIR=${CDDIR}/old

if [ ! -d $OLDDIR ] ; then
   echo making directory $OLDDIR
   mkdir $OLDDIR
fi

allow_null_glob_expansion=1

for rpm in ${UPDDIR}/*.rpm ; do
  NAME=`rpm --queryformat "%{NAME}" -qp $rpm`
  unset OLDNAME
  for oldrpm in ${RPMDIR}/${NAME}*.rpm ; do
    if [ `rpm --queryformat "%{NAME}" -qp $oldrpm` = "$NAME" ]; then
      OLDNAME=$oldrpm;
      break
    fi
  done
  if [ -z "$OLDNAME" ]; then 
    echo $NAME is new
    cp -pv $rpm $RPMDIR
  else
    if [ `basename $rpm` != `basename $OLDNAME` ]; then
      mv $OLDNAME $OLDDIR
      cp -pv $rpm $RPMDIR
    fi
  fi
done


# Copy new boot image files to the right place...
for newfile in ${UPDDIR}/images/* ; do
  file=${CDDIR}$/${ARCH}/images/$(basename ${newfile})
  if [ $newfile -nt $file ] ; then 
     cp -pv $newfile $file
  fi
done

exit 0

5.3 Generating a new hdlist file

When installing from the CD, the installation program on the CD misc/src/install/genhdlist relies on the file RedHat/base/hdlist describing what RPM packages are available on the CD. This program must be run with the root name of the distribution as the only argument. Here is the updateHdlist script:


#!/bin/bash

echo generating hdlist...
CDDIR=/jaz/redhat-${RHVERSION}
ARCH=i386
GENHDDIR=${CDDIR}/${ARCH}/misc/src/install

chmod u+x ${GENHDDIR}/genhdlist
chmod 644 ${CDDIR}/${ARCH}/RedHat/base/hdlist
${GENHDDIR}/genhdlist ${CDDIR}/${ARCH}

exit 0

NOTE: After having incorporated the updates in the main RedHat/RPMS directory, your copy of the distribution is no longer a mirror of the Red Hat distribution site. Actually, it is more up-to-date! Therefore, if you attempt to mirror the distribution, older versions of the RPM's that have been updated will be downloaded once more, and the updates deleted.


Next Previous Contents