#!/bin/bash

set -x

REPO_NAME="removepackages"
REPO_DIR="/usr/share/volatile/"
REPO_PLACE="$REPO_DIR/$REPO_NAME"
DEB_ARCHIVE_DIR="$REPO_PLACE/archives"
#SOURCE_LISTS_PLACE=$REPO_PLACE
SOURCE_LISTS_PLACE=/etc
SOURCE_LISTS_DIR="$SOURCE_LISTS_PLACE/apt/sources.list.d"
SOURCE_LISTS_FILE="$SOURCE_LISTS_DIR/$REPO_NAME.list"
SOURCE_LISTS_SAVES="$REPO_PLACE/lists"

mkdir -p $SOURCE_LISTS_SAVES $SOURCE_LISTS_DIR $DEB_ARCHIVE_DIR
cp config-remove-ubuntuone-precise-all_1.3_amd64.deb $DEB_ARCHIVE_DIR
#cp *.deb $DEB_ARCHIVE_DIR

cd $DEB_ARCHIVE_DIR
dpkg-scanpackages --multiversion . /dev/null > Packages

echo "deb file://$DEB_ARCHIVE_DIR /" > $SOURCE_LISTS_FILE

#apt-get update -o Dir::Etc::SourceParts="$SOURCE_LISTS_DIR" -o Dir::Etc::SourceList="$SOURCE_LISTS_FILE" -o Dir::State::Lists="$SOURCE_LISTS_SAVES"
#apt-get install -o Dir::Etc::SourceParts="$SOURCE_LISTS_DIR" -o Dir::Etc::SourceList="$SOURCE_LISTS_FILE" -o Dir::State::Lists="$SOURCE_LISTS_SAVES" -y --force-yes config-remove-ubuntuone-precise-all
#rm -rf $REPO_PLACE
