#!/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
}
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=/storage/salix/i486/extra-$SLACKVERSION/salix
else
	MIRRORSALIX=/storage/salix/x86_64/$SLACKVERSION/salix
	MIRROREXTRA=/storage/salix/x86_64/extra-$SLACKVERSION/salix
fi
SFX=$(echo $1|grep 64)
SLINTREPO=../..
MIRRORSLACKWARE=/storage/slackware${SFX}-$SLACKVERSION
DATESTAMP=`date +%Y%m%d`
rm -rf pkg_lists/$1/$DATESTAMP
mkdir pkg_lists/$1/$DATESTAMP
cp pkg_lists/replaced_packages pkg_lists/$1/$DATESTAMP/replaced
for SERIES in a ap d e f k kde l n t tcl x xap xfce y; do
  for i in $(find $MIRRORSLACKWARE/slackware$SFX/$SERIES/ -name "*t?z"); do
	echo $i >> pkg_lists/$1/$DATESTAMP/slackware
  done
done
for i in $(find $MIRRORSLACKWARE/slackware$SFX/kdei/ -name "*t?z"); do
  echo $i >> pkg_lists/$1/$DATESTAMP/slackware_locales
done
for i in $(find $MIRRORSLACKWARE/extra/aspell-word-lists/ -name "*t?z"); do
  echo $i >> pkg_lists/$1/$DATESTAMP/slackware_locales
done
for i in $(find $SLINTREPO/slint -name "*t?z"|grep -v installer); do
    echo $i >> pkg_lists/$1/$DATESTAMP/slint
done
for i in $(find $MIRRORSLACKWARE/patches/packages -name "*t?z"); do
    echo $i >> pkg_lists/$1/$DATESTAMP/patches
done
for i in $(<pkg_lists/Salix); do
  find $MIRRORSALIX -name "${i}*t?z" >> pkg_lists/$1/$DATESTAMP/salix
done
for i in $(<pkg_lists/SalixLocales); do
  find $MIRRORSALIX -name "${i}*t?z" >> pkg_lists/$1/$DATESTAMP/salix_locales
done
for i in $(<pkg_lists/Extra); do
  find $MIRROREXTRA -name "${i}*t?z" >> pkg_lists/$1/$DATESTAMP/salix_extra
done
echo "All done."
