LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-11-2005, 02:15 PM   #1
DaHammer
Member
 
Registered: Oct 2003
Location: Planet Earth
Distribution: Slackware, LFS
Posts: 561

Rep: Reputation: 30
Remastering/Combining the Slackware ISOs


I've seen alot of people asking how to do this lately, so I thought I'd post a script I wrote a while back to do it. You can use it too combine multiple CDs or ISOs into 1. You can also use it remaster the same. It builds a replica of the ISO/CDROM using symlinks vs actually copying the files to hard disk, so it's faster and doesn't require much hard disk space at all. mkisofs warns about doing it this way, but I've not had any problems at all doing, results may vary though. Anyway, here it is if you want it.
Code:
#!/bin/sh
#
# rebuildiso 0.1
#
# USE AT YOUR OWN RISK!
# It works fine for me, in it's present form, but I suggest you look it over 
# thoroughly before using it.
#
# This script will rebuild an ISO from a current ISO or CDROM, allowing you to make
# modifications in between, without ever actually coping the files from the ISO/CDROM
# to hard disk. It does this by setting up a replica of the ISO/CDROMs's directory
# tree using links vs actual files. This saves time and space. It can also be used to 
# combine multiple ISO/CDROMs into a single ISO, for say a DVD iso. Since it mounts
# the ISO/CDROMs on a loop device, you either need to run it as root or make fstab 
# entries to allow a regular user to do it, which is a security risk in and of itself.
#
# NOTE: In order to combine multiple CDROMs you WILL need to have multiple CDROM drives
#       available, since all ISO/CDROMs MUST stay mounted until the new ISO has been
#       built. If you have a minimum of 2 CDROM drives, then you could use this script
#       to combine those 2 into 1, then use that new ISO to build upon and so on, thereby
#       combining as many as you want eventually into a single ISO. Hope that makes sense. :)
#
#
APPID="Slackware Install"        # Default Application ID Name
VOLID="Slackware Install DVD"    # Default Volume ID Name
NAME="slackware-dvd.iso"         # Default filename of new ISO
#
# DO NOT SET THESE 2 VARIABLES TO ANYTHING YOU VALUE, AS THEY ARE REMOVED AT COMPLETION!!!!!!
MNTDIR="/mnt/rebuildiso"         # Directory where the original ISO/CDROMs will be mounted
REPDIR="/tmp/rebuildiso"         # Directory to build the replica in

EXITSTAT=0
# Codes:
# 1 -- mkisofs failed
# 2 -- $MNTDIR exists & we have no idea what is there (safe play is to abort)
# 3 -- $REPDIR exists & we have no idea what is there (safe play is to abort)
# 4 -- mkdir failed
# 5 -- mount -o loop failed
# 6 -- user abort

create_iso ()
{
  cd $REPDIR
  if [ -h isolinux/isolinux.bin ]; then
    # mkisofs modifies isolinux.bin, so we need to remove the link to it
    #  and copy the actual file into the new tree
    cp -H isolinux/isolinux.bin /tmp
    rm isolinux/isolinux.bin
    cp /tmp/isolinux.bin isolinux/
    rm /tmp/isolinux.bin
  fi
  if [ -e isolinux/isolinux.boot ]; then
    # mkisofs creates isolinux.boot, so just remove it if present
    rm -f isolinux/isolinux.boot
  fi
  
  if [ -d isolinux ]; then
    mkisofs -o $NAME -R -J -V "$APPID" -hide-rr-moved \
    -v -d -N -no-emul-boot -boot-load-size 4 -boot-info-table \
    -sort isolinux/iso.sort -b isolinux/isolinux.bin \
    -c isolinux/isolinux.boot -A "$VOLID" -f .
    if [ ! "$?" = "0" ]; then
      EXITSTAT=1
      echo "mkisofs failed!!!"
    fi
  else
    echo
    echo "There is no isolinux directory present. The ISO will not"
    echo "be bootable! Not a problem if you'll be adding isolinux"
    echo "later or don't care if it's bootable or not."
    echo -n "Continue anyway? (y/n): "
    read ANSWER
    if [ "$ANSWER" = "y" ]; then
      mkisofs -o $NAME -R -J -V "$APPID" -hide-rr-moved \
      -v -d -N -A "$VOLID" -f .
      if [ ! "$?" = "0" ]; then
        EXITSTAT=1
        echo "mkisofs failed!!!"
      fi
    else
      echo "Aborted..."
      exit 6
    fi
  fi
}

cleanup ()
{
  cd /
  for ((a=1; a <= NUM ; a++))
  do
    umount $MNTDIR/loop$a
    rmdir $MNTDIR/loop$a
  done
  rm -rf $REPDIR
  rm -f /tmp/.rebuildiso-save
  rmdir $MNTDIR
}

if [ -f /tmp/.rebuildiso-save ]; then
  # Get the settings from the saved build, if present
  . /tmp/.rebuildiso-save
  echo "Found a saved session at $REPDIR"
  echo -n "Create the ISO from it? (y/n): "
  read ANSWER
  if [ "$ANSWER" = "y" ]; then
    create_iso
    cleanup
    echo
    if [ "$EXITSTAT" = "0" ]; then
      echo "ISO $NAME build is complete..."
    else
      echo "ISO $NAME build failed!!!"
    fi
  else
    rm /tmp/.rebuildiso-save
  fi
  exit $EXITSTAT
fi

while [ "$GOTALL" != "y" ]
do
  # Here we collect all the information we need
  echo
  echo -n "How many ISO/CDROMs do you want to include?: "
  read NUM

  if (( NUM )); then
    ((a = 1))
    while (( a <= NUM ))
    do
      echo
      echo "What is the full path to ISO/CDROM #$a?" 
      echo -n "(ie /home/gomer/slack.iso, /dev/cdrom): "
      read ISOS[$a]
      if [ -f ${ISOS[$a]} ] || [ -b ${ISOS[$a]} ]; then
        ((a += 1))
      else
        echo
        echo "${ISOS[$a]} either does not exist or is not a regular file or device!"
      fi
    done

    ((a = 1))
    while (( a ))
    do
      echo
      echo -n "What shall I name the new ISO? [`basename $NAME`]: "
      read TMP
      if [ -n "$TMP" ]; then
         NAME=$TMP
      fi
      # Force it into /tmp/filename so we don't end up writing the new ISO inside $REPDIR
      # when using the -o option to mkisofs
      NAME="/tmp/`basename $NAME`"
      if [ -e $NAME ]; then
        echo
        echo -n "$NAME already exists. Overwrite it? (y/n): "
        read ANSWER
        if [ "$ANSWER" = "y" ]; then
          (( a = 0 ))
        fi
      else
        (( a = 0 ))
      fi
    done

  echo
  echo -n "What should I use for the Application ID? [$APPID]: "
  read TMP
  if [ -n "$TMP" ]; then
    APPID=$TMP
  fi
  echo
  echo -n "What should I use for the Volume ID? [$VOLID]: "
  read TMP
  if [ -n "$TMP" ]; then
    VOLID=$TMP
  fi

  echo "About to generate $NAME from the following ISO/CDROMs:"
  for ((a=1; a <= NUM ; a++))
  do
    echo "    ${ISOS[$a]}"
  done
  echo
  echo -n "Proceed? (y/n): "
  read GOTALL
  fi
done

if [ -e $MNTDIR/loop1 ]; then
  echo
  echo "I can not proceed until you unmount anything in $MNTDIR"
  echo "and remove the directory, since I have no way of knowing"
  echo "for sure what is there."
  exit 2
fi

if [ -e $REPDIR ]; then
  echo
  echo "I can not proceed until you remove $REPDIR, since I have"
  echo "no way of knowing for sure what is there."
  exit 3
fi
mkdir -p $REPDIR
if [ ! "$?" = "0" ]; then
  echo "Failed to create $REPDIR"
  exit 4
fi

for ((a=1; a <= NUM ; a++))
do
  mkdir -p $MNTDIR/loop$a
  if [ ! "$?" = "0" ]; then
    echo "Failed to create $MNTDIR/loop$a"
    exit 4
  fi
  mount -o loop ${ISOS[$a]} $MNTDIR/loop$a
  if [ ! "$?" = "0" ]; then
    echo "Could not mount ${ISOS[$a]}"
    exit 5
  fi
  cd $MNTDIR/loop$a
  (( x=1 ))
  echo
  echo -n "Adding ISO/CDROM #$a to $REPDIR ... "
  for file in `find . | cut -c 3-`
  do
    if [ -d "$file" ]; then
      mkdir -p $REPDIR/$file
    else
      ln -sf $MNTDIR/loop$a/$file $REPDIR/$file
    fi
    # Print progress
    case $x in
      1)
        printf "\b|";;
      2)
        printf "\b/";;
      3)
        printf "\b-";;
      *)
        printf "\b\\"
        x=1;;
    esac
    (( x++ ))
  done
  printf "\bDone!"
done

echo
cat << EOF 
The directory tree for the new ISO is ready at $REPDIR.
If you would like to make some custom modifications to it
then you can exit this script now, make your mods, and then
rerun this script to build the ISO.

NOTE: Before you can modify any file, you will need to replace
      the link with the actual file from the ISO/CDROM. All of 
      the ISO/CDROMs are mounted at $MNTDIR.
EOF
echo
echo -n "Proceed now? (y/n): "
read ANSWER
if [ "$ANSWER" = "n" ]; then
  # Save the variables for later
  cat << EOF > /tmp/.rebuildiso-save
# DO NOT MODIFY THIS FILE! IT'S INTEGRITY IS ASSUMED!"
NUM=$NUM
REPDIR="$REPDIR"
MNTDIR="$MNTDIR"
NAME="$NAME"
APPID="$APPID"
VOLID="$VOLID"
GOTALL="y"
EOF
  exit 0
fi

create_iso
cleanup
echo
if [ "$EXITSTAT" = "0" ]; then
  echo "ISO $NAME build is complete..."
else
  echo "ISO $NAME build failed!!!"
fi
exit $EXITSTAT
# End of script
 
Old 01-11-2005, 02:38 PM   #2
SlackerLX
Senior Member
 
Registered: Dec 2004
Location: Herzliyya, Israel
Distribution: SuSE 10.1; Testing Distros
Posts: 1,832

Rep: Reputation: 47
DaHammer!
You could, perhaps, contact slackMeUp member.... As long as I remember he was trying with a project of Slackware DVD GUI install. Perhaps your cooperation will greatly be appreciated?!
 
Old 01-12-2005, 01:41 PM   #3
DaHammer
Member
 
Registered: Oct 2003
Location: Planet Earth
Distribution: Slackware, LFS
Posts: 561

Original Poster
Rep: Reputation: 30
I'm not much of a hand at programming GUIs under linux, so I doubt I'd be of much help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
slackware: combining install cd's to 1 dvd? flapjack Linux - Newbie 2 05-24-2005 09:48 AM
Burning Slackware ISOs sxa Slackware 3 02-06-2004 07:12 AM
Slackware ISOs kersten78 Slackware 7 12-16-2003 10:31 AM
Slackware 8.1 _all_ isos zeky Slackware 1 07-25-2002 05:07 AM
Slackware ISOs DeadPuddle Linux - General 2 04-21-2002 05:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration