#!/bin/sh

REPREPRO_BASE_DIR=/home/debian/raspbian_packages

if [ $# -lt 1 ]; then
    echo "Usage: $0 package [package ...]"
    exit 1
fi

export REPREPRO_BASE_DIR

for p in $*; do
    package=`echo $p | cut -d_ -f 1` # get canonical package name
    if [ -z $(echo $p | grep \.changes$) ]; then
        changes=$(ls -r ${package}*.changes 2>/dev/null | head -1)
    else
        changes=$p
    fi
    if [ -z "$changes" -o ! -f "$changes" ]; then
    	echo "$package not found. skipping."
    	continue
    fi
    reprepro include sid $changes
done

reprepro pull # add packages to testing as well

