diff --git a/make-sdcard/main.go b/make-sdcard/main.go index 6253ac7..4d0cb41 100644 --- a/make-sdcard/main.go +++ b/make-sdcard/main.go @@ -4,6 +4,7 @@ import "log" import "fmt" import "strings" import "reflect" +import "os" import "os/exec" import "bytes" @@ -66,19 +67,26 @@ func format(mybut *ui.Button) { // exampleCommand("ls", "/tmp") // stdoutExec("ls /tmp", 50) // ping("git.wit.com", 5) - // simpleScanner("ping git.wit.com") - // simpleScanner("dd if=/home/pinebook/factory/factory-pine14inch of=/dev/sdb status=progress bs=1M oflag=sync count=300"); - // simpleScanner("dd if=/home/pinebook/factory/factory-pine14inch of=/dev/sdb status=progress bs=1M oflag=sync count=300"); - simpleScanner("parted /dev/sdb mklabel msdos") - simpleScanner("parted /dev/sdb mkpart primary ext4 1MiB 8GB") - simpleScanner("parted /dev/sdb mkpart primary ext4 8GB 32GB") - simpleScanner("sleep 1") - simpleScanner("mkfs.ext4 /dev/sdb1") - simpleScanner("mkfs.ext4 /dev/sdb2") - simpleScanner("e2label /dev/sdb1 root") - simpleScanner("e2label /dev/sdb2 factory-image") - simpleScanner("mount /dev/sdb1 /mnt/sdcard/") - simpleScanner("dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1K seek=8") + // simpleProcess("ping git.wit.com") + // simpleProcess("dd if=/home/pinebook/factory/factory-pine14inch of=/dev/sdb status=progress bs=1M oflag=sync count=300"); + // simpleProcess("dd if=/home/pinebook/factory/factory-pine14inch of=/dev/sdb status=progress bs=1M oflag=sync count=300"); + + simpleProcess("pwd") + simpleProcess("ls -l") + os.Chdir("/mnt") + simpleProcess("pwd") + simpleProcess("ls -l") + return + simpleProcess("parted -s /dev/sdb mklabel msdos") + simpleProcess("parted -s /dev/sdb mkpart primary ext4 1MiB 8GB") + simpleProcess("parted -s /dev/sdb mkpart primary ext4 8GB 32GB") + simpleProcess("sleep 1") + simpleProcess("mkfs.ext4 /dev/sdb1") + simpleProcess("mkfs.ext4 /dev/sdb2") + simpleProcess("e2label /dev/sdb1 root") + simpleProcess("e2label /dev/sdb2 factory-image") + simpleProcess("mount /dev/sdb1 /mnt/sdcard/") + simpleProcess("dd if=../u-boot/u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1K seek=8") } func hostnameButton(hostname string, something func(*ui.Button)) ui.Control { diff --git a/make-sdcard/ping.go b/make-sdcard/ping.go index 5bfaa02..ad30bee 100644 --- a/make-sdcard/ping.go +++ b/make-sdcard/ping.go @@ -7,6 +7,8 @@ import "io" import "os" import "os/exec" import "bufio" +import "reflect" +import "github.com/davecgh/go-spew/spew" /* func exampleCommand(a string, b ...string) { @@ -62,7 +64,8 @@ func ping(hostname string, count int) { cmd.Wait() } -func simpleScanner(cmd string) { +// Spawns a process and captures stdout and stderr +func simpleProcess(cmd string) { log.Println("START " + cmd) // cmd := exec.Command("ls", "/tmp", "/ballon", "/") @@ -72,7 +75,12 @@ func simpleScanner(cmd string) { stderr, _ := process.StderrPipe() process.Start() - fmt.Println("start ls /tmp") + pid := process.Process.Pid + fmt.Println("start ls /tmp pid =", pid) + log.Println(reflect.ValueOf(process.Process).Elem()) + log.Println(reflect.TypeOf(process.Process)) + spew.Dump(process) + merged := io.MultiReader(stderr, stdout) scanner := bufio.NewScanner(merged) @@ -84,6 +92,9 @@ func simpleScanner(cmd string) { // fmt.Fprintln(os.Stderr, "reading standard input:", err) fmt.Println("reading standard input:", err) } + + // One must wait for the process to formally finish and flush all buffer output + process.Wait() log.Println("END " + cmd) } diff --git a/make-sdcard/u-boot-sunxi-with-spl.bin b/make-sdcard/u-boot-sunxi-with-spl.bin deleted file mode 100644 index db0c9f9..0000000 Binary files a/make-sdcard/u-boot-sunxi-with-spl.bin and /dev/null differ