#!/bin/tcsh -f
# JLdL 02Nov19.
#
# Make all the Packages files for the Debian Cluster packages,
# _ for the "amd64" and "all" architecture versions; however,
# _ the "all" packages are distributed do the "i386" arch.
#
# Define the current stable distribution.
set dist = stable
#
# Define the set of binary architectures supported.
set arches = ( amd64 )
#
# Define the set of distribution sections supported.
set sectns = ( main contrib non-free )
#
# Hard-link the "all" packages within the other directories.
#
# Loop over the supported binary architectures.
foreach arch ( $arches )
    #
    # Loop over the sections.
    foreach sect ( $sectns )
	#
	# Remove any old versions of the "all" packages.
	rm -f dists/stable/$sect/binary-$arch/*_all.deb >& /dev/null
	#
	# Loop over the "all" packages.
	foreach p ( `ls dists/stable/$sect/binary-all/` )
	    #
	    # Hard-link the package.
	    ln -f dists/stable/$sect/binary-all/$p \
		  dists/stable/$sect/binary-$arch/$p
	    #
	end
    end
end
#
# Update the packages files.
#
# Loop over the supported architectures.
foreach arch ( $arches )
    #
    # Loop over the sections.
    foreach sect ( $sectns )
	#
	# Do it.
	echo "\nstable $arch ${sect}:"
	dpkg-scanpackages \
		dists/stable/$sect/binary-$arch \
		indices/override.$dist.$sect.gz \
		>! dists/stable/$sect/binary-$arch/Packages
	rm -f dists/stable/$sect/binary-$arch/Packages.gz
	gzip -9 dists/stable/$sect/binary-$arch/Packages
	#
    end
    #
end
