This file is indexed.

/usr/bin/citrain is in phablet-tools-citrain 1.2+16.04.20160317-0ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
#!/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]
$1

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.
EOF
exit 1
}

loudly () {
    echo adb shell "$@"
    adb shell "$@"
}

[ -x /usr/bin/sudo               ] || { echo "Please install 'sudo'"; exit 1; }
[ -x /usr/bin/add-apt-repository ] || { echo "Please install 'software-properties-common'"; exit 1; }

DIR=$(dirname "$0")
if [ -f "$DIR/shell-adb-common.sh" ]; then
    . "$DIR/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 "Missing COMMAND"

# Check that silo number is really a number.
echo "$1" | egrep -q "^[0-9]{1,3}$" || usage "SILO-NUMBER not a number."

# Read the second positional argument.
SILO=landing-$(echo "000$1" | rev | cut -c -3 | rev)
[ $# -gt 0 ] && shift || usage "Missing SILO-NUMBER."

case "$COMMAND" in
    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 "Missing DEVICE-PASSWORD"

        SERIES=$(adb shell lsb_release -cs | tr -d '\r')
        DISTRO=$(adb shell lsb_release -is | tr -d '\r' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')

        loudly egrep ^deb /etc/apt/sources.list.d/\*.list
        loudly "echo -e '#\x21/bin/sh\necho $PASSWORD' >/tmp/askpass.sh"
        loudly chmod +x /tmp/askpass.sh
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A touch /userdata/.adb_onlock
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A mount -o remount,rw /

        # Stable images have stable-snapshot PPA but sometimes we need to pull deps from overlay:
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A add-apt-repository -y "$PPA/$DISTRO/stable-phone-overlay"
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A add-apt-repository -y "$PPA/$DISTRO/$SILO"

        loudly "test -e /usr/sbin/policy-rc.d && cp /usr/sbin/policy-rc.d /tmp/policy-rc.d"
        loudly "echo 'exit 101' | SUDO_ASKPASS=/tmp/askpass.sh sudo -A tee /usr/sbin/policy-rc.d"
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A chmod +x /usr/sbin/policy-rc.d
        loudly "echo -e 'Package: *\nPin: release o=*$SILO*\nPin-Priority: 1100\n\nPackage: *\nPin: release a=$SERIES*\nPin-Priority: 50' | SUDO_ASKPASS=/tmp/askpass.sh sudo -A tee /etc/apt/preferences.d/extra-ppas.pref"
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A apt-get update

        # We need to put lxc-android-config on hold here as it's the only
        # package which must be upgrade by hand through the recovery. See
        # https://wiki.ubuntu.com/Touch/Testing/lxc-android-config for details.
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A apt-mark hold lxc-android-config

        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A apt-get dist-upgrade --yes --force-yes
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A apt-get autoremove --yes --force-yes

        loudly "test ! -e /tmp/policy-rc.d && SUDO_ASKPASS=/tmp/askpass.sh sudo -A rm /usr/sbin/policy-rc.d"
        loudly "test -e /tmp/policy-rc.d && SUDO_ASKPASS=/tmp/askpass.sh sudo -A mv /tmp/policy-rc.d /usr/sbin/policy-rc.d"
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A apt-mark unhold lxc-android-config
        loudly SUDO_ASKPASS=/tmp/askpass.sh sudo -A 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 "Unknown COMMAND."
        ;;
esac