1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124 | #!/bin/sh -e
# This program is free software: you can redistribute it and/or modify it
# under the terms of the the GNU General Public License version 3, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
# PURPOSE. See the applicable version of 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/>.
#
# Copyright (C) 2014 Canonical, Ltd.
usage () {
cat <<EOF
usage: $0 COMMAND SILO-NUMBER [DEVICE-PASSWORD] [DISTRIBUTION]
COMMANDS:
host-install Deprecated. Please use host-upgrade instead.
device-install Deprecated. Please use device-upgrade instead.
host-upgrade Upgrades your host machine with packages from the silo.
device-upgrade Upgrades your connected device with packages from the silo.
host-purge Uses ppa-purge to uninstall the silo contents from the host machine.
device-purge Not implemented.
SILO-NUMBER:
0..30
DISTRIBUTION: (optional)
ubuntu
ubuntu-rtm
EOF
exit 1
}
[ -x /usr/bin/sudo ] || { echo "Please install 'sudo'"; exit 1; }
[ -x /usr/bin/add-apt-repository ] || { echo "Please install 'software-properties-common'"; exit 1; }
if [ -f "$(dirname $0)/shell-adb-common.sh" ]; then
. "$(dirname $0)/shell-adb-common.sh"
else
. "/usr/share/phabletutils/shell-adb-common.sh"
fi
# Defaults
PPA="ppa:ci-train-ppa-service"
# Read the first positional argument.
COMMAND="$1"
[ $# -gt 0 ] && shift || usage
# Check that silo number is really a number.
echo "$1" | egrep -q "^[0-9]{1,3}$" || usage
# Read the second positional argument.
SILO=landing-$(echo "000$1" | rev | cut -c -3 | rev)
[ $# -gt 0 ] && shift || usage
case "$COMMAND" in
host-install)
usage
;;
device-install)
usage
;;
host-upgrade)
set -x
sudo add-apt-repository $PPA/$SILO
sudo apt-get update -qq
sudo apt-get dist-upgrade --yes
;;
device-upgrade)
check_devices
# Read the third positional argument.
PASSWORD="$1"
[ $# -gt 0 ] && shift || usage
set -x
adb shell egrep ^deb /etc/apt/sources.list.d/\*.list
DISTRO="$1"
if [ -z $DISTRO ]; then
# In case no distro specified, guess
if adb shell system-image-cli -i | grep -q ubuntu-rtm; then
DISTRO="ubuntu-rtm"
else
DISTRO="ubuntu"
fi
fi
adb shell "echo -e '#\x21/bin/sh\necho $PASSWORD' >/tmp/askpass.sh"
adb shell chmod +x /tmp/askpass.sh
adb shell SUDO_ASKPASS=/tmp/askpass.sh sudo -A mount -o remount,rw /
adb shell SUDO_ASKPASS=/tmp/askpass.sh sudo -A add-apt-repository -y $PPA/$DISTRO/$SILO
adb shell "echo 'exit 101' | SUDO_ASKPASS=/tmp/askpass.sh sudo -A tee /usr/sbin/policy-rc.d"
adb shell cp /usr/sbin/policy-rc.d /tmp/policy-rc.d
adb shell SUDO_ASKPASS=/tmp/askpass.sh sudo -A chmod +x /usr/sbin/policy-rc.d
adb shell "echo -e 'Package: *\nPin: release o=LP-PPA-ci-train-ppa-service-$SILO\nPin-Priority: 1100' | SUDO_ASKPASS=/tmp/askpass.sh sudo -A tee /etc/apt/preferences.d/silo.pref"
adb shell SUDO_ASKPASS=/tmp/askpass.sh sudo -A apt-get -o Dir::Etc::SourceList=/dev/null update
adb shell SUDO_ASKPASS=/tmp/askpass.sh sudo -A apt-get dist-upgrade --yes --force-yes
adb shell SUDO_ASKPASS=/tmp/askpass.sh sudo -A cp /tmp/policy-rc.d /usr/sbin/policy-rc.d
adb shell rm -f /tmp/askpass.sh
adb reboot
;;
host-purge)
set -x
sudo ppa-purge $PPA/$SILO
;;
device-purge)
echo "Unfortunately purging from the device is unsupported because"
echo "ppa-purge is not installed by default in the images."
echo "However, the silo packages go away next time you flash the device."
;;
*)
usage
;;
esac
|