#!/bin/sh
# -*- indent-tabs-mode: t; tab-width: 2 -*-
#
# Copyright 2009-2012 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Expected arguments:
# 1 is sources.list file to add
# 2 is a list of extra packages to install

set -e

if grep "https://" "$1"; then
	apt-get --assume-yes --force-yes install apt-transport-https
fi

cat "$1" >> /etc/apt/sources.list

apt-get update

if [ -n "$2" ]; then
	apt-get --assume-yes --force-yes install $2
fi

apt-get --assume-yes --force-yes dist-upgrade

