#!/bin/bash
# This script creates a very basic debian package repo
# Note - this script has no side effects so it can be re-run

repo_base=/var/www/debian

mkdir -p $repo_base
cd $repo_base

if [ ! -e "$repo_base/apt-ftparchive.conf" ];then
  echo "No repo config file found at $repo_base/apt-ftparchive.conf."
  exit 1
fi

# the type of packages we want to support
dists="etch lenny"
components="main contrib nonfree"
architectures="binary-i386 source"

# make sure we've got the command we need
# assume we already have a webserver running - did apt-get install apache2
apt-get install apt-utils bzip2

mkdir -p dists/packages .scratch dists/pool/main/

for dist in `echo $dists`;do
  for component in `echo $components`;do
    for arch in `echo $architectures`;do
      mkdir -p dists/$dist/$component/$arch/
    done
  done
done

chmod -R a+rX $repo_base/dists/

# run after you've added a package
apt-ftparchive generate $repo_base/apt-ftparchive.conf

