4. The scripts.

The process of making new tagfiles from a model installation consists out of two steps:

  1. Making the directory structure filled with the original tagfiles to use as source for the second step.

  2. Checking if the packages in a tagfile are actually installed on a system.

For these steps I wrote two BASH scripts. Each script using only the most basic of commands to keep the scripts as portable as possible.

4.1. The script mkorgstruct

The purpose of this script is quite simple. It checks directories in the /slackware directory for files with the name tagfile. If it finds one, it makes a directorie in the OUT_DIR and copies the tagfile as tagfile.org in that directory. You run the script twice: once for every Slackware install CD-Rom

After the second run you would get a structure like this:

tagfiles/
|-- a
|   `-- tagfile.org
|-- ap
|   `-- tagfile.org
|-- d
|   `-- tagfile.org
|-- e
|   `-- tagfile.org
|-- f
|   `-- tagfile.org
|-- gnome
|   `-- tagfile.org
|-- k
|   `-- tagfile.org
|-- kde
|   `-- tagfile.org
|-- kdei
|   `-- tagfile.org
|-- l
|   `-- tagfile.org
|-- n
|   `-- tagfile.org
|-- t
|   `-- tagfile.org
|-- tcl
|   `-- tagfile.org
|-- x
|   `-- tagfile.org
|-- xap
|   `-- tagfile.org
`-- y
    `-- tagfile.org

The script itself is quite simple, I had to add a lot of comments to give it some body ;):

#! /bin/sh

#========
# LICENSE
#========
# Yes this is BSD licensed. Everyone may do what they want with it, 
# I only want my name in the credits :-) 

# Copyright (c) 2005, Peter Kaagman <bilbo@nedlinux.nl>
# http://www.bilbos-stekkie.com
# All rights reserved. 

# Redistribution and use in source and binary forms, with or without 
# modification, are permitted provided that the following conditions 
# are met: 

# Redistributions of source code must retain the above copyright 
# notice, this list of conditions and the following disclaimer.

# Redistributions in binary form must reproduce the above copyright 
# notice, this list of conditions and the following disclaimer in the 
# documentation and/or other materials provided with the distribution. 

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
# PROFITS; ORBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#========
# PURPOSE
#========
# This script will make a structure "tagfiles/[serie name]/tagfile.org"
# in the current working directory based upon the tagfiles it finds in 
# the "slackware" directory on a Slackware CDRom (or where ever you 
# install from).
# The output of this script can be used by "mkcpinstall" 

# Some vars 
SLACKWARE_DIR="/mnt/cdrom/slackware"
CWD=`pwd`
TAG_DIR=${CWD}/tagfiles

# Make the slackware directory our working dir
cd ${SLACKWARE_DIR}
# Process the slackware directory
for serie in * ; do
  # only interested in the dirs
  if [ -d ${serie} ]; then
    mkdir -p ${TAG_DIR}/${serie}
    cp ${serie}/tagfile ${TAG_DIR}/${serie}/tagfile.org
  fi # is it a dir
done # processing the slackware dir

The variable SLACKWARE_DIR should reflect the place where you've mounted the CD-Rom. Please change that variable accordingly. If you make your installs via NFS you could run the script agains the directory where you keep your packages. In that case you would allso have to change the SLACKWARE_DIR variable. I could have prompted you for the location... but that seems like such a hassle for such a simple script.

4.2. The script mkcpinstall

This script uses the files tagfiles/*/tagfile.org to check if a package is installed. Place the directory tagfiles on the model system which you want to check against and run the script. What the script does is readis the content of every tagfile.org and checks in /var/log/packages if that perticular package is installed on the system. It writes a new file named tagfile in the tagfile directory. If it finds the package installed the line will be "[packagename]: ADD", if not the line will be "[packagename]: SKP".

After you've run the script you'll have the following files in the tagfile directory:

tagfiles/
|-- a
|   |-- tagfile
|   `-- tagfile.org
|-- ap
|   |-- tagfile
|   `-- tagfile.org
|-- d
|   |-- tagfile
|   `-- tagfile.org
|-- e
|   |-- tagfile
|   `-- tagfile.org
|-- f
|   |-- tagfile
|   `-- tagfile.org
|-- gnome
|   |-- tagfile
|   `-- tagfile.org
|-- k
|   |-- tagfile
|   `-- tagfile.org
|-- kde
|   |-- tagfile
|   `-- tagfile.org
|-- kdei
|   |-- tagfile
|   `-- tagfile.org
|-- l
|   |-- tagfile
|   `-- tagfile.org
|-- n
|   |-- tagfile
|   `-- tagfile.org
|-- t
|   |-- tagfile
|   `-- tagfile.org
|-- tcl
|   |-- tagfile
|   `-- tagfile.org
|-- x
|   |-- tagfile
|   `-- tagfile.org
|-- xap
|   |-- tagfile
|   `-- tagfile.org
`-- y
    |-- tagfile
    `-- tagfile.org

This script too is just a simple BASH script. I feel allmost ashamed to put a copyright on it ;):

#! /bin/sh

# Yes this is BSD licensed. Everyone may do what they want with it, 
# I only want my name in the credits :-) 

# Copyright (c) 2005, Peter Kaagman <bilbo@nedlinux.nl>
# http://www.bilbos-stekkie.com
# All rights reserved. 

# Redistribution and use in source and binary forms, with or without 
# modification, are permitted provided that the following conditions 
# are met: 

# Redistributions of source code must retain the above copyright 
# notice, this list of conditions and the following disclaimer.

# Redistributions in binary form must reproduce the above copyright 
# notice, this list of conditions and the following disclaimer in the 
# documentation and/or other materials provided with the distribution. 

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
# PROFITS; ORBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Given a directory structure made by "mkorgstruct" this script will
# make tagfiles in that structure which will only install the 
# packages that were found in the current systems /var/log/packages.

# Some vars 
PKG_DIR="/var/log/packages"
CWD=`pwd`
TAG_DIR=${CWD}/tagfiles

# Process the .org files
for org in ${TAG_DIR}/*/tagfile.org ; do
  # Use the tagfile.org basename as name for the output file
  OUT_DIR=`dirname ${org}`
  OUT_FILE=`basename ${org} .org`

  # Write a little intro in the output file.
(  
  cat <<EOB
#  
# This file was created by "mkcpinstall" on `date`.
# The host on which it ran was "`hostname`" a `cat /etc/slackware-version` system.
#
EOB
) > ${OUT_DIR}/${OUT_FILE}

  #Read the package names from the tagfile.org file.
  for package in `grep -v ^# ${org}|cut -d: -f1`; do
    # See if this package is installed on the current system
    if [ -f ${PKG_DIR}/${package}-[0-9]* ]; then
      echo "${package}: ADD" >> $OUT_DIR/$OUT_FILE
    else  
      echo "${package}: SKP" >> $OUT_DIR/$OUT_FILE
    fi # package installed
  done # packages in .org file
done # processing .org files

All you need to do next is put the tagfiles directory on a floppy and you're ready to do an install based on these tagfiles.