#!/bin/sh -eu

PART=base
MANIFEST=basesystem.manifest

CACHE="$TMPDIR/tmp/$$"

PKG_FILE="$SOURCE"/extra-packages.list

# Download packages from repos
Download() { # package [package ...]
  echo "Please note NOT ALL required packages will be downloaded" >&2
  mkdir -p "$CACHE/archives/partial"
  apt-get -o dir::cache="$CACHE" -y -d --reinstall install "$@"
}

echo "Inserting extra packages..."

Download `cat $PKG_FILE`
cp "$CACHE/archives"/*.rpm "$REPODIR/RPMS.$PART/"
( cd "$CACHE/archives"; ls *.rpm ) >> "$METADIR/$MANIFEST"
genbasedir --verbose --progress --topdir "$DEST" "$REPO"
rm -rf "$CACHE"

echo "Done."

