#!/bin/sh
# Author: Didier Spaier, Paris, France
#
# Before running this script, adapt MIRROR* and SLINTREPO below to your
# installation.
#
CWD=$(pwd)
SLACKVERSION="14.2"
SLINTVERSION="14.2"
usage() {
  printf %b "Usage: $0 32|64\n"
  exit
}
MIRROR=http://slackware.uk/salix
if [ $# -ne 1 ]; then usage; fi
if [ $1 -ne 32 ] && [ $1 -ne 64 ]; then usage; fi
if [ $1 -eq 32 ]; then
	MIRRORSALIX=/storage/salix/i486/$SLACKVERSION/salix
	MIRROREXTRA=$MIRROR/i486/extra-$SLACKVERSION
else
	MIRRORSALIX=/storage/salix/i486/$SLACKVERSION/salix
	MIRROREXTRA=$MIRROR/x86_64/extra-$SLACKVERSION
fi
SFX=$(echo $1|grep 64)
SLINTREPO=../..
MIRRORSLACKWARE=/storage/slackware${SFX}-$SLACKVERSION
#DATESTAMP=`date -u +%Y%m%d`
DATESTAMP=20170110
#if [ ! $UID -eq 0 ]; then
#  printf "%b"  "Please execute this script as root.\n"
#  exit
#fi
ISO=/tmp/iso$SFX
rm -rf $ISO
mkdir -p $ISO/slint/locales
# First step install the packages and write the metadata
# ======================================================
#
printf "%b" "Remove the obsolete packages...\n"
# packages replaced by those in patches/
for i in $(<pkg_lists/$1/$DATESTAMP/patches); do
	FILE=$(basename $i|sed "s/\(.\)[^-]*-[^-]*-[^-]*$/\1/")
    echo $FILE
done
