#!/bin/sh

scriptname=$(basename "$1")

if [ $# != 1 ] ; then
  echo "Usage: $scriptname <changes_file>"
  exit 1
fi

if [ ! -e "$1" ] ; then
  echo "No such file $1"
  exit 1
fi

if ! echo "$1" | grep -q '_amd64.changes$' ; then
  echo "File $1 does not seem to be a changes file"
  exit 1
fi

if [ ! -x /usr/sbin/piuparts ] ; then
  sudo apt install piuparts
fi

sudo /usr/sbin/piuparts --allow-database --fail-on-broken-symlinks  --warn-on-leftovers-after-purge --no-upgrade-test -d stable -d sid --distupgrade-to-testdebs "$1"

exit 0

#       $ sudo piuparts \                                                                                                                                                                                            
#               --testdebs-repo='deb [trusted=true] http://[::1]/~emollier/repos experimental main' \                                                                                                                
#               --distupgrade-to-testdebs \                                                                                                                                                                          
#               --warn-on-leftovers-after-purge \                                                                                                                                                                    
#               --distribution=buster \                                                                                                                                                                              
#               --distribution=bullseye \                                                                                                                                                                            
#               --apt r-cran-dt=0.17+dfsg-3                                                                                                                                                                          
#                                                                                                                                                                                                                    
#       $ sudo piuparts \                                                                                                                                                                                            
#               --testdebs-repo='deb [trusted=true] http://[::1]/~emollier/repos experimental main' \                                                                                                                
#               --distupgrade-to-testdebs \                                                                                                                                                                          
#               --warn-on-leftovers-after-purge \                                                                                                                                                                    
#               --distribution=bullseye \                                                                                                                                                                            
#               --apt r-cran-dt=0.17+dfsg-3              

