diff -Nru goget-ubuntu-touch-0.33/debian/changelog goget-ubuntu-touch-0.34/debian/changelog --- goget-ubuntu-touch-0.33/debian/changelog 2016-04-05 10:23:15.000000000 +0000 +++ goget-ubuntu-touch-0.34/debian/changelog 2016-04-05 10:23:16.000000000 +0000 @@ -1,3 +1,11 @@ +goget-ubuntu-touch (0.34-0ubuntu1) xenial; urgency=medium + + [ Ondrej Kubik ] + * touch: new adb support with key support. by w-ondra approved by mvo + LP: #1316302 + + -- Michael Vogt Tue, 05 Apr 2016 12:21:07 +0200 + goget-ubuntu-touch (0.33-0ubuntu3) xenial; urgency=medium * remove support for building ubuntu-core (snappy) images diff -Nru goget-ubuntu-touch-0.33/diskimage/bootloader.go goget-ubuntu-touch-0.34/diskimage/bootloader.go --- goget-ubuntu-touch-0.33/diskimage/bootloader.go 2016-04-05 10:23:15.000000000 +0000 +++ goget-ubuntu-touch-0.34/diskimage/bootloader.go 2016-04-05 09:31:59.000000000 +0000 @@ -20,12 +20,12 @@ // with this program. If not, see . import ( + "fmt" "io" "os" "os/exec" "path/filepath" "strconv" - "fmt" "launchpad.net/goget-ubuntu-touch/sysutils" ) @@ -89,7 +89,7 @@ printOut("Setting up raw boot asset partitions for", imagePath, "...") var part int = partCount - for _, asset := range rawPartitions{ + for _, asset := range rawPartitions { part += 1 size, err := strconv.Atoi(asset.Size) diff -Nru goget-ubuntu-touch-0.33/diskimage/common.go goget-ubuntu-touch-0.34/diskimage/common.go --- goget-ubuntu-touch-0.33/diskimage/common.go 2016-04-05 10:23:15.000000000 +0000 +++ goget-ubuntu-touch-0.34/diskimage/common.go 2016-04-05 09:31:59.000000000 +0000 @@ -88,9 +88,9 @@ } type BootAssetRawPartitions struct { - Name string `yaml:"name"` - Size string `yaml:"size"` - Type string `yaml:"type"` + Name string `yaml:"name"` + Size string `yaml:"size"` + Type string `yaml:"type"` } type BootAssetFiles struct { @@ -102,8 +102,8 @@ } type BootAssets struct { - Files []BootAssetFiles `yaml:"files,omitempty"` - RawFiles []BootAssetRawFiles `yaml:"raw-files,omitempty"` + Files []BootAssetFiles `yaml:"files,omitempty"` + RawFiles []BootAssetRawFiles `yaml:"raw-files,omitempty"` RawPartitions []BootAssetRawPartitions `yaml:"raw-partitions,omitempty"` } @@ -208,7 +208,7 @@ partCount int size int64 rootSize int - label string + label string } // Mount mounts the image. This also maps the loop device. diff -Nru goget-ubuntu-touch-0.33/diskimage/core_grub.go goget-ubuntu-touch-0.34/diskimage/core_grub.go --- goget-ubuntu-touch-0.33/diskimage/core_grub.go 2016-04-05 10:23:15.000000000 +0000 +++ goget-ubuntu-touch-0.34/diskimage/core_grub.go 2016-04-05 09:31:59.000000000 +0000 @@ -46,7 +46,7 @@ hardware: hw, oem: oem, partCount: 5, - label: label, + label: label, }, legacyGrub: updateGrub, } diff -Nru goget-ubuntu-touch-0.33/diskimage/core_uboot.go goget-ubuntu-touch-0.34/diskimage/core_uboot.go --- goget-ubuntu-touch-0.33/diskimage/core_uboot.go 2016-04-05 10:23:15.000000000 +0000 +++ goget-ubuntu-touch-0.34/diskimage/core_uboot.go 2016-04-05 09:31:59.000000000 +0000 @@ -75,7 +75,7 @@ size: size, rootSize: rootSize, partCount: 4, - label: label, + label: label, }, } } diff -Nru goget-ubuntu-touch-0.33/ubuntu-device-flash/touch.go goget-ubuntu-touch-0.34/ubuntu-device-flash/touch.go --- goget-ubuntu-touch-0.33/ubuntu-device-flash/touch.go 2015-11-04 13:17:25.000000000 +0000 +++ goget-ubuntu-touch-0.34/ubuntu-device-flash/touch.go 2016-04-05 10:20:54.000000000 +0000 @@ -36,6 +36,7 @@ Wipe bool `long:"wipe" description:"Clear all data after flashing"` Serial string `long:"serial" description:"Serial of the device to operate"` DeveloperMode bool `long:"developer-mode" description:"Enables developer mode after the factory reset, this is meant for automation and makes the device insecure by default (requires --password)"` + AdbKeys string `long:"adb-keys" description:"Specify a local adb keys files, instead of using default ~/.android/adbkey.pub (requires --developer-mode)"` DeviceTarball string `long:"device-tarball" description:"Specify a local device tarball to override the one from the server (using official Ubuntu images with different device tarballs)"` CustomTarball string `long:"custom-tarball" description:"Specify a local custom tarball to override the one from the server (using official Ubuntu images with different custom tarballs)"` RunScript string `long:"run-script" description:"Run a script given by path to finish the flashing process, instead of rebooting to recovery (mostly used during development to work around quirky or incomplete recovery images)"` @@ -79,6 +80,30 @@ log.Fatal("Developer mode requires --password to be set (and --wipe or --bootstrap)") } + if touchCmd.AdbKeys != "" && !touchCmd.DeveloperMode { + log.Fatal("Adb keys requires --developer-mode to be set") + } + + var adbKeyPath string + if touchCmd.DeveloperMode { + if touchCmd.AdbKeys != "" { + p, err := expandFile(touchCmd.AdbKeys) + if err != nil { + log.Fatalln("Issues with custom adb keys file", err) + } + adbKeyPath = p + } else { + home := os.Getenv("HOME") + p, err := expandFile(filepath.Join(home, "/.android/adbkey.pub")) + if err != nil { + fmt.Println("WARNING: missing ~/.android/adbkey.pub, your device will not be preauthorised") + } else { + fmt.Println("no --adb-keys defined, using default ~/.android/adbkey.pub") + adbKeyPath = p + } + } + } + if touchCmd.Password != "" && !touchCmd.Wipe { log.Fatal("Default password setup requires --wipe or --bootstrap") } @@ -87,6 +112,10 @@ fmt.Println("WARNING --developer-mode and --password are dangerous as they remove security features from your device") } + if touchCmd.AdbKeys != "" && touchCmd.DeveloperMode { + fmt.Println("WARNING: --adb-keys is dangerous, potentially authorising multiple cliets to connect to your device") + } + var deviceTarballPath string if touchCmd.DeviceTarball != "" { p, err := expandFile(touchCmd.DeviceTarball) @@ -220,7 +249,13 @@ var enableList []string if touchCmd.DeveloperMode { enableList = append(enableList, "developer_mode") - enableList = append(enableList, "adb_onlock") + // provision target device with adbkeys if available + if adbKeyPath != "" { + err := touchCmd.adb.Push(adbKeyPath, "/cache/recovery/adbkey.pub") + if err == nil { + enableList = append(enableList, "adb_keys adbkey.pub") + } + } } if touchCmd.Password != "" { enableList = append(enableList, "default_password "+touchCmd.Password)