#!/bin/sh
# Author: Didier Spaier, Paris, France
#
# Before running this script, adapt the paths to your installation.
CWD=$(pwd)
SLACKVERSION="14.2"
usage() {
  printf %b "Usage: $0 stable|testing\n"
  exit
}
if [ $# -ne 1 ]; then usage; fi

#if [ "$1" = "stable" ]; then echo "Not yet!"; exit; fi 
#if [ ! "$1" = "testing" ]; then usage; fi 
CWD=$(pwd)
SLACKVERSION="14.2"
SFX=64
MIRRORSLACKWARE=/data/slackware${SFX}-$SLACKVERSION
DATESTAMP=`date +%Y%m%d`
PKGLISTS="pkg_lists/$1/$DATESTAMP/"
ISO=/data/iso64
rm -rf $ISO
mkdir -p $ISO/slint/locales
# First step install the packages and write the metadata
# ======================================================
#
# packages under slackware/ but in kdei/
echo "Copy packages from slackware..."
for PACKAGE in $(<$PKGLISTS/slackware); do
  cp $PACKAGE $ISO/slint
done
echo "Copy packages from slackware_locales..."
for PACKAGE in $(<$PKGLISTS/slackware_locales); do
  cp $PACKAGE $ISO/slint/locales
done
echo "Copy packages from slint..."
for PACKAGE in $(<$PKGLISTS/slint); do
  cp $PACKAGE $ISO/slint
done
echo "Copy packages from slint_locales..."
for PACKAGE in $(<$PKGLISTS/slint_locales); do
  cp $PACKAGE $ISO/slint/locales
done
echo "Copy packages from flite_voices..."
for PACKAGE in $(<$PKGLISTS/flite_voices); do
  cp $PACKAGE $ISO/slint
done
echo "Copy packages from mbrola_voices..."
for PACKAGE in $(<$PKGLISTS/mbrola_voices); do
  cp $PACKAGE $ISO/slint
done
echo "Copy packages from patches..."
for PACKAGE in $(<$PKGLISTS/patches); do
  cp $PACKAGE $ISO/slint
done
cp /storage/repo/x86_64/slint-$1/slint/DONOTREMOVEME.TXT $ISO/slint
printf "%b" "Write the metadata. This can take a while...\n"
# Write the metadata
( cd $ISO
printf "%b" "Running metagen all...\n"
$CWD/metagen.sh all
printf "%b" "Running metagen clean...\n"
$CWD/metagen.sh clean
printf "%b" "Running metagen md5...\n"
$CWD/metagen.sh md5
)
echo "All done."
