diff -Nru goget-ubuntu-touch-0.3+14.10.20140619/debian/changelog goget-ubuntu-touch-0.3+14.10.20140709/debian/changelog --- goget-ubuntu-touch-0.3+14.10.20140619/debian/changelog 2014-07-09 09:30:13.000000000 +0000 +++ goget-ubuntu-touch-0.3+14.10.20140709/debian/changelog 2014-07-09 09:30:13.000000000 +0000 @@ -1,3 +1,19 @@ +goget-ubuntu-touch (0.3+14.10.20140709-0ubuntu1) utopic; urgency=low + + [ Ubuntu daily release ] + * New rebuild forced + + [ Sergio Schvezov ] + * ubuntu-emulator: add option to create a vfat formatted sdcard image. + * ubuntu-emulator: launch emulator from android source tree if the + build env is setup. + + [ Jani Monoses ] + * ubuntu-device-flash: Add --device-tarball flag to allow flashing a + tarball from the local disk. + + -- Ubuntu daily release Wed, 09 Jul 2014 08:53:17 +0000 + goget-ubuntu-touch (0.3+14.10.20140619-0ubuntu1) utopic; urgency=low [ Ricardo Salveti de Araujo ] diff -Nru goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-device-flash/args.go goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-device-flash/args.go --- goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-device-flash/args.go 2014-06-19 14:36:39.000000000 +0000 +++ goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-device-flash/args.go 2014-07-09 08:52:48.000000000 +0000 @@ -31,6 +31,7 @@ Wipe bool `long:"wipe" description:"Clear all data after flashing"` Channel string `long:"channel" description:"Specify an alternate channel"` Device string `long:"device" description:"Specify the device to flash"` + DeviceTarball string `long:"device-tarball" description:"Specify a local device tarball to override the one from the server (using official Ubuntu images with custom device tarballs)"` Serial string `long:"serial" description:"Serial of the device to operate"` Server string `long:"server" description:"Use a different image server"` CleanCache bool `long:"clean-cache" description:"Cleans up cache with all downloaded bits"` diff -Nru goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-device-flash/main.go goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-device-flash/main.go --- goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-device-flash/main.go 2014-06-19 14:36:39.000000000 +0000 +++ goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-device-flash/main.go 2014-07-09 08:52:48.000000000 +0000 @@ -31,6 +31,7 @@ "os/exec" "path/filepath" "strings" + "syscall" "launchpad.net/goget-ubuntu-touch/devices" "launchpad.net/goget-ubuntu-touch/ubuntuimage" @@ -55,10 +56,26 @@ if err != nil { log.Fatal(err) } - if fi.Mode()&0100 == 0 { + if fi.Mode()&0100 == 0 || !fi.Mode().IsRegular() { log.Fatalf("The script %s passed via --run-script is not executable", script) } } + + tarballPath := args.DeviceTarball + if tarballPath != "" { + if p, err := filepath.Abs(tarballPath); err != nil { + log.Fatal("Device tarball not found", err) + } else { + tarballPath = p + } + fi, err := os.Lstat(tarballPath) + if err != nil { + log.Fatal(err) + } + if !fi.Mode().IsRegular() { + log.Fatalf("The file %s passed via --device-tarball is not a regular file\n", tarballPath) + } + } channels, err := ubuntuimage.NewChannels(args.Server) if err != nil { log.Fatal(err) @@ -130,8 +147,15 @@ totalFiles := len(image.Files) + len(signFiles) files := make(chan Files, totalFiles) done := make(chan bool, totalFiles) - for _, file := range image.Files { - go bitDownloader(file, files, args.Server, cacheDir) + for i, file := range image.Files { + if tarballPath != "" && strings.HasPrefix(file.Path, "/pool/device") { + //change the file paths so they are correctly picked up by bitPusher later on + image.Files[i].Path = tarballPath + image.Files[i].Signature = tarballPath + ".asc" + useLocalTarball(image.Files[i], files) + } else { + go bitDownloader(file, files, args.Server, cacheDir) + } } for _, file := range signFiles { go bitDownloader(file, files, args.Server, cacheDir) @@ -222,8 +246,23 @@ } } +// ensureExists touches a file. It can be used to create a dummy .asc file if none exists +func ensureExists(path string) { + f, err := os.OpenFile(path, syscall.O_WRONLY|syscall.O_CREAT, 0666) + if err != nil { + log.Fatal("Cannot touch %s : %s", path, err) + } + f.Close() +} + type Files struct{ FilePath, SigPath string } +// useLocalTarball adds a local file to the ones to be pushed +func useLocalTarball(file ubuntuimage.File, files chan<- Files) { + ensureExists(file.Signature) + files <- Files{FilePath: file.Path, SigPath: file.Signature} +} + // bitDownloader downloads func bitDownloader(file ubuntuimage.File, files chan<- Files, server, downloadDir string) { err := file.MakeRelativeToServer(server) diff -Nru goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-emulator/create.go goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-emulator/create.go --- goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-emulator/create.go 2014-06-19 14:36:39.000000000 +0000 +++ goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-emulator/create.go 2014-07-09 08:52:56.000000000 +0000 @@ -37,6 +37,7 @@ Server string `long:"server" description:"Select image server"` Revision int `long:"revision" description:"Select revision"` RawDisk bool `long:"use-raw-disk" description:"Use raw disks instead of qcow2"` + SDCard bool `long:"with-sdcard" description:"Create an external vfat sdcard"` Arch string `long:"arch" description:"Device architecture to use (i386 or armhf)"` } @@ -152,6 +153,14 @@ } } + if createCmd.SDCard { + fmt.Println("Creating vfat sdcard...") + sdcard := diskimage.New(filepath.Join(dataDir, "sdcardprime.img"), "SDCARD", 2) + if err := sdcard.CreateVFat(); err != nil { + return err + } + } + if err = sysutils.WriteStamp(dataDir, image); err != nil { return err } @@ -172,7 +181,7 @@ func createSystem(ubuntuImage, sdcardImage *diskimage.DiskImage, files []string) (err error) { for _, img := range []*diskimage.DiskImage{ubuntuImage, sdcardImage} { - if err := img.Create(); err != nil { + if err := img.CreateExt4(); err != nil { return err } } diff -Nru goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-emulator/diskimage/image.go goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-emulator/diskimage/image.go --- goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-emulator/diskimage/image.go 2014-06-19 14:36:39.000000000 +0000 +++ goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-emulator/diskimage/image.go 2014-07-09 08:52:56.000000000 +0000 @@ -147,15 +147,19 @@ } //Create returns a ext4 partition for a given file -func (img DiskImage) Create() error { +func (img DiskImage) CreateExt4() error { if err := sysutils.CreateEmptyFile(img.path, img.size); err != nil { return err } - if err := exec.Command("mkfs.ext4", "-F", "-L", - img.label, img.path).Run(); err != nil { + return exec.Command("mkfs.ext4", "-F", "-L", img.label, img.path).Run() +} + +//Create returns a vfat partition for a given file +func (img DiskImage) CreateVFat() error { + if err := sysutils.CreateEmptyFile(img.path, img.size); err != nil { return err } - return nil + return exec.Command("mkfs.vfat", "-n", img.label, img.path).Run() } //unpackSystem moves the system partition up one level diff -Nru goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-emulator/run.go goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-emulator/run.go --- goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-emulator/run.go 2014-06-19 14:36:39.000000000 +0000 +++ goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-emulator/run.go 2014-07-09 08:53:06.000000000 +0000 @@ -22,10 +22,12 @@ import ( "errors" "fmt" - "launchpad.net/goget-ubuntu-touch/ubuntu-emulator/sysutils" "os" "os/exec" + "path" "path/filepath" + + "launchpad.net/goget-ubuntu-touch/ubuntu-emulator/sysutils" ) type RunCmd struct { @@ -39,10 +41,11 @@ var runCmd RunCmd const ( - defaultMemory = "512" - defaultScale = "1.0" - defaultSkin = "EDGE" - emulatorCmd = "/usr/share/android/emulator/out/host/linux-x86/bin/emulator" + defaultMemory = "512" + defaultScale = "1.0" + defaultSkin = "EDGE" + installPath = "/usr/share/android/emulator" + subpathEmulatorCmd = "out/host/linux-x86/bin/emulator" ) var skinDirs = []string{ @@ -51,13 +54,19 @@ "/usr/share/android/emulator/development/tools/emulator/skins", } +var extendedRunHelp string = "Runs a new emulator instance name 'name' which " + + "was previously created. If the ANDROID_BUILD_TOP envionment variable is " + + "found, used during Android side development, the emulator runtime will " + + "be executed from there if possible. ANDROID_BUILT_TOP is set after an " + + "android 'lunch' target is selected." + func init() { runCmd.Skin = defaultSkin runCmd.Scale = defaultScale runCmd.Memory = defaultMemory parser.AddCommand("run", "Run emulator instance named 'name'", - "Runs a new emulator instance name 'name' which was previously created", + extendedRunHelp, &runCmd) } @@ -88,7 +97,7 @@ } ramdisk := bootRamdisk - if (runCmd.Recovery) { + if runCmd.Recovery { ramdisk = recoveryRamdisk } cmdOpts := []string{ @@ -121,6 +130,8 @@ return err } + emulatorCmd := getEmulatorCmd() + cmd := exec.Command(emulatorCmd, cmdOpts...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr @@ -132,6 +143,16 @@ return nil } +func getEmulatorCmd() string { + androidTree := os.Getenv("ANDROID_BUILD_TOP") + cmd := path.Join(androidTree, subpathEmulatorCmd) + if fInfo, err := os.Stat(cmd); err == nil && fInfo.Mode()&0111 != 0 { + fmt.Println("Using", cmd, "for the emulator runtime") + return cmd + } + return path.Join(installPath, subpathEmulatorCmd) +} + func getSkinDir(skin string) (string, error) { for _, skinDir := range skinDirs { if dir, err := os.Stat(skinDir); err != nil || !dir.IsDir() { diff -Nru goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-emulator/run_test.go goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-emulator/run_test.go --- goget-ubuntu-touch-0.3+14.10.20140619/ubuntu-emulator/run_test.go 1970-01-01 00:00:00.000000000 +0000 +++ goget-ubuntu-touch-0.3+14.10.20140709/ubuntu-emulator/run_test.go 2014-07-09 08:53:06.000000000 +0000 @@ -0,0 +1,57 @@ +/* + * Copyright 2014 Canonical Ltd. + * + * Authors: + * Sergio Schvezov: sergio.schvezov@canonical.com + * + * This file is part of ubuntu-emulator. + * + * ubuntu-emulator 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. + * + * ubuntu-emulator 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 . + */ + +package main + +import ( + "os" + "path/filepath" + "testing" + . "launchpad.net/gocheck" +) + +var _ = Suite(&EmulatorRunTestSuite{}) + +type EmulatorRunTestSuite struct { + tmpDir string +} + +func (s *EmulatorRunTestSuite) SetUpTest(c *C) { + s.tmpDir = c.MkDir() +} + +func Test(t *testing.T) { TestingT(t) } + +func (s *EmulatorRunTestSuite) TestRunPathInstalled(c *C) { + c.Assert(getEmulatorCmd(), Equals, filepath.Join(installPath, subpathEmulatorCmd)) +} + +func (s *EmulatorRunTestSuite) TestRunPathAndroidTree(c *C) { + emuCmd := filepath.Join(s.tmpDir, subpathEmulatorCmd) + os.MkdirAll(filepath.Dir(emuCmd), 0777) + cmdFile, err := os.Create(emuCmd) + c.Assert(err, IsNil) + cmdFile.Chmod(0755) + cmdFile.Close() + c.Assert(os.Setenv("ANDROID_BUILD_TOP", s.tmpDir), IsNil) + c.Assert(getEmulatorCmd(), Equals, emuCmd) + c.Assert(os.Setenv("ANDROID_BUILD_TOP", ""), IsNil) +}