#!/bin/sh
#
# mkpkglist - make a package list for the homepage
#

VERSION="1.0"

if [ -z "$1" -o "$1" = "-h" -o "$1" = "--help" ]; then
  echo "Usage: mkpkglist [FILE]..."
  echo "Make a nice package list for the ROOT homepage, using the"
  echo "file versions found in the present directory."
  echo
  echo " -h, --help		print this help and exit"
  echo " -v, --version		output version information and exit"
  echo
  echo "Report bugs to <johne@rootlinux.org>."
  exit
fi

if [ "$1" = "-v" -o "$1" = "--version" ]; then
  echo "mkpkglist $VERSION"
  exit
fi

if [ ! -d base ]; then
  echo "this does not seem to be a nice directory to be in, exiting."
  exit 1
fi

echo >$1
cat << EOF >>$1
<?
require_once('functions.php');
start_html();
?>

<h2>Package List for v1.4</h2>

<pre>
EOF

cd base

for i in base opt net mmedia gnbase gnopt kde wmaker x nonfree; do \
cd ../$i
echo -e "Category: $i/\n\n" >> ../$1
for file in *.gz; do
A=`echo $file | cut -f2 -d\#`
B=`echo $A | cut -f1 -d\-`
N=`echo $file | cut -f1 -d\#`
M=`echo $N | wc -m`

if [ $M = 2 -o $M = 3 -o $M = 4 -o $M = 5 -o $M = 6 -o $M = 7 ]; then
echo -e "$N:\t\t\t$B" >>../$1
elif [ $M = 8 -o $M = 9 -o $M = 10 -o $M = 11 -o $M = 12 -o $M = 13 -o \
$M = 14 -o $M = 15 ]; then
echo -e "$N:\t\t$B" >>../$1
else
echo -e "$N:\t$B" >>../$1
fi

done
echo -e "\n\n" >>../$1
done

cd ..

cat << EOF >>$1

</pre>

<?
end_html();
?>
EOF

# EOF

