#!/bin/bash
#
# $Id: archive-setup 70 2004-08-31 08:41:27Z guillem $
#
# Copyright (C) 2003, 2004 Guillem Jover <guillem@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
#

#
# Requires: procmail (formail)
#

# Import configuration

. archive-lib

create_apt_config ()
{
  cat > $apt_config <<-HERE
	Default {
	  Packages::Extensions	".deb .udeb";
	  Packages::Compress	". gzip bzip2";
	  Sources::Compress	". gzip bzip2";
	};

	Dir {
	  ArchiveDir		"$archive_dir";
	  OverrideDir		"$indices_dir";
	  CacheDir		"$cache_dir";
	  FileListDir		"$cache_dir";
	};

	TreeDefault {
	  Directory		"pool/";
	  SrcDirectory		"pool/";
	};
	
HERE

  for suite in $suite_list; do
    cat >> $apt_config <<-HERE
	Tree "dists/$suite" {
	  FileList		"files_${suite}_\$(ARCH).list";
	  Sections		"$section_list";
	  Architectures		"$(get_suite_arches $suite)";
	};

HERE
  done
}

create_repo ()
{
  if [ ! -d $incoming_dir ]; then
    mkdir -p $incoming_dir
  fi

  for suite in $suite_list; do
     for section in $section_list; do
      for arch in $(get_suite_arches $suite); do
        if [ $arch = source ]; then
          path_dir=$dists_dir/$suite/$section/$arch
        else
          path_dir=$dists_dir/$suite/$section/binary-$arch
        fi
        mkdir -p $path_dir
        cat > $path_dir/Release <<-HERE
		Archive: $archive_name
		Version: $archive_version
		Component: $suite/$section
		Origin: $archive_url
		Label: $archive_url
		Architecture: $arch
	HERE
        files_owner_perms $path_dir/Release
      done
    done
  done

  mkdir -p $cache_dir

  if [ ! -d $indices_dir ]; then
    mkdir -p $indices_dir
    touch $indices_dir/override
    touch $indices_dir/override.extra
  fi

  mkdir -p $queue_dir
  mkdir -p $unchecked_dir
  mkdir -p $accepted_dir
  mkdir -p $rejected_dir
  mkdir -p $byhand_dir

  mkdir -p $quinn_dir
  mkdir -p $log_dir

  if [ ! -d $pool_dir ]; then
    mkdir -p $pool_dir
  fi
}


create_repo
create_apt_config

