#!/bin/sh

if [ ! -f Release ]; then
    echo "This script must be run from the root of the apt repository"
    exit 1
fi

look_for_file(){
    echo "$1"
    if [ ! -f "$1" ]; then
        echo "$1 not found"
        exit 1
    fi
}

FILES=$(dcmd "$1")

if [ -z "$FILES" ]; then
    echo dcmd failed
    exit 1
fi

for f in $FILES; do
    look_for_file $f
done

pkgname=$(basename $1 | sed s/_.*//)
echo $pkgname

mkdir -p $pkgname
dcmd cp "$1" $pkgname/
make

