Updating Mandrake 7.1 ISOs

This page works ONLY for Mandrake 7.1. Mandrake changed things for Mandrake 7.2. See the page http://www.theory.physics.ubc.ca/mandrake-update72.html for the procedure to follow for Mandrake 7.2.

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, 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. 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.

The following will assume that you already have some rpm based distribution to use to update the cdrom distribution. In particular the scipt uses the rpm program.

In Brief

In Detail

Mandrake ISO

Download the Mandrake 7.1 iso, or the full 7.1 distribution from some site. I will use the example of the site ftp.sunet.se

mkdir /usr/local/Mandrake71
cd /usr/local/Mandrake71

ftp ftp.sunet.se
cd /pub/Linux/distributions/mandrake/iso
get mandrake71-inst.iso

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.) The 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 ./mandrake71-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 cpio. The directory which will contain the unpacked Mandrake distribution will be /usr/local/Mandrake71/Mandrake71-inst

mkdir Mandrake71-inst
cd /mnt/cdrom
find . -depth -print0| cpio --null -pd /usr/local/Mandrake71/Mandrake71-inst

This will copy all of the files from the iso into the directory /usr/local/Mandrake71/Mandrake71-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/Mandrake71/mandrake71-inst.iso

Mandrake 7.1 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/Mandrake71/Mandrake71-ext.


Now download the updates from the same source.

mkdir /usr/local/Mandrake71/updates71
mkdir /usr/local/Mandrake71/updates71/RPMS
cd /usr/local/Mandrake71/updates71/RPMS

ftp ftp.sunet.se
cd /pub/Linux/distributions/mandrake/updates/7.1
mget *

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/Mandrake71
./update-CD updates71 Mandrake71-inst Mandrake71-ext

which would update all of the files on both CDs from the new files downloaded into the updates71/RPMS directory. It would save the old files in updates71/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. 


if [ $NEWFILES -lt 1 -o $NEWFILES -gt $# ]; then

if [ $# -le  1 -o $# -gt 3 ]; then
  echo "Usage: update-CD updates_dir CD1dir [CD2dir]"
  echo "       where updates_dir 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
if [ "$#" = "3" ]; then
 NUM_CD="1 2"

for i in $NUM_CD
 if [  ! -d ${RPMDIR[$i]} ]; then
  echo  CD$i RPM directory ${RPMDIR[$i]} does not exist.
  exit 1
if [ ! -d $UPDDIR ] ; then
  echo Update directory $UPDDIR does not exit
  exit 1
if [ ! -d $OLDDIR ] ; then
   if  mkdir -p $OLDDIR 
     echo made backup directory $OLDDIR 
     echo Cannot make backup directory
     exit 1

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
#    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]}
#  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]}


exit 0

Run this script to load the updated rpms into the Mandrake RPMS directory.

Updating the Distribution.

We now have to update various features of the distribution. Unfortunately Mandrake has made this only partially easy. Almost all of the programs to do this are included on the distribution CD, but for some inexplicable reason they left off one library file, libpopt.

We need to copy the library file into the distribution CDRom. Assuming that you already have a 7.1 system which you have installed, you need to copy the file
/lib/libpopt.so.0 into the directory
If you do not have an already installed Mandrake 7. distribution from which to copy this file, you can get it from the popt rpm in the Mandrake 7.1 distribution.

rpm -Uhv --force /usr/local/Mandrake71/Mandrake71-inst/Mandrake/RPMS/popt*
cp -p /lib/libpopt.so.0 /usr/local/Mandrake71/Mandrake71-inst/Mandrake/mdkinst/lib/

Now, go to the directory /usr/local/Mandrake71/Mandrake71-inst/misc and edit the file
Add the line

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/Mandrake/mdkinst/lib/

to this file right after the line

cd $1

Go to the directory /usr/local/Mandrake71/Mandrake7-inst/Mandrake/base and erase the file hdlist. (Do NOT erase any of the files ending in cz2 however and do not erase hdlists.)
Also edit the file hdlists and remove all but the first or all but the first two entries depending on whether you are upgrading the one or both CDs.

hdlist.cz2 Mandrake/RPMS Installation CD (x86)
hdlist2.cz2 Mandrake/RPMS2 Extension CD (x86)

If you do not there is a good chance that the system will complain in the installation process that the dependencies do not match, and the installation will abort.

Finally you are ready to update the installation files. If you are only interested in updating the first, installation CD, you can use the tools which Mandrake supplies. Go back to the directory

cd /usr/local/Mandrake71/Mandrake71-inst

and run the program


This will produce voluminous output. in about the last four lines you must find the line starting
choosing compression method with "bzip2 -9" for archive ...

If not there has been an error, which you need to correct and rerun this command. However, if you want to be able to use both CDs, the installation and the extra one, you need to use the following file mkhdlist2 instead of the Mandrake mkhdlist

Filename: mkhdlist2

Useage: mkhdlist2 distCD1_head [distCD2_head]

# 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
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

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
export PATH=$CD1/misc:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CD1/Mandrake/mdkinst/lib/

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*
  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
echo libpopt found

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

rm -rf /tmp/.build_hdlist/
$CD1/misc/genhdlist_cz2 -o $CD1/Mandrake/base/hdlist.cz2 $CD1/Mandrake/RPMS
if [ $? -ne 0 ]; then
   echo Error in Processing hdlist.cz2 from $CD1/Mandrake/RPMS >&2
   exit 1

if [ $# -eq 2 ]; then
  $CD1/misc/genhdlist_cz2 -o $CD1/Mandrake/base/hdlist2.cz2 $CD2/Mandrake/RPMS2
  if [ $? -ne 0 ]; then
      echo Error in Processing hdlist2.cz2 from $CD2/Mandrake/RPMS2 >&2
      exit 1

if [ $# -eq 1 ]; then
   $CD1/misc/gendepslist2 -o $CD1/Mandrake/base/depslist $CD1/Mandrake/base/hdlist.cz2
    $CD1/misc/gendepslist2 -o $CD1/Mandrake/base/depslist $CD1/Mandrake/base/hdlist.cz2 $CD1/Mandrake/base/hdlist2.cz2 
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 is a suggestion on one of the Madrake programs on their web page that the images directory on the first CD should come first on the CD or the disk may have problems being bootable on some systems. Thus, they advise that the images directory be moved and then reunited via mkisofs.

cd /usr/local/Mandrake71/Mandrake71-inst
mkdir ../Images
mv images ../Images
mkisofs -v -r -T -J -V "Mandrake7.1 update" -b images/cdrom.img -c images/boot.cat -o /usr/local/Mandrake71/Mandrake71-inst-updt.iso /usr/local/Mandrake71/Images /usr/local/Mandrake71/Mandrake71-inst

(all on one line). This will take a while to create the iso. After it is finished, move back the images directory.
mv ../Images/images .
rmdir ../Images

You can mount this iso to see if it worked using the same command as above

cd /usr/local/Mandrake71
mount -t iso9660 -o ro,loop=/dev/loop0 ./Mandrake71-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 a CD of the second extra CD with

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

Finally, you can burn the cdrom. On my system this is

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

where my CDR drive can burn at a 4x speed and is located on scsi ID 3. Change these to comply with your particular CDR 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 openssh, the openssh-client, and openssh-server rpms which you want included on the installation CD. You would do, from the directory in which you downloaded the openssh rpms file do

cp openssh*.rpm /usr/local/Mandrake71/Mandrake71-inst/Mandrake/RPMS

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

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

You need to edit the two files compss and compssList. The first determines where in the menus of files to load during the install this new file is located. The second gives the priority for the installation of this file under the three options "Normal", "Development" or "Server"

I place openssh into the menu system under the "System/Servers" menu item. Put


into this file under the System/Server item. (to keep the alphabetical order, I place them just after the openldap item.) Exactly where in the menu you place your new rpm is of course up to you.

Now edit the file compssList. This gives the priorities for this particular set of files under the three installation options. Since I believe that ssh is crucial to any installation, I put them in as

openssh                                       80    80    80
openssh-clients                               80    80    80
openssh-server                                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. It does not really seem to matter much what numbers you assign, unless in 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 misc/mkhdlist2 and make a new iso file. Alternatively you can buy some of the new 700MB CDR disks. 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 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.