#!/bin/sh

# Copyright 1999 Raphal Hertzog <hertzog@debian.org>
# See the README file for the license

# This script will create the Sources.gz files
# First arg = directory of the CD

set -e

PREFIX=$1
if [ -n "$NONFREE" -o -n "$EXTRANONFREE" ]; then
  SECTIONS="main contrib non-free"
else
  SECTIONS="main contrib"
fi

cd $PREFIX

for SECT in $SECTIONS; do

	dpkg-scansources dists/$CODENAME/$SECT/source \
        | gzip --best > dists/$CODENAME/$SECT/source/Sources.gz 
   
	if [ -n "$NONUS" -a "$CODENAME" != "slink" ]; then
 		 dpkg-scansources dists/$CODENAME/non-US/$SECT/source \
                 | gzip --best > dists/$CODENAME/non-US/$SECT/source/Sources.gz
	fi
	
done

# Slink special case
if [ -n "$NONUS" -a "$CODENAME" = "slink" ]; then
	dpkg-scansources dists/$CODENAME/non-US/source \
	| gzip --best > dists/$CODENAME/non-US/source/Sources.gz
fi

if [ -n "$LOCAL" ]; then
	dpkg-scansources dists/$CODENAME/local/source \
	| gzip --best > dists/$CODENAME/local/source/Sources.gz
fi

exit 0
