#!/usr/bin/env python
#
# Copyright 2017 Google Inc.
#
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


"""Upgrade a bot via apt-get, then reboot. Aborts on error."""


import subprocess

# Copied from
# https://skia.googlesource.com/buildbot/+/d864d83d992f2968cf4d229cebf2d3104ee11ebf/go/gce/swarming/base-image/setup-script.sh#20
base_cmd = ['sudo', 'DEBIAN_FRONTEND=noninteractive', 'apt',
            '-o', 'quiet=2', '--assume-yes',
            '-o', 'Dpkg::Options::=--force-confdef',
            '-o', 'Dpkg::Options::=--force-confold']

subprocess.check_call(base_cmd + ['update'])
subprocess.check_call(base_cmd + ['full-upgrade'])
subprocess.check_call(base_cmd + ['autoremove'])

subprocess.check_call(['sudo', 'reboot'])

Add script to upgrade Debian/Ubuntu bots.
Add script to upgrade Debian/Ubuntu bots.

Bug: skia:6890
Change-Id: I30eea5d64c502ac7ef51cf2d8f6ef3c583e60b3e
Reviewed-on: https://skia-review.googlesource.com/28840
Commit-Queue: Ben Wagner <3ef7217be91069877d94f7907ce5479000772cd3@google.com>
Reviewed-by: Eric Boren <0e499112533c8544f0505ea0d08394fb5ad7d8fa@google.com>
