Updating Mandrake 7.2 ISOs

Until the Mandrake 7.0, the miniHowTo "RedHat-CD" gave detailed instructions for updating the files on a Mandrake or RedHat distribution. (Redhat did not include this particular miniHowTo in their distribution for some reason but Mandrake did.)

However with the new versions of Mandrake (post 7.0), the procedure and files used changed radically, and Mandrake, although they included most of the tools, did not include instructions as to how to make updated CDRom ISO distributions. Furthermore, they again  changed the procedure for Mandrake 7.2 from that which worked in 7.1. One significant change is that the installation CDs no longer are self contained, and one can only update the 7.2 CDs from a 7.2 or 7.1 system. (The 7.1 updates could be run completely from the CD image.) This page is to give step by step instructions for updating the distributions so that CDRoms can be cut which for example include all of the updated files or include extra rpm files of particular interest to your own site.
 

In Brief

 

In Detail

Mandrake ISO

Download the Mandrake 7.2 iso, or the full 7.2 distribution from some site. I will use the example of the site ftp.sunet.se
All  of the files will be assumed to be located in the root directory  /usr/local/Mandrake72. Change all instances of this to whichever directory you use for the CD images.
mkdir /usr/local/Mandrake72
cd /usr/local/Mandrake72

ftp ftp.sunet.se
ftp
yourname@
cd /pub/Linux/distributions/mandrake/iso
get mandrake72-inst.iso
get mandrake72-ext.iso
exit
The above are just the commands which I issued to logon on and get the file. (ftp is the Username: and yourname@ is the Password:. Make sure you include the @ at the end of your name, or the server may object.) Each file is about 700MB so you should not try this with a telephone modem, and should make sure that you have enough room on the drive. In fact you will need at least 1.5GB for each CD on that drive.

Now you need to unpack the iso file. The easiest way is to mount the iso as a loopback file.

mount -t iso9660 -o ro,loop=/dev/loop0 ./mandrake72-inst.iso /mnt/cdrom

Now you want to copy all of the files from /mnt/cdrom to a local filesystem, since you cannot write or change anything on that mounted loopback iso. Use your favorite way of doing so. Here is one using tar. The directory which will contain the unpacked Mandrake distribution will be /usr/local/Mandrake72/Mandrake72-inst

mkdir /usr/local/Mandrake72/Mandrake72-inst
cd /mnt/cdrom
tar -cf - .|(cd /usr/local/Mandrake72/Mandrake72-inst; tar -xf - )

This will copy all of the files from the iso into the directory /usr/local/Mandrake72/Mandrake72-inst. Once you are sure that the copy has gone alright, you can unmount and remove the iso you downloaded. ( of course if you have enough disk space, you should save it just in case...)

umount /mnt/cdrom
rm /usr/local/Mandrake72/mandrake72-inst.iso

The Mandrake 7.2 downloadable distribution contains two CDs. You can do the same for the second CD-- download the iso, locally mount it, and copy the files to another directory. I will assume that these files are copied to /usr/local/Mandrake72/Mandrake72-ext.

Updates

Now download the updates from the same source.
mkdir -p /usr/local/Mandrake72/updates72/RPMS
cd /usr/local/Mandrake72/updates72/RPMS

ftp ftp.sunet.se
yourname@
cd /pub/Linux/distributions/mandrake/updates/7.2
mget *
y
...
y
exit
Where on each of the questions about whether to download the file you answer y unless you do not want that update.

You now need to replace the files in the the distribution with the updated files you have downloaded. To do so you can use the following shell script, based on the script included in the original RedHat-CD miniHowTo by Morten Kjeldgaard, mok@imsb.au.dk and Peter von der Ahé. Note that you could simply copy each of the new rpms that you want to update by hand to Mandrake/RPMS and delete the old version, but that does take a while if there are a number of updates.

In the examples I am following, you would do

cd /usr/local/Mandrake72
update-CD updates72 Mandrake72-inst Mandrake72-ext

which would update all of the files on both CDs from the new files downloaded into the updates72/RPMS directory. It would save the old rpm files in updates72/old



Filename: update-CD

Useage: update-CD updates_dir distCD1_head [distCD2_head]

Here updates_dir/RPMS contains the new rpm files which update files on the distribution, distCD1_head is the top of the first distribution CD file tree ( with rpm files contained in distCD1_head/Mandrake/RPMS and distCD2_head is the top of the second distribution CD file tree, with rpm files assumed to be in distCD2_head/Mandrake/RPMS2/

Note that if there are two updates for the same package in the update_dir/RPMS then this could update with the wrong (earlier) one. 


#! /bin/bash 
# This script updates rpms  distribution trees  found in  one or two arguments
# given to this script. The first is assumed to be in the Mandrake/RPMS
# directory below this first base name, while the second is in the
# Mandrake/RPMS1 directory below the second argument given
# Note that you need only give the first if you wish.
# The old rpms will be placed in $OLDDIR.
# The new rpms should be located in $UPDDIR.

# NEWFILES  determines whether new files (ie files not found in the 
#directory tree) are added to one of the  CD RPMS directories or not. 
# It should be set to the number of the CD to which the files should be added
# if they are new. Do Not use 0 if you do not want new files copied. 

NEWFILES="99"

if [ $NEWFILES -lt 1 -o $NEWFILES -gt $# ]; then
   NEWFILES="99"
fi

if [ $# -le  1 -o $# -gt 3 ]; then
  echo "Usage: update-CD updates_dir CD1dir [CD2dir]"
  echo "       where update-CD has the updated files in the RPMS directory,"
  echo "    and CD1dir and CD2dir are the tops of the tree containing the CD files"
  exit 1
fi
UPROOT="$1"
RPMDIR[1]="$2/Mandrake/RPMS"
RPMDIR[2]=""
NUM_CD="1"
if [ "$#" = "3" ]; then
 RPMDIR[2]="$3/Mandrake/RPMS2"
 NUM_CD="1 2"
fi
NEWRPM="${RPMDIR[$NEWFILES]}"

for i in $NUM_CD
do
 if [  ! -d ${RPMDIR[$i]} ]; then
  echo  CD$i RPM directory ${RPMDIR[$i]} does not exist.
  exit 1
 fi  
done
 
UPDDIR=${UPROOT}/RPMS
OLDDIR=${UPROOT}/old/RPMS
if [ ! -d $UPDDIR ] ; then
  echo Update directory $UPDDIR does not exit
  exit 1
fi
if [ ! -d $OLDDIR ] ; then
   if  mkdir -p $OLDDIR 
   then
     echo made backup directory $OLDDIR 
   else
     echo Cannot make backup directory
     exit 1
   fi 
   
fi

shopt -s nullglob

for rpm in ${UPDDIR}/*.rpm ; do
#  Get the short name of the rpm file
 NAME=`rpm --queryformat "%{NAME}" -qp $rpm`
 if [ -n "$NAME" ]; then
   for i in $NUM_CD; do
    unset OLDNAME
#     find files in the distributions which start with that name
    for oldrpm in ${RPMDIR[$i]}/${NAME}*.rpm ; do
     if [ -n "$oldrpm" ]; then
#        See if the short name is the same
      if [ `rpm --queryformat "%{NAME}" -qp $oldrpm` = "$NAME" ]; then
        OLDNAME=$oldrpm;
        break
      fi
     fi
    done
#    copy the updated rpm file to the distribution and save the old file
    if [ -n "$OLDNAME" ]; then
      if [ "`basename $rpm`" != "`basename $OLDNAME`" ]; then
        mv -v $OLDNAME $OLDDIR
        cp -pv $rpm ${RPMDIR[$i]}
      fi
    fi
  done
#  If no rpm of same name found on any distribution, place into appropriate
#     distribution according to NEWFILES
  if [ -z "$OLDNAME" ]; then
      if [ -n "${RPMDIR[$NEWFILES]}" ]; then
         echo --- $NAME is new-- copying to ${RPMDIR[$NEWFILES]}
          cp -pv $rpm ${RPMDIR[$NEWFILES]}
     fi
  fi

 fi
done

chmod -R a+rX $2/Mandrake/RPMS
if [ $# -eq 3 ]; then
  chmod -R a+rX $3/Mandrake
fi

exit 0




 

Updating your computer's programs to use the Mandrake tools.

We now have to install various features of the 7.2 distribution. This requires you to be already running either Mandrake 7.1 or 7.2. (Whether a version of Redhat would do as well I do not know).

cd /usr/local/Mandrake72/Mandrake72-inst/Mandrake/RPMS
rpm -Uhv bzip2* rpm-3* rpmtools-1*

If there are complaints about dependencies put --nodep as an argument to rpm

Now it is time to update the various distribution files. This uses the files gendepslist and genbasefiles from rpmtools or from the misc directory on the first CD. It also requires you to edit the file Mandrake/base/hdlists on the first CD and to remove various files from the Mandrake/base directory. These have been collected together into the shell script mkhdlist72 Filename: mkhdlist72

Useage: mkhdlist2 distCD1_head [distCD2_head]


#!/bin/sh
# Regenerate hdlists for installation [and extra] CD. 
# distCD1_head should be the directory where you find 
# generally these files and subdirectories :
#
# COPYING Mandrake/ RPM-GPG-KEYS VERSION dosutils/ images/ lnx4win/
#  misc/
#
#distCD2_head should be the top of the extra CD where there is just the file 
#Manrdrake/ which contains Mandrake/RPMS2


if [ $# -eq 0 -o $# -gt 2 ];then
   echo "Usage: $(basename $0) /path/to/CD1/root_directory/   [/path/to/CD2/root_directory]" >&2
   exit 1
fi
CD1=`echo $1|awk ' $1 !~ /^\// {printf "'\`pwd\`'/"}{print $1}'`
if [ ! -d $CD1/misc ]; then
  echo " RPM directory $CD1/misc does not exist" >&2
  exit 1
fi

if [ $# -eq 2 ]; then
  CD2=`echo $2|awk ' $1 !~ /^\// {printf "'\`pwd\`'/"}{print $1}'`
    if [ ! -d $CD2/Mandrake/RPMS2 ]; then
       echo RPM directory $CD2/Mandrake/RPMS2 does not exists >&2
       exit 1
     fi
fi
export PATH=$CD1/misc:$PATH
export LD_LIBRARY_PATH=$CD1/Mandrake/mdkinst/lib/:$LD_LIBRARY_PATH:

echo Checking for libpopt

if [ ! -f $CD1/Mandrake/mdkinst/lib/libpopt.so.0 ]; then
  if [ ! -f /lib/libpopt.so.0 ]; then
   rpm -Uhv --force $CD1/Mandrake/RPMS/libpopt*
  fi
  cp -p /lib/libpopt.so.0 $CD1/Mandrake/mdkinst/lib/libpopt.so.0
  if [ ! -f $CD1/Mandrake/mdkinst/lib/libpopt.so.0 ]; then
    echo Cannot find or install required libpopt.so.0 >&2
    exit 1
  fi
fi
echo libpopt found

#Now make the compressed files hdlist?.cz in Mandrake/base

rm -rf /tmp/.build_hdlist/

cd $1/Mandrake/base
rm provides hdlist1.cz hdlist2.cz
mv hdlists hdlists.$$
echo "hdlist1.cz Mandrake/RPMS CD 1 Installation CD (x86)">hdlists
if [ $# -eq 2 ]; then
  echo "hdlist2.cz Mandrake/RPMS2 CD 2 Extention CD (x86)">>hdlists
  ln -sf $CD2/Mandrake/RPMS2 ../RPMS2
fi

$CD1/misc/genhdlists --distrib $CD1

if [ $? -ne 0 ]; then
   echo Error in Processing hdlist.cz2 from $CD1/Mandrake/RPMS >&2
   exit 1
fi




if [ $# -eq 1 ]; then
   $CD1/misc/genbasefiles  $CD1/Mandrake/base/ $CD1/Mandrake/base/hdlist1.cz
else
    $CD1/misc/genbasefiles  $CD1/Mandrake/base/ $CD1/Mandrake/base/hdlist1.cz $CD1/Mandrake/base/hdlist2.cz 
fi
EXIT=$?

if [ ! "$EXIT" = "0" ]; then
        echo  
        echo "Error in generating dependencies lists."
fi  

chmod a+r $CD1/Mandrake/base/*
rm -rf /tmp/.build_hdlist/
exit $EXIT



Assuming you got no errors, your Mandrake files are now updated and ready to be converted to ISOs and burned to CD.

Making ISO and Burning to CD

You use the programs mkisofs and cdrecord to burn the CD. There are indications on some of the shell scripts on the Mandrake web pages that it is best to make sure that the images directory occurs first on the CD if it is to be bootable. I have not had problems with this, but will follow their suggestion.

cd /usr/local/Mandrake72/Mandrake72-inst
mkdir ../Images
mv images ../Images

Now we can make the iso image.

mkisofs -v -r -T -J -V "Mandrake7.2 update" -b images/cdrom.img -c images/boot.cat -o     /usr/local/Mandrake72/Mandrake72-inst-updt.iso /usr/local/Mandrake72/Images /usr/local/Mandrake72/Mandrake72-inst

(all on one line). This will take a while to create the iso.
Fianlly move back the images directory so as to keep things clean.

mv ../Images/images .
rmdir ../Images

You can now mount this iso file you have created  to see if it worked using the same type of mount command as above

cd /usr/local/Mandrake72
mount -t iso9660 -o ro,loop=/dev/loop0 ./Mandrake72-inst-updt.iso /mnt/cdrom

and look through the resultant files to see if there is anything obviously wrong. Then unmount this loopback mount.
umount /mnt/cdrom

Similarly you can make an iso image  of the second extention CD with

mkisofs -v -r -T -J -V "Mandrake7.1 update" -o /usr/local/Mandrake72/Mandrake72-ext-updt.iso /usr/local/Mandrake72/Mandrake72-ext

Finally, you can burn the cdroms. On my system the command is

cdrecord -v speed=4 dev=3,0 ./Mandrake72-inst-updt.iso

where my CDR drive can burn an 4x speed and is located on scsi ID 3. Change these to comply with your particular CDR drive.  You can use

cdrecord --scanbus

to find the scsiID of your CDrom drive.

You now have updated cdrom(s) which you can boot from to install Mandrake 7.1.

Adding RPMS to Distribution

You can follow almost the same procedure to add an rpm to the distribution. However in order that the installation routine see the new rpm during the installation, a few extra steps are required.

Copy the rpms you want to include to the appropriate RPMS directory. Lets say it is the chrony rpm ( a program to synchronize your computer clock with atomic clocks on the internet) which you want included on the installation CD. You would do, from the directory in which you downloaded the openssh rpms file do

cp chrony*.rpm /usr/local/Mandrake72/Mandrake72-inst/Mandrake/RPMS

Now run the mkhdlist72 command as above. However befor making the iso file, and burning it, go into the directory

cd /usr/local/Mandrake72/Mandrake72-inst/Mandrake/base

First check that the rpm got included in the list of files

grep chrony compss

Edit the file compssList. This gives the priorities for each of the rpm packages under the three installation options (Standard, Server, Development). Since I believe that chrony is crucial to any installation, I put them in as

chrony                                          80 80 80
The priorities go from 0 ( which means that it is not selected by default under that particular installation category) to 100 which means it is absolutely crucial. Look at the numbers associated with other packages which you consider of roughly equal importance. Except for 0, it does not really seem to matter much what numbers you assign, unless during the installation the system finds you have selected more packages than can fit on your disk. It will then use these numbers to decide which packages to leave off, and which to include.

Your system is now ready again to make the iso image and to burn the CDRom. Just follow the instructions above in the Making the ISO and Burning the CD section.

The only problem can occur if you have made too large an iso. The standard CDRoms can only hold 650MB ( about 681,574,000 bytes). If your iso file is larger than this, you will have to erase some of the files in the RPMS directory to shorten the iso. Once you have erased the unwanted files rerun mkhdlist72 and make a new iso file. Alternatively you can buy some of the new 700MB CDR disks (734,003,200 bytes). cdrecord will write these without problem to compliant CDR drives, and most of the newer CDRoms will read them without problems as well.

Updating an installed distribution

Since one often has a distribution already installed, which needs updating, and since running rpm on all of the update files may install stuff you do not want, I have written the script update-distr to do this. It is probably better to use the MandrakeUpdate facility if you are running a single machine. It is much more user friendly. However I find my script file more useful for updating a bunch of installed systems from the updates directory I have already downloaded to update the CD iso images. It is called with the directory containing the updates in the RPMS directory, and has two options. -f will run a failed attempt to updte again with the --nodeps option, so that circular dependency problems can be resolved. -v is verbose output.

Useage: update-distr [-f] [-v] path/to/updates

The update rpms are in path/to/updates/RPMS



Good Luck


This document was prepared by W. Unruh, and is copyright by him. It may be reproduced as long as the copyright notice is maintained. Please let me know if anything here is wrong or could be improved.

History