From c81d0cd50f6cd0e2f6966a6d3c377a61bbefdb20 Mon Sep 17 00:00:00 2001 From: Yi Gu Date: Mon, 23 Mar 2015 00:51:12 -0700 Subject: [PATCH] [android] remove redundant makefile and go_script folder --- Makefile | 30 -- .../common/args/parse/args.go | 10 - .../common/args/parse/config.go | 14 - .../common/log/colorized_log.go | 28 -- .../common/log/file_and_stdout_logger.go | 26 - .../common/log/logger_test.go | 30 -- .../common/log/silent_logger.go | 15 - .../common/log/stdout_logger.go | 8 - .../src/mobile.ooyala.com/common/path/path.go | 198 -------- .../common/path/path_test.go | 54 --- .../src/mobile.ooyala.com/common/platforms.go | 4 - .../common/testutil/testutil.go | 64 --- .../src/mobile.ooyala.com/common/util/dbc.go | 22 - .../mobile.ooyala.com/common/util/errors.go | 33 -- .../common/util/is_zeroer.go | 5 - .../src/mobile.ooyala.com/common/util/util.go | 444 ------------------ .../common/util/util_test.go | 127 ----- .../clean_sample_apps/clean_sample_apps.go | 57 --- .../sample_app_config/sample_app_config.go | 75 --- .../config/vendor_config/vendor_config.go | 81 ---- .../samples/config/zip_config/zip_config.go | 52 -- .../copy_from_vendor/copy_from_vendor.go | 58 --- .../samples/get_latest_rc/get_latest_rc.go | 79 ---- .../get_latest_release/get_latest_release.go | 80 ---- .../merge_into_complete_sample_app.go | 44 -- .../update_from_target_location.go | 127 ----- 26 files changed, 1765 deletions(-) delete mode 100644 Makefile delete mode 100644 go_script/src/mobile.ooyala.com/common/args/parse/args.go delete mode 100644 go_script/src/mobile.ooyala.com/common/args/parse/config.go delete mode 100644 go_script/src/mobile.ooyala.com/common/log/colorized_log.go delete mode 100644 go_script/src/mobile.ooyala.com/common/log/file_and_stdout_logger.go delete mode 100644 go_script/src/mobile.ooyala.com/common/log/logger_test.go delete mode 100644 go_script/src/mobile.ooyala.com/common/log/silent_logger.go delete mode 100644 go_script/src/mobile.ooyala.com/common/log/stdout_logger.go delete mode 100644 go_script/src/mobile.ooyala.com/common/path/path.go delete mode 100644 go_script/src/mobile.ooyala.com/common/path/path_test.go delete mode 100644 go_script/src/mobile.ooyala.com/common/platforms.go delete mode 100644 go_script/src/mobile.ooyala.com/common/testutil/testutil.go delete mode 100644 go_script/src/mobile.ooyala.com/common/util/dbc.go delete mode 100644 go_script/src/mobile.ooyala.com/common/util/errors.go delete mode 100644 go_script/src/mobile.ooyala.com/common/util/is_zeroer.go delete mode 100644 go_script/src/mobile.ooyala.com/common/util/util.go delete mode 100644 go_script/src/mobile.ooyala.com/common/util/util_test.go delete mode 100644 go_script/src/mobile.ooyala.com/samples/clean_sample_apps/clean_sample_apps.go delete mode 100644 go_script/src/mobile.ooyala.com/samples/config/sample_app_config/sample_app_config.go delete mode 100644 go_script/src/mobile.ooyala.com/samples/config/vendor_config/vendor_config.go delete mode 100644 go_script/src/mobile.ooyala.com/samples/config/zip_config/zip_config.go delete mode 100644 go_script/src/mobile.ooyala.com/samples/copy_from_vendor/copy_from_vendor.go delete mode 100644 go_script/src/mobile.ooyala.com/samples/get_latest_rc/get_latest_rc.go delete mode 100644 go_script/src/mobile.ooyala.com/samples/get_latest_release/get_latest_release.go delete mode 100644 go_script/src/mobile.ooyala.com/samples/merge_into_complete_sample_app/merge_into_complete_sample_app.go delete mode 100644 go_script/src/mobile.ooyala.com/samples/update_from_target_location/update_from_target_location.go diff --git a/Makefile b/Makefile deleted file mode 100644 index 98df8954b..000000000 --- a/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -export GOPATH = $(shell pwd)/go_script/ - -install: install-scripts clean - go_script/bin/copy_from_vendor - go_script/bin/merge_into_complete_sample_app - -get-latest-rc: install-scripts - go_script/bin/get_latest_rc - make install - -get-latest-release: install-scripts - go_script/bin/get_latest_release - make install - -update-from-target-location: install-scripts - go_script/bin/update_from_target_location -path=$(path) - -clean-scripts: - rm -f go_script/bin/* - -install-scripts: clean-scripts - cd go_script/src/mobile.ooyala.com/samples/clean_sample_apps/ && go install - cd go_script/src/mobile.ooyala.com/samples/get_latest_rc/ && go install - cd go_script/src/mobile.ooyala.com/samples/get_latest_release/ && go install - cd go_script/src/mobile.ooyala.com/samples/update_from_target_location/ && go install - cd go_script/src/mobile.ooyala.com/samples/copy_from_vendor/ && go install - cd go_script/src/mobile.ooyala.com/samples/merge_into_complete_sample_app/ && go install - -clean: install-scripts - go_script/bin/clean_sample_apps diff --git a/go_script/src/mobile.ooyala.com/common/args/parse/args.go b/go_script/src/mobile.ooyala.com/common/args/parse/args.go deleted file mode 100644 index 7c48d3f17..000000000 --- a/go_script/src/mobile.ooyala.com/common/args/parse/args.go +++ /dev/null @@ -1,10 +0,0 @@ -package build - -import "log" -import "flag" - -func ParseArgs(c Config, l *log.Logger) error { - l.Println("args.ParseArgs") - flag.Parse() - return nil -} diff --git a/go_script/src/mobile.ooyala.com/common/args/parse/config.go b/go_script/src/mobile.ooyala.com/common/args/parse/config.go deleted file mode 100644 index bf53a13a6..000000000 --- a/go_script/src/mobile.ooyala.com/common/args/parse/config.go +++ /dev/null @@ -1,14 +0,0 @@ -package build - -import "log" -import "flag" - -type Config struct { - Path *string -} - -func MakeConfig(logger *log.Logger) Config { - return Config{ - Path: flag.String("path", "", "The path we get our android sdks"), - } -} diff --git a/go_script/src/mobile.ooyala.com/common/log/colorized_log.go b/go_script/src/mobile.ooyala.com/common/log/colorized_log.go deleted file mode 100644 index 22aeff815..000000000 --- a/go_script/src/mobile.ooyala.com/common/log/colorized_log.go +++ /dev/null @@ -1,28 +0,0 @@ -package log - -import gl "log" -import "runtime" - -func ColorizedPrintln(l *gl.Logger, s string) { - l.Println("\x1b[31;1m" + s + "\x1b[0m") -} - -func ColorizedMethodPrintln(l *gl.Logger) { - ColorizedMethodMessagePrintln(l, "") -} - -func ColorizedMethodMessagePrintln(l *gl.Logger, s string) { - pc, _, _, ok := runtime.Caller(2) - printed := false - if( ok ) { - f := runtime.FuncForPC(pc) - if( f != nil ) { - callerName := f.Name() - ColorizedPrintln(l, "(in " + callerName + ") " + s) - printed = true - } - } - if(!printed) { - ColorizedPrintln(l, s) - } -} diff --git a/go_script/src/mobile.ooyala.com/common/log/file_and_stdout_logger.go b/go_script/src/mobile.ooyala.com/common/log/file_and_stdout_logger.go deleted file mode 100644 index 5f97b408f..000000000 --- a/go_script/src/mobile.ooyala.com/common/log/file_and_stdout_logger.go +++ /dev/null @@ -1,26 +0,0 @@ -package log - -import gl "log" -import "os" -import "io" -import "time" -import "errors" -import . "mobile.ooyala.com/common/path" - -func NewFileAndStdoutLogger(outpath FileAbs) (*gl.Logger, error) { - _, err := os.Stat(outpath.S) - if err == nil { - return nil, errors.New(outpath.S + " already exists, won't over-write") - } - fileout, err := os.OpenFile(outpath.S, os.O_CREATE|os.O_WRONLY|os.O_APPEND, os.ModePerm) - if err != nil { - return nil, err - } - mw := io.MultiWriter(fileout, os.Stdout) - return gl.New(mw, "", gl.LstdFlags), nil -} - -func NewFileAndStdoutLoggerNow(outpath FileAbs) (*gl.Logger, error) { - nowStr := time.Now().Format(time.RFC3339) - return NewFileAndStdoutLogger(MakeFileAbs(outpath.S + "_" + nowStr)) -} diff --git a/go_script/src/mobile.ooyala.com/common/log/logger_test.go b/go_script/src/mobile.ooyala.com/common/log/logger_test.go deleted file mode 100644 index a504637b3..000000000 --- a/go_script/src/mobile.ooyala.com/common/log/logger_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package log - -import "testing" -import "os" -import . "mobile.ooyala.com/common/path" - -// yes, these are just smoke tests, not really unit tests. - -func Test_SilentLogger(t *testing.T) { - l := NewStdoutLogger() - l.Println("log.foo") -} - -func Test_StdoutLogger(t *testing.T) { - l := NewStdoutLogger() - l.Println("log.foo") -} - -func Test_FilAndStdoutLogger(t *testing.T) { - path := "/tmp/testing.logger_test.out" - err := os.RemoveAll(path) - if err != nil { - t.FailNow() - } - l, err := NewFileAndStdoutLogger(MakeFileAbs(path)) - if err != nil { - t.FailNow() - } - l.Println("log.foo") -} diff --git a/go_script/src/mobile.ooyala.com/common/log/silent_logger.go b/go_script/src/mobile.ooyala.com/common/log/silent_logger.go deleted file mode 100644 index f8b8634ac..000000000 --- a/go_script/src/mobile.ooyala.com/common/log/silent_logger.go +++ /dev/null @@ -1,15 +0,0 @@ -package log - -import gl "log" - -type SilentWriter struct { -} - -func (this *SilentWriter) Write(p []byte) (n int, err error) { - return len(p), nil -} - -func NewSilentLogger() *gl.Logger { - silentWriter := &SilentWriter{} - return gl.New(silentWriter, "", gl.LstdFlags) -} diff --git a/go_script/src/mobile.ooyala.com/common/log/stdout_logger.go b/go_script/src/mobile.ooyala.com/common/log/stdout_logger.go deleted file mode 100644 index aad1662f7..000000000 --- a/go_script/src/mobile.ooyala.com/common/log/stdout_logger.go +++ /dev/null @@ -1,8 +0,0 @@ -package log - -import gl "log" -import "os" - -func NewStdoutLogger() *gl.Logger { - return gl.New(os.Stdout, "", gl.LstdFlags) -} diff --git a/go_script/src/mobile.ooyala.com/common/path/path.go b/go_script/src/mobile.ooyala.com/common/path/path.go deleted file mode 100644 index 72b089a14..000000000 --- a/go_script/src/mobile.ooyala.com/common/path/path.go +++ /dev/null @@ -1,198 +0,0 @@ -package path - -import gp "path" -import gpfp "path/filepath" -import "os" -import "fmt" -import "regexp" -import "runtime/debug" - -// todo: use embedding to make them all Fragments and maybe then Paths (for Base)? -// i could never get / figure out how to get embedding to work right for me. - -// too bad there isn't a 'to string' type interface that's part of core go? -type Stringer interface { - String() string -} - -// todo: versions with different return types; 'string' is just lame. -// maybe move Join to be on the different types below? -func Join(args ...Stringer) string { - s := make([]string, len(args)) - for i, e := range args { - s[i] = e.String() - } - return gp.Join(s...) -} - -type Pather interface { - Stringer - Path() Path -} - -// ---------------------------------------- - -func RequireNoWhitespace(s string) string { - if HasWhitespace(s) { - stack := string(debug.Stack()) - fmt.Fprintf(os.Stderr, `no whitespace allowed: '`+s+`'`+"\n") - fmt.Fprintf(os.Stderr, `call stack: `+stack) - os.Exit(1) - } - return s -} - -func HasWhitespace(s string) bool { - m, err := regexp.MatchString("[[:space:]]", s) - if err != nil { - fmt.Fprintf(os.Stderr, err.Error()) - os.Exit(1) - } - return m -} - -// ---------------------------------------- - -// Fragment is anything that doesn't fit into the types below -- could be a sub-part of a name, sub-part of a directory name, a glob, etc. - -type Fragment struct { - S string -} - -func MakeFragment(s string) Fragment { - return MakeFragmentAllowWhitespace(RequireNoWhitespace(s)) -} -func MakeFragmentAllowWhitespace(s string) Fragment { - return Fragment{S: s} -} -func (this Fragment) Path() Path { - return MakePath(this.S) -} -func (this Fragment) String() string { - return this.S -} - -// ---------------------------------------- - -// could be a directory or a file, sometimes we don't need to restrict it. - -type Path struct { - Fragment -} - -func MakePath(s string) Path { - return MakePathAllowWhitespace(RequireNoWhitespace(s)) -} -func MakePathAllowWhitespace(s string) Path { - o := Path{} - o.S = s - return o -} - -// note: this is assuming we can make a path from our string. -func (this Path) Base() Fragment { - return MakeFragment(gpfp.Base(this.String())) -} - -// ---------------------------------------- - -type FileName struct { - Fragment -} - -func MakeFileName(s string) FileName { - return MakeFileNameAllowWhitespace(RequireNoWhitespace(s)) -} -func MakeFileNameAllowWhitespace(s string) FileName { - o := FileName{} - o.S = s - return o -} -func (this FileName) Base() Fragment { - return MakeFragment(this.S) -} - -type FileRel struct { - Fragment -} - -func MakeFileRel(s string) FileRel { - return MakeFileRelAllowWhitespace(RequireNoWhitespace(s)) -} -func MakeFileRelAllowWhitespace(s string) FileRel { - o := FileRel{} - o.S = s - return o -} -func (this FileRel) Base() Fragment { - return MakeFragment(gpfp.Base(this.S)) -} - -type FileAbs struct { - Fragment -} - -func MakeFileAbs(s string) FileAbs { - return MakeFileAbsAllowWhitespace(RequireNoWhitespace(s)) -} -func MakeFileAbsAllowWhitespace(s string) FileAbs { - o := FileAbs{} - o.S = s - return o -} -func (this FileAbs) Base() Fragment { - return MakeFragment(gpfp.Base(this.S)) -} -func (this FileAbs) Dir() DirAbs { - return MakeDirAbs(gpfp.Dir(this.S)) -} - -// ---------------------------------------- - -type DirName struct { - Fragment -} - -func MakeDirName(s string) DirName { - return MakeDirNameAllowWhitespace(RequireNoWhitespace(s)) -} -func MakeDirNameAllowWhitespace(s string) DirName { - o := DirName{} - o.S = s - return o -} -func (this DirName) Base() Fragment { - return MakeFragment(this.S) -} - -type DirRel struct { - Fragment -} - -func MakeDirRel(s string) DirRel { - return MakeDirRelAllowWhitespace(RequireNoWhitespace(s)) -} -func MakeDirRelAllowWhitespace(s string) DirRel { - o := DirRel{} - o.S = s - return o -} -func (this DirRel) Base() Fragment { - return MakeFragment(gpfp.Base(this.S)) -} - -type DirAbs struct { - Fragment -} - -func MakeDirAbs(s string) DirAbs { - return MakeDirAbsAllowWhitespace(RequireNoWhitespace(s)) -} -func MakeDirAbsAllowWhitespace(s string) DirAbs { - o := DirAbs{} - o.S = s - return o -} -func (this DirAbs) Base() Fragment { - return MakeFragment(gpfp.Base(this.S)) -} diff --git a/go_script/src/mobile.ooyala.com/common/path/path_test.go b/go_script/src/mobile.ooyala.com/common/path/path_test.go deleted file mode 100644 index b9236c41f..000000000 --- a/go_script/src/mobile.ooyala.com/common/path/path_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package path - -import "testing" -import "errors" -import gp "path" - -func Test_HasWhitespace(t *testing.T) { - tests := []string{ - "foo bar", - "foo\tbar", - "foo\vbar", - "foo\nbar", - "foo\rbar", - } - for _, s := range tests { - if !HasWhitespace(s) { - t.Log(s) - t.FailNow() - } - } -} - -// todo: i want this to be a compiler error! -func Test_PathArgument(t *testing.T) { - f := func(p Path) {} - f(MakePath("foo")) -} - -func Test_Join(t *testing.T) { - pjs := Join( - MakeFragment("a"), - MakePath("b"), - MakeFileName("c"), - MakeFileRel("d"), - MakeFileAbs("/e"), - MakeDirName("f"), - MakeDirRel("g"), - MakeDirAbs("/h"), - ) - gpjs := gp.Join( - "a", - "b", - "c", - "d", - "/e", - "f", - "g", - "/h", - ) - if pjs != gpjs { - t.Log(errors.New("expected: '" + gpjs + "', got '" + pjs + "'")) - t.FailNow() - } -} diff --git a/go_script/src/mobile.ooyala.com/common/platforms.go b/go_script/src/mobile.ooyala.com/common/platforms.go deleted file mode 100644 index 4c27aa52a..000000000 --- a/go_script/src/mobile.ooyala.com/common/platforms.go +++ /dev/null @@ -1,4 +0,0 @@ -package common - -const Platform_iOS = "iOS" -const Platform_Android = "Android" diff --git a/go_script/src/mobile.ooyala.com/common/testutil/testutil.go b/go_script/src/mobile.ooyala.com/common/testutil/testutil.go deleted file mode 100644 index f80e0f2b7..000000000 --- a/go_script/src/mobile.ooyala.com/common/testutil/testutil.go +++ /dev/null @@ -1,64 +0,0 @@ -package testutil - -import "testing" -import "fmt" -import "os/exec" -import "runtime/debug" -import . "mobile.ooyala.com/common/path" -import "mobile.ooyala.com/common/util" -import "mobile.ooyala.com/common/log" - -type setupfn func(t *testing.T) - -func ErrorNow(t *testing.T, err error) { - t.Log(string(debug.Stack())) - t.Fatalf(err.Error()) -} - -func MaybeErrorNow(t *testing.T, err error) error { - if err != nil { - ErrorNow(t, err) - } - return util.NewErrorWithErrorAndStack(err) -} - -func RequirePath(t *testing.T, path Pather) { - MaybeErrorNow(t, util.RequirePath(path, log.NewSilentLogger())) -} - -func RequireNoPath(t *testing.T, path Pather) { - MaybeErrorNow(t, util.RequireNoPath(path, log.NewSilentLogger())) -} - -func DeletePath(t *testing.T, path DirAbs) { - MaybeErrorNow(t, util.DeletePath(path, log.NewSilentLogger())) -} - -func EnsurePath(t *testing.T, path DirAbs) { - MaybeErrorNow(t, util.EnsurePath(path, log.NewSilentLogger())) -} - -func EnsureCleanDestinationTest(t *testing.T, dirpath DirAbs, setupfn setupfn) { - fmt.Printf("testutil.EnsureCleanDestinationTest", dirpath) - DeletePath(t, dirpath) - EnsurePath(t, dirpath) - - dummyPath := MakeDirAbs(Join(dirpath, MakeFileName("dummy"))) - cmdstr := "touch " + dummyPath.S - fmt.Printf(cmdstr) - MaybeErrorNow(t, exec.Command("bash", "-c", cmdstr).Run()) - if !util.IsPathVisible(dummyPath) { - ErrorNow(t, util.NewErrorWithMessageAndStack("failed to create dummy: "+dummyPath.S)) - } - - setupfn(t) - - if !util.IsPathVisible(dirpath) { - ErrorNow(t, util.NewErrorWithMessageAndStack("parent not visible: "+dirpath.S)) - } - if util.IsPathVisible(dummyPath) { - ErrorNow(t, util.NewErrorWithMessageAndStack("failed to erase (post) dummy : "+dummyPath.S)) - } - - DeletePath(t, dirpath) -} diff --git a/go_script/src/mobile.ooyala.com/common/util/dbc.go b/go_script/src/mobile.ooyala.com/common/util/dbc.go deleted file mode 100644 index 1a16de219..000000000 --- a/go_script/src/mobile.ooyala.com/common/util/dbc.go +++ /dev/null @@ -1,22 +0,0 @@ -package util - -import "os" -import "strings" -import "fmt" - -func DbcPre(b bool, msgs ...string) { - dbcAssert(b, "pre-condition", msgs) -} - -func DbcPost(b bool, msgs ...string) { - dbcAssert(b, "post-condition", msgs) -} - -func dbcAssert(b bool, dbcType string, msgs []string) { - if !b { - msg := strings.Join(msgs, ", ") - fullmsg := fmt.Sprintf("failed %s: %s\n", dbcType, msg) - fmt.Fprintf(os.Stderr, fullmsg) - panic(fullmsg) - } -} diff --git a/go_script/src/mobile.ooyala.com/common/util/errors.go b/go_script/src/mobile.ooyala.com/common/util/errors.go deleted file mode 100644 index 7d0a41e28..000000000 --- a/go_script/src/mobile.ooyala.com/common/util/errors.go +++ /dev/null @@ -1,33 +0,0 @@ -package util - -import "runtime/debug" -import "errors" - -func NewErrorWithMessageAndStack(msg string) error { - return errors.New(msg + " @ " + string(debug.Stack())) -} - -func NewErrorWithMessageAndErrorAndStack(msg string, err error) error { - return errors.New(msg + ":" + err.Error() + " @ " + string(debug.Stack())) -} - -func NewErrorWithErrorAndStack(err error) error { - var msg string - if err != nil { - msg = err.Error() - } else { - msg = "" - } - return errors.New(msg + " @ " + string(debug.Stack())) -} - -type notImplementedError struct { - Stack string -} - -func NewNotImplementedError() *notImplementedError { - return ¬ImplementedError{string(debug.Stack())} -} -func (this *notImplementedError) Error() string { - return "not implemented: " + this.Stack -} diff --git a/go_script/src/mobile.ooyala.com/common/util/is_zeroer.go b/go_script/src/mobile.ooyala.com/common/util/is_zeroer.go deleted file mode 100644 index 3170f0149..000000000 --- a/go_script/src/mobile.ooyala.com/common/util/is_zeroer.go +++ /dev/null @@ -1,5 +0,0 @@ -package util - -type IsZeroer interface { - IsZero() bool -} diff --git a/go_script/src/mobile.ooyala.com/common/util/util.go b/go_script/src/mobile.ooyala.com/common/util/util.go deleted file mode 100644 index 9d06e70a8..000000000 --- a/go_script/src/mobile.ooyala.com/common/util/util.go +++ /dev/null @@ -1,444 +0,0 @@ -package util - -import "fmt" -import "log" -import "os" -import "regexp" -import "os/exec" -import "strconv" -import "strings" -import "reflect" -import "flag" -import "bytes" -import "bufio" -import "unicode" -import gpfp "path/filepath" -import . "mobile.ooyala.com/common/path" -import ol "mobile.ooyala.com/common/log" - -type RunAction func() error -type VisitFieldFn func(name string, field reflect.Value) error - -const FindFilesRecursivePrefix = "find . -type f" -const FindFilesPrefix = "find . -type f -maxdepth 1" - -func Run(actions []RunAction) error { - for _, fn := range actions { - err := fn() - if err != nil { - return NewErrorWithErrorAndStack(err) - } - } - return nil -} - -func Die(err error, logger *log.Logger) { - if err != nil { - msg := "!!! util.Die " + err.Error() - if logger != nil { - ol.ColorizedPrintln(logger, msg) - } else { - fmt.Fprintf(os.Stderr, msg) - } - } - os.Exit(1) -} - -func MaybeDie(err error, logger *log.Logger) { - if err != nil { - msg := "!!! " + err.Error() - if logger != nil { - logger.Println(msg) - } else { - fmt.Fprintf(os.Stderr, msg) - } - os.Exit(1) - } -} - -func ToDirAbs(d DirRel) (DirAbs, error) { - rootStr, err := gpfp.Abs(d.S) - if err != nil { - return MakeDirAbs(""), err - } - return MakeDirAbs(rootStr), nil -} - -func RequireCountFilesRecursive(path DirAbs, expected int, logger *log.Logger) error { - return RequireCountFilesOf(CountFilesRecursive, path, expected, logger) -} - -func RequireCountFiles(path DirAbs, expected int, logger *log.Logger) error { - return RequireCountFilesOf(CountFiles, path, expected, logger) -} - -// todo: add a RequireCountFiles{Recursive}Named() -type CounterAction func(DirAbs, *log.Logger) (int, error) - -func RequireCountFilesOf(counter CounterAction, path DirAbs, expected int, logger *log.Logger) error { - if !IsPathVisible(path) { - return NewErrorWithMessageAndStack("path should be visible: " + path.S) - } - count, err := counter(path, logger) - if err != nil { - return NewErrorWithErrorAndStack(err) - } - if count != expected { - return NewErrorWithMessageAndStack("wrong count, expected " + strconv.Itoa(expected) + ", got " + strconv.Itoa(count)) - } - return nil -} - -func RequirePaths(pathers []Pather, logger *log.Logger) error { - logger.Println("util.RequirePaths") - for _, e := range pathers { - err := RequirePath(e, logger) - if err != nil { - return NewErrorWithErrorAndStack(err) - } - } - return nil -} - -func RequirePath(pather Pather, logger *log.Logger) error { - path := pather.Path() - logger.Println("util.RequirePath: " + path.S) - if !IsPathVisible(path) { - return NewErrorWithMessageAndStack("path should be visible: " + path.S) - } else { - return nil - } -} - -func RequireNoPaths(paths []Pather, logger *log.Logger) error { - logger.Println("util.RequireNoPaths") - for _, e := range paths { - err := RequireNoPath(e, logger) - if err != nil { - return NewErrorWithErrorAndStack(err) - } - } - return nil -} - -func RequireNoPath(pather Pather, logger *log.Logger) error { - path := pather.Path() - logger.Println("util.RequireNoPath: " + path.S) - if IsPathVisible(path) { - return NewErrorWithMessageAndStack("path should not be visible: " + path.S) - } else { - return nil - } -} - -func DeletePath(pather Pather, logger *log.Logger) error { - path := pather.Path() - logger.Println("util.DeletePath: " + path.S) - if !IsPathVisible(path) { - return nil - } - err := os.RemoveAll(path.S) - if err != nil { - return NewErrorWithErrorAndStack(err) - } - return RequireNoPath(path, logger) -} - -func EnsurePaths(paths []DirAbs, logger *log.Logger) error { - for _, e := range paths { - err := EnsurePath(e, logger) - if err != nil { - return NewErrorWithErrorAndStack(err) - } - } - return nil -} - -func EnsurePath(path DirAbs, logger *log.Logger) error { - logger.Println("util.EnsurePath: " + path.S) - if IsPathVisible(path) { - return nil - } - err := os.MkdirAll(path.S, os.ModeDir|os.ModePerm) - if err != nil { - return NewErrorWithErrorAndStack(err) - } - return RequirePath(path, logger) -} - -func DeleteFile(path FileAbs, logger *log.Logger) error { - logger.Println("util.DeleteFile: " + path.S) - if IsPathVisible(path) { - err := os.Remove(path.S) - if err != nil { - return NewErrorWithErrorAndStack(err) - } - } - return nil -} - -func EnsureCleanDestinationPath(path DirAbs, logger *log.Logger) error { - logger.Println("util.EnsureCleanDestinationPath: " + path.S) - err := Run([]RunAction{ - func() error { return DeletePath(path, logger) }, - func() error { return os.MkdirAll(path.S, os.ModeDir|os.ModePerm) }, - }) - if err != nil { - return NewErrorWithErrorAndStack(err) - } - return RequirePath(path, logger) -} - -func CopyPath(srcPather Pather, dstPather Pather, logger *log.Logger) error { - logger.Println("util.CopyPath", srcPather, dstPather) - _, err := RunBashCommand(`cp `+srcPather.Path().S+` `+dstPather.Path().S, logger) - return err -} - -func CopyPathLiteral(srcPath string, dstPather Pather, logger *log.Logger) error { - logger.Println("util.CopyPathLiteral", srcPath, dstPather) - _, err := RunBashCommand(`cp `+srcPath+` `+dstPather.Path().S, logger) - return err -} - -func CopyPathRecursive(srcPather Pather, dstPather Pather, logger *log.Logger) error { - logger.Println("util.CopyPathRecursive", srcPather, dstPather) - _, err := RunBashCommand(`cp -R `+srcPather.Path().S+` `+dstPather.Path().S, logger) - return err -} - -func CopyPathContents(srcPather Pather, dstPather Pather, logger *log.Logger) error { - logger.Println("util.CopyPathContents", srcPather, dstPather) - _, err := RunBashCommand(`cp `+srcPather.Path().S+`/* `+dstPather.Path().S+`/`, logger) - return err -} - -func CopyPathContentsRecursive(srcPather Pather, dstPather Pather, logger *log.Logger) error { - logger.Println("util.CopyPathContentsRecursive", srcPather, dstPather) - _, err := RunBashCommand(`cp -R `+srcPather.Path().S+`/* `+dstPather.Path().S+`/`, logger) - return err -} - -// todo: fix up the arbitrary return type differences among RunBash*()'s. - -func RunBashCommandParts(parts []string, logger *log.Logger) (string, error) { - return RunBashCommand(strings.Join(parts, " "), logger) -} - -func RunBashCommand(command string, logger *log.Logger) (string, error) { - logger.Println("util.RunBashCommand", command) - out, err := exec.Command("bash", "-c", command).Output() - if err != nil { - msg := fmt.Sprintf( "command=<%s>", command ) - err = NewErrorWithMessageAndErrorAndStack( msg, err ) - } - return strings.TrimRightFunc(string(out), unicode.IsSpace), err -} - -func RunBashCommandPartsInDir(dir DirAbs, parts []string, logger *log.Logger) (string, error) { - return RunBashCommandInDir(dir, strings.Join(parts, " "), logger) -} - -func RunBashCommandInDir(dir DirAbs, command string, logger *log.Logger) (string, error) { - logger.Println("util.RunBashCommandInDir") - return RunBashCommand("cd "+dir.S+" && "+command, logger) -} - -// if you really need the full output returned, then write your own loop somewhere. -func RunBashCommandsInDir(dir DirAbs, commands []string, logger *log.Logger) error { - for _, c := range commands { - cd := "cd " + dir.S - full_cmd := cd + " && " + c - logger.Println("util.RunBashCommandsInDir:", full_cmd) - exec := exec.Command("bash", "-c", full_cmd) - // todo: figure out something better some day. - exec.Stdout = os.Stdout - exec.Stderr = os.Stderr - err := exec.Run() - if err != nil { - return NewErrorWithErrorAndStack(err) - } - } - return nil -} - -func IsPathVisible(pather Pather) bool { - return IsPathVisibleError(pather) == nil -} - -func IsPathVisibleError(pather Pather) error { - path := pather.Path() - _, err := os.Stat(path.S) - return err -} - -func MakeCountComparisonCommand(srcFindCmd string, dstFindCmd string, comparison string) string { - return "if [ `" + srcFindCmd + " | wc -l` " + comparison + " `" + dstFindCmd + " | wc -l` ]; then exit 0; else exit 1; fi" -} - -func RequireEqualCount(runPath DirAbs, srcFindCmd string, dstFindCmd string, logger *log.Logger) error { - cmd := MakeCountComparisonCommand(srcFindCmd, dstFindCmd, "-eq") - _, err := RunBashCommandInDir(runPath, cmd, logger) - return err -} - -func RequireGreaterThanOrEqualCount(runPath DirAbs, srcFindCmd string, dstFindCmd string, logger *log.Logger) error { - cmd := MakeCountComparisonCommand(srcFindCmd, dstFindCmd, "-le") // the source count should be <= destination count. - _, err := RunBashCommandInDir(runPath, cmd, logger) - return err -} - -func CountFilesRecursive(path DirAbs, logger *log.Logger) (int, error) { - return CountFilesOf(path, FindFilesRecursivePrefix, logger) -} - -func CountFiles(path DirAbs, logger *log.Logger) (int, error) { - return CountFilesOf(path, FindFilesPrefix, logger) -} - -func CountFilesOf(path DirAbs, find string, logger *log.Logger) (int, error) { - fullCommand := "cd " + path.S + " && " + find + " | wc -l" - cmdexec := exec.Command("bash", "-c", fullCommand) - logger.Println(fullCommand) - out, err := cmdexec.Output() - if err != nil { - return 0, NewErrorWithErrorAndStack(err) - } - sout := strings.TrimSpace(string(out)) - count64, err := strconv.ParseInt(sout, 10, 0) - if err != nil { - return 0, NewErrorWithErrorAndStack(err) - } - logger.Println(sout) - return int(count64), nil -} - -func GrepFile(path FileAbs, query string) bool { - regex, err := regexp.Compile(query) - if err != nil { - return false - } - fh, err := os.Open(path.S) - if err != nil { - return false - } - defer fh.Close() - - scanner := bufio.NewScanner(fh) - if scanner == nil { - return false - } - for scanner.Scan() { - if err := scanner.Err(); err != nil { - return false - } - if regex.MatchString(scanner.Text()) { - return true - } - } - return false -} - -// note: in the end this doesn't really fit what i wanted -// to do, since really the only way to know if a -// struct field has/not been set is to have them -// all be pointers and check vs. nil. which then -// sucks for consumers of the struct.. -func RequireFullStructOrDie(x interface{}, logger *log.Logger, ignore ...string) { - MaybeDie(RequireFullStruct(x, ignore...), logger) -} - -func RequireFullStruct(x interface{}, ignore ...string) error { - vfn := func(name string, value reflect.Value) error { - if IsZero(value) { - return NewErrorWithMessageAndStack("zero field: " + name + ", " + value.String()) - } else { - return nil - } - } - return visitStruct(x, vfn, ignore...) -} - -// todo: this is only for non-pointer structs at the moment!? -func visitStruct(x interface{}, vfn VisitFieldFn, ignore ...string) error { - //fmt.Println( "+ util.visitStruct: struct = ", x ) - _v := func(x interface{}, vfn VisitFieldFn, ignore ...string) error { - s := reflect.ValueOf(x) - if s.Kind() != reflect.Struct { - return NewErrorWithMessageAndStack("not a struct") - } - for i := 0; i < s.NumField(); i++ { - f := s.Field(i) - name := s.Type().Field(i).Name - //fmt.Println( " util.visitStruct: field name =", name ) - skip := false - for _, e := range ignore { - if name == e { - skip = true - } - } - - if !skip { - err := vfn(name, f) - if err != nil { - return err - } - } - } - return nil - } - err := _v(x, vfn, ignore...) - //fmt.Println( "- util.visitStruct" ) - return err -} - -// http://code.google.com/p/go/issues/detail?id=7501 -func IsZero(v reflect.Value) bool { - //fmt.Println( "util.IsZero", v, v.Kind() ) - izi := reflect.TypeOf((*IsZeroer)(nil)).Elem() - if v.Type().Implements(izi) { - in := make([]reflect.Value, 0) - return v.MethodByName("IsZero").Call(in)[0].Bool() - } else { - switch v.Kind() { - case reflect.Array, reflect.String: - return v.Len() == 0 - case reflect.Bool: - return !v.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() == 0 - case reflect.Float32, reflect.Float64: - return v.Float() == 0 - case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: - return v.IsNil() - case reflect.Struct: - hasZero := false - vfn := func(name string, field reflect.Value) error { - //fmt.Println( "util.IsZero.vfn", hasZero, name, field ) - if IsZero(field) { - hasZero = true - } - return nil - } - MaybeDie( - visitStruct(v.Interface(), vfn), - nil, - ) - return hasZero - default: - return false - } - } -} - -func FlagSetToHelpString(flagSet *flag.FlagSet) string { - var b bytes.Buffer - flagSet.VisitAll(func(f *flag.Flag) { b.WriteString("flag: " + f.Name + " (" + f.Usage + ")\n") }) - return b.String() -} - -func BashEscape(src string, escapee string) string { - return strings.Replace(src, escapee, `\`+escapee, -1) -} diff --git a/go_script/src/mobile.ooyala.com/common/util/util_test.go b/go_script/src/mobile.ooyala.com/common/util/util_test.go deleted file mode 100644 index 18d41e8c7..000000000 --- a/go_script/src/mobile.ooyala.com/common/util/util_test.go +++ /dev/null @@ -1,127 +0,0 @@ -package util - -import "testing" -import "strconv" -import "flag" -import . "encoding/hex" -import . "mobile.ooyala.com/common/path" -import "mobile.ooyala.com/common/log" - -func check(t *testing.T, err error) { - if err != nil { - t.Log(err.Error()) - t.FailNow() - } -} - -func require(t *testing.T, err error) { - if err == nil { - t.Log(err.Error()) - t.FailNow() - } -} - -// ---------------------------------------- - -func Test_IsPathVisible(t *testing.T) { - is := IsPathVisible(MakeDirAbs("/tmp/thisshouldbeaprettybogusfilename")) - if is { - t.FailNow() - } -} - -func Test_IsPathVisibleError(t *testing.T) { - err := IsPathVisibleError(MakeDirAbs("/tmp/thisshouldbeaprettybogusfilename")) - require(t, err) -} - -// ---------------------------------------- - -func Test_RunBashCommandInDir_Junk(t *testing.T) { - l := log.NewStdoutLogger() - check(t, EnsureCleanDestinationPath(MakeDirAbs("/tmp/sdk_tmp"), l)) - _, err := RunBashCommandInDir(MakeDirAbs("/tmp/sdk_tmp"), "for me in 1 2 3 4 5; do echo $me `date +%s`; sleep 1; done", l) - check(t, err) -} - -func Test_RunBashCommandInDir_ExitCode1(t *testing.T) { - l := log.NewStdoutLogger() - _, err := RunBashCommandInDir(MakeDirAbs("/tmp"), "exit 1", l) - require(t, err) -} - -func Test_RunBashCommandInDir_ExitCode0(t *testing.T) { - l := log.NewStdoutLogger() - _, err := RunBashCommandInDir(MakeDirAbs("/tmp"), "exit 0", l) - check(t, err) -} - -// ---------------------------------------- - -func RunBashCommandsInDir_TwoExitCodesOneError(code1 int, code2 int) error { - l := log.NewStdoutLogger() - cmds := []string{ - "exit " + strconv.Itoa(code1), - "exit " + strconv.Itoa(code2), - } - return RunBashCommandsInDir(MakeDirAbs("/tmp"), cmds, l) -} - -func Test_RunBashCommandsInDir_ExitCode1_1(t *testing.T) { - err := RunBashCommandsInDir_TwoExitCodesOneError(1, 1) - require(t, err) -} - -func Test_RunBashCommandsInDir_ExitCode0_1(t *testing.T) { - err := RunBashCommandsInDir_TwoExitCodesOneError(0, 1) - require(t, err) -} - -func Test_RunBashCommandsInDir_ExitCode1_0(t *testing.T) { - err := RunBashCommandsInDir_TwoExitCodesOneError(1, 0) - require(t, err) -} - -func Test_RunBashCommandsInDir_ExitCode0_0(t *testing.T) { - err := RunBashCommandsInDir_TwoExitCodesOneError(0, 0) - check(t, err) -} - -// ---------------------------------------- - -func Test_CountFilesOf(t *testing.T) { - l := log.NewStdoutLogger() - _, err := RunBashCommandInDir(MakeDirAbs("/tmp"), "for me in 1 2 3 4 5; do touch ${me}.sdk_tmp_test; done", l) - count, err := CountFilesOf(MakeDirAbs(`/tmp`), FindFilesPrefix+` -name \*sdk_tmp_test`, l) - check(t, err) - if count < 5 { - t.FailNow() - } -} - -// ---------------------------------------- - -func Test_FlagSetToHelpString(t *testing.T) { - flagSet := flag.NewFlagSet("test", flag.ExitOnError) - flagSet.String("str", "default", "set me") - s := FlagSetToHelpString(flagSet) - e := "flag: str (set me)\n" - if s != e { - t.Log(s) - t.Log(e) - bs := []byte(s) - t.Log(Dump(bs)) - be := []byte(e) - t.Log(Dump(be)) - t.FailNow() - } -} - -// ---------------------------------------- - -func Test_DeletePath_Dir(t *testing.T) { - l := log.NewStdoutLogger() - d := MakeDirAbs("/tmp/sdk_test_foobar") - check(t, EnsureCleanDestinationPath(d, l)) - check(t, DeletePath(d, l)) -} diff --git a/go_script/src/mobile.ooyala.com/samples/clean_sample_apps/clean_sample_apps.go b/go_script/src/mobile.ooyala.com/samples/clean_sample_apps/clean_sample_apps.go deleted file mode 100644 index 2b8d2ee0b..000000000 --- a/go_script/src/mobile.ooyala.com/samples/clean_sample_apps/clean_sample_apps.go +++ /dev/null @@ -1,57 +0,0 @@ -package main -import ol "mobile.ooyala.com/common/log" -import "log" -import "mobile.ooyala.com/common/util" -import . "mobile.ooyala.com/common/path" -import sc "mobile.ooyala.com/samples/config/sample_app_config" - - -func main() { - l, err := ol.NewFileAndStdoutLoggerNow(MakeFileAbs("/tmp/android-sample-apps.clean-sample-apps")) - ol.ColorizedPrintln(l, "CleanSampleApps") - util.MaybeDie(err, nil) - - rootDir, err := util.ToDirAbs(MakeDirRel(".")) - util.MaybeDie(err, l) - - config := sc.MakeConfig("Android", rootDir, l); - - l.Println("We found the following apps:") - for _, element := range config.MergableSampleAppPaths { - l.Println(element.String()) - } - - removeLibraries (config.AllSampleAppsPaths, l) - - //Remove the code that is duplicated in the CompleteSampleApp - removeCompleteCode(config, l) -} - -func removeLibraries (sampleAppPaths []DirAbs, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - for _, element := range sampleAppPaths { - util.DeletePath(MakeDirAbs(Join(element, MakeDirRel("app/libs"))), l); - util.EnsurePath(MakeDirAbs(Join(element, MakeDirRel("app/libs"))), l); - } -} - -func removeCompleteCode (config sc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - - playersDirAbs := MakeDirAbs(Join(config.CompleteSampleAppPath, config.PlayersPackageDirRel)) - listsDirAbs := MakeDirAbs(Join(config.CompleteSampleAppPath, config.ListPackageDirRel)) - utilsDirAbs := MakeDirAbs(Join(config.CompleteSampleAppPath, config.UtilsPackageDirRel)) - layoutDirAbs := MakeDirAbs(Join(config.CompleteSampleAppPath, config.LayoutDirRel)) - - util.DeletePath(playersDirAbs, l); - util.EnsurePath(playersDirAbs, l); - - util.DeletePath(listsDirAbs, l); - util.EnsurePath(listsDirAbs, l); - - util.DeletePath(utilsDirAbs, l); - util.EnsurePath(utilsDirAbs, l); - - util.DeletePath(layoutDirAbs, l); - util.EnsurePath(layoutDirAbs, l); -} diff --git a/go_script/src/mobile.ooyala.com/samples/config/sample_app_config/sample_app_config.go b/go_script/src/mobile.ooyala.com/samples/config/sample_app_config/sample_app_config.go deleted file mode 100644 index 2f263abcf..000000000 --- a/go_script/src/mobile.ooyala.com/samples/config/sample_app_config/sample_app_config.go +++ /dev/null @@ -1,75 +0,0 @@ -package sample_app_config - -import "log" -import "strings" -import "mobile.ooyala.com/common/util" -import . "mobile.ooyala.com/common/path" - -/** - * This config file represents folders to access sample apps. - * Consistent between Android and iOS sample app - */ -type Config struct { - RootPath DirAbs - - CompleteSampleAppName DirName - CompleteSampleAppPath DirAbs - - MergableSampleAppPaths []DirAbs - AllSampleAppsPaths []DirAbs - FreewheelEnabledSampleAppsPaths []DirAbs - IMAEnabledSampleAppPaths []DirAbs - AdobePassEnabledSampleAppPaths []DirAbs - - PlayersPackageDirRel DirRel - ListPackageDirRel DirRel - UtilsPackageDirRel DirRel - LayoutDirRel DirRel -} - -func MakeConfig(platformName string, rootPath DirAbs, logger *log.Logger) Config { - // You do not need to specify your sample app here, unless you require vendor-copied libraries? - completeSampleAppName := MakeDirName("CompleteSampleApp") - freewheelSampleAppName := MakeDirName("FreewheelSampleApp") - imaSampleAppName := MakeDirName("IMASampleApp") - optionsSampleAppName := MakeDirName("OptionsSampleApp") - adobepassSampleAppName := MakeDirName("ContentProtectionSampleApp") - - completeSampleAppPath := MakeDirAbs(Join(rootPath, completeSampleAppName)) - freewheelSampleAppPath := MakeDirAbs(Join(rootPath, freewheelSampleAppName)) - imaSampleAppPath := MakeDirAbs(Join(rootPath, imaSampleAppName)) - optionsSampleAppPath := MakeDirAbs(Join(rootPath, optionsSampleAppName)) - adobepassSampleAppPath := MakeDirAbs(Join(rootPath, adobepassSampleAppName)) - - // Get All Sample Apps in Repo - appNamesListString, err := util.RunBashCommandInDir(rootPath, "ls -d *SampleApp", logger) - util.MaybeDie(err, logger) - - appNamesDirSlice := make ([]DirAbs, 0) - for _, element := range strings.Split(appNamesListString, "\n") { - // Do not include the CompleteSampleApp - if (element != completeSampleAppName.String()) { - appNamesDirSlice = append(appNamesDirSlice, MakeDirAbs(Join(rootPath, MakeDirName(element)))) - } - } - - c := Config{ - RootPath: rootPath, - - CompleteSampleAppName: completeSampleAppName, - CompleteSampleAppPath: completeSampleAppPath, - - MergableSampleAppPaths: appNamesDirSlice, - AllSampleAppsPaths: append(appNamesDirSlice, completeSampleAppPath), - FreewheelEnabledSampleAppsPaths: []DirAbs{freewheelSampleAppPath, completeSampleAppPath, optionsSampleAppPath}, - IMAEnabledSampleAppPaths: []DirAbs{imaSampleAppPath, completeSampleAppPath, optionsSampleAppPath}, - AdobePassEnabledSampleAppPaths: []DirAbs{completeSampleAppPath, adobepassSampleAppPath}, - - PlayersPackageDirRel: MakeDirRel(Join(MakeDirRel("app/src/main/java/com/ooyala/sample"), MakeDirName("players"))), - ListPackageDirRel: MakeDirRel(Join(MakeDirRel("app/src/main/java/com/ooyala/sample"), MakeDirName("lists"))), - UtilsPackageDirRel: MakeDirRel(Join(MakeDirRel("app/src/main/java/com/ooyala/sample"), MakeDirName("utils"))), - LayoutDirRel: MakeDirRel(Join(MakeDirName("app/src/main/res"), MakeDirName("layout"))), - } - util.RequireFullStructOrDie(c, logger) - return c -} diff --git a/go_script/src/mobile.ooyala.com/samples/config/vendor_config/vendor_config.go b/go_script/src/mobile.ooyala.com/samples/config/vendor_config/vendor_config.go deleted file mode 100644 index f4790862a..000000000 --- a/go_script/src/mobile.ooyala.com/samples/config/vendor_config/vendor_config.go +++ /dev/null @@ -1,81 +0,0 @@ -package vendor_config - -import "log" -import "mobile.ooyala.com/common/util" -import . "mobile.ooyala.com/common/path" - -/** - * This config file represents folders to access vendor files. - * Consistent between Android and iOS sample app - */ -type Config struct { - RootPath DirAbs - - VendorFreewheelFolderPath DirAbs - VendorIMAFolderPath DirAbs - - VendorOoyalaRootFolderPath DirAbs - VendorOoyalaFreewheelFolderPath DirAbs - VendorOoyalaIMAFolderPath DirAbs - VendorOoyalaCoreFolderPath DirAbs - - OoyalaCoreSDKFilePaths []Pather - IMASDKFilePaths []Pather - FreewheelSDKFilePaths []Pather - AdobePassSDKFilePaths []Pather -} - -func MakeConfig(platformName string, rootPath DirAbs, logger *log.Logger) Config { - vendorDirName := MakeDirName("vendor") - vendorPath := MakeDirAbs(Join(rootPath, vendorDirName)) - - //Names of all folders in vendor - freewheelDirName := MakeDirName("Freewheel") - googleDirName := MakeDirName("Google") - adobepassDirName := MakeDirName("AdobePass") - ooyalaDirName := MakeDirName("Ooyala") - ooyalaIMADirName := MakeDirName("OoyalaIMASDK-" + platformName) - ooyalaFWDirName := MakeDirName("OoyalaFreewheelSDK-" + platformName) - ooyalaCoreDirName := MakeDirName("OoyalaSDK-" + platformName) - - ooyalaCoreFileName := MakeFileName("OoyalaSDK.jar") - ooyalaFWFileName := MakeFileName("OoyalaFreewheelSDK.jar") - ooyalaIMAFileName := MakeFileName("OoyalaIMASDK.jar") - - imaFileName := MakeFileName("ima-android-sdk-beta9.jar") - freewheelFileName := MakeFileRel(Join(MakeDirName("Android_AdManagerDistribution"), MakeFileName("FWAdManager.jar"))) - adobepassFileName := MakeFileName("android_accessenabler-1.7.3.jar") - - vendorFreewheelFolderPath := MakeDirAbs(Join(vendorPath, freewheelDirName)) - vendorIMAFolderPath := MakeDirAbs(Join(vendorPath, googleDirName)) - vendorAdobePassFolderPath := MakeDirAbs(Join(vendorPath, adobepassDirName)) - - vendorOoyalaRootFolderPath := MakeDirAbs(Join(vendorPath, ooyalaDirName)) - vendorOoyalaFreewheelFolderPath := MakeDirAbs(Join(vendorPath, ooyalaDirName, ooyalaFWDirName)) - vendorOoyalaIMAFolderPath := MakeDirAbs(Join(vendorPath, ooyalaDirName, ooyalaIMADirName)) - vendorOoyalaCoreFolderPath := MakeDirAbs(Join(vendorPath, ooyalaDirName, ooyalaCoreDirName)) - - c := Config { - RootPath: rootPath, - - VendorFreewheelFolderPath: vendorFreewheelFolderPath, - VendorIMAFolderPath: vendorIMAFolderPath, - - VendorOoyalaRootFolderPath: vendorOoyalaRootFolderPath, - VendorOoyalaFreewheelFolderPath: vendorOoyalaFreewheelFolderPath, - VendorOoyalaIMAFolderPath: vendorOoyalaIMAFolderPath, - VendorOoyalaCoreFolderPath: vendorOoyalaCoreFolderPath, - - OoyalaCoreSDKFilePaths: []Pather{ MakeFileAbs(Join(vendorOoyalaCoreFolderPath, ooyalaCoreFileName)) }, - - IMASDKFilePaths: []Pather{ MakeFileAbs(Join(vendorIMAFolderPath, imaFileName)), - MakeFileAbs(Join(vendorOoyalaIMAFolderPath, ooyalaIMAFileName)) }, - - FreewheelSDKFilePaths: []Pather{ MakeFileAbs(Join(vendorFreewheelFolderPath, freewheelFileName)), - MakeFileAbs(Join(vendorOoyalaFreewheelFolderPath, ooyalaFWFileName)) }, - - AdobePassSDKFilePaths: []Pather{ MakeFileAbs(Join(vendorAdobePassFolderPath, adobepassFileName)) }, - } - util.RequireFullStructOrDie(c, logger) - return c -} diff --git a/go_script/src/mobile.ooyala.com/samples/config/zip_config/zip_config.go b/go_script/src/mobile.ooyala.com/samples/config/zip_config/zip_config.go deleted file mode 100644 index 78604beb8..000000000 --- a/go_script/src/mobile.ooyala.com/samples/config/zip_config/zip_config.go +++ /dev/null @@ -1,52 +0,0 @@ -package zip_config - -import "log" -import "mobile.ooyala.com/common/util" -import . "mobile.ooyala.com/common/path" - -/** - * This config file represents folders to access vendor files. - * Consistent between Android and iOS sample app - */ -type Config struct { - RootPath DirAbs - - CoreSDKFileName FileName - FreewheelSDKFileName FileName - IMASDKFileName FileName - - CoreSDKCandidateURL string - FreewheelSDKCandidateURL string - IMASDKCandidateURL string - - CoreSDKURL string - FreewheelSDKURL string - IMASDKURL string -} - - - -func MakeConfig(platformName string, rootPath DirAbs, logger *log.Logger) Config { - ooyalaIMADirName := MakeDirName("OoyalaIMASDK-" + platformName) - ooyalaFWDirName := MakeDirName("OoyalaFreewheelSDK-" + platformName) - ooyalaCoreDirName := MakeDirName("OoyalaSDK-" + platformName) - - - c := Config { - RootPath: rootPath, - - IMASDKFileName: MakeFileName(ooyalaCoreDirName.S + ".zip"), - FreewheelSDKFileName: MakeFileName(ooyalaFWDirName.S + ".zip"), - CoreSDKFileName: MakeFileName(ooyalaIMADirName.S + ".zip"), - - IMASDKCandidateURL: "https://ooyala.box.com/shared/static/ubnku1wycclufczldxhcz8zyp9jck726.zip", - FreewheelSDKCandidateURL: "https://ooyala.box.com/shared/static/0ztawz50oqkr9gggyvy46drbxs0gag5f.zip", - CoreSDKCandidateURL: "https://ooyala.box.com/shared/static/zh55rsm1us5o4ikfzc87tf585o3h2zzs.zip", - - CoreSDKURL: "https://ooyala.box.com/shared/static/90wup42cbi7ywel2all2.zip", - FreewheelSDKURL: "https://ooyala.box.com/shared/static/i17ps4vjmne3bsnnc9sz.zip", - IMASDKURL: "https://ooyala.box.com/shared/static/j1189d1o59t3sdaony7l.zip", - } - util.RequireFullStructOrDie(c, logger) - return c -} diff --git a/go_script/src/mobile.ooyala.com/samples/copy_from_vendor/copy_from_vendor.go b/go_script/src/mobile.ooyala.com/samples/copy_from_vendor/copy_from_vendor.go deleted file mode 100644 index e343efda5..000000000 --- a/go_script/src/mobile.ooyala.com/samples/copy_from_vendor/copy_from_vendor.go +++ /dev/null @@ -1,58 +0,0 @@ -package main -import ol "mobile.ooyala.com/common/log" -import "log" -import "mobile.ooyala.com/common/util" -import . "mobile.ooyala.com/common/path" -import vc "mobile.ooyala.com/samples/config/vendor_config" -import sc "mobile.ooyala.com/samples/config/sample_app_config" - - -func main() { - l, err := ol.NewFileAndStdoutLoggerNow(MakeFileAbs("/tmp/android-sample-apps.copy_from_vendor")) - ol.ColorizedPrintln(l, "CopyFromVendor") - util.MaybeDie(err, nil) - - rootDir, err := util.ToDirAbs(MakeDirRel(".")) - util.MaybeDie(err, l) - - //Make configs - vendorConfig := vc.MakeConfig("Android", rootDir, l); - sampleAppConfig := sc.MakeConfig("Android", rootDir, l); - - copyOoyalaCoreSDKFromVendor(sampleAppConfig, vendorConfig, l) - copyOoyalaFreewheelSDKFromVendor(sampleAppConfig, vendorConfig, l) - copyOoyalaIMASDKFromVendor(sampleAppConfig, vendorConfig, l) - copyAdobePassSDKFromVendor(sampleAppConfig, vendorConfig, l) -} - -func copyOoyalaCoreSDKFromVendor(sampleAppConfig sc.Config, vendorConfig vc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - copyLibrariesFromVendor(vendorConfig.OoyalaCoreSDKFilePaths, sampleAppConfig.AllSampleAppsPaths, l) -} - -func copyOoyalaFreewheelSDKFromVendor(sampleAppConfig sc.Config, vendorConfig vc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - copyLibrariesFromVendor(vendorConfig.FreewheelSDKFilePaths, sampleAppConfig.FreewheelEnabledSampleAppsPaths, l) -} - -func copyOoyalaIMASDKFromVendor(sampleAppConfig sc.Config, vendorConfig vc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - copyLibrariesFromVendor(vendorConfig.IMASDKFilePaths, sampleAppConfig.IMAEnabledSampleAppPaths, l) -} - -func copyAdobePassSDKFromVendor(sampleAppConfig sc.Config, vendorConfig vc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - copyLibrariesFromVendor(vendorConfig.AdobePassSDKFilePaths, sampleAppConfig.AdobePassEnabledSampleAppPaths, l) -} - -func copyLibrariesFromVendor(libraryPaths []Pather, sampleAppPaths []DirAbs, l *log.Logger) { - for _, appPath := range sampleAppPaths { - appLibsDir := MakeDirAbs(Join(appPath, MakeDirRel("app/libs"))) - util.EnsurePath(appLibsDir, l) - - for _, libraryPath := range libraryPaths { - util.RequirePath(libraryPath, l) - util.CopyPath(libraryPath, appLibsDir, l) - } - } -} \ No newline at end of file diff --git a/go_script/src/mobile.ooyala.com/samples/get_latest_rc/get_latest_rc.go b/go_script/src/mobile.ooyala.com/samples/get_latest_rc/get_latest_rc.go deleted file mode 100644 index 212fe9b19..000000000 --- a/go_script/src/mobile.ooyala.com/samples/get_latest_rc/get_latest_rc.go +++ /dev/null @@ -1,79 +0,0 @@ -package main -import ol "mobile.ooyala.com/common/log" -import "log" -import "mobile.ooyala.com/common/util" -import . "mobile.ooyala.com/common/path" -import vc "mobile.ooyala.com/samples/config/vendor_config" -import zc "mobile.ooyala.com/samples/config/zip_config" - -func main() { - l, err := ol.NewFileAndStdoutLoggerNow(MakeFileAbs("/tmp/android-sample-apps.get_latest_rc")) - ol.ColorizedPrintln(l, "GetLatestRc") - util.MaybeDie(err, nil) - - rootDir, err := util.ToDirAbs(MakeDirRel(".")) - util.MaybeDie(err, l) - - config := vc.MakeConfig("Android", rootDir, l); - zipConfig := zc.MakeConfig("Android", rootDir, l); - - removeOldOoyalaVendorFolders(config, l) - - downloadNewRCPackages(config, zipConfig, l) - - unzipNewRCPackages(config, zipConfig, l) - - removeZipFiles(config, zipConfig, l) - - //TEMPORARY: Remove all sample apps provided in the packages, until the sample apps are no longer included - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaCoreFolderPath, MakeFileName("SampleApps"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaCoreFolderPath, MakeFileName("APIDocs"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaCoreFolderPath, MakeFileName("DefaultControlsSource"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaFreewheelFolderPath, MakeFileName("FreewheelSampleApp"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaFreewheelFolderPath, MakeFileName("APIDocs"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaIMAFolderPath,MakeFileName("IMASampleApp"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaIMAFolderPath, MakeFileName("APIDocs"))), l); -} - -func removeOldOoyalaVendorFolders(config vc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - util.DeletePath(config.VendorOoyalaFreewheelFolderPath, l); - util.DeletePath(config.VendorOoyalaCoreFolderPath, l); - util.DeletePath(config.VendorOoyalaIMAFolderPath, l); -} - -func downloadNewRCPackages(config vc.Config, zipConfig zc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - _, err := util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "wget '" + zipConfig.CoreSDKCandidateURL + "' -O " + zipConfig.CoreSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "wget '" + zipConfig.FreewheelSDKCandidateURL + "' -O " + zipConfig.FreewheelSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "wget '" + zipConfig.IMASDKCandidateURL + "' -O " + zipConfig.IMASDKFileName.S, l) - util.MaybeDie(err, l) -} - -func unzipNewRCPackages(config vc.Config, zipConfig zc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - _, err := util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "unzip " + zipConfig.CoreSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "unzip " + zipConfig.FreewheelSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "unzip " + zipConfig.IMASDKFileName.S, l) - util.MaybeDie(err, l) -} - -func removeZipFiles(config vc.Config, zipConfig zc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - _, err := util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "rm " + zipConfig.CoreSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "rm " + zipConfig.FreewheelSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "rm " + zipConfig.IMASDKFileName.S, l) - util.MaybeDie(err, l) -} \ No newline at end of file diff --git a/go_script/src/mobile.ooyala.com/samples/get_latest_release/get_latest_release.go b/go_script/src/mobile.ooyala.com/samples/get_latest_release/get_latest_release.go deleted file mode 100644 index edac562da..000000000 --- a/go_script/src/mobile.ooyala.com/samples/get_latest_release/get_latest_release.go +++ /dev/null @@ -1,80 +0,0 @@ -package main -import ol "mobile.ooyala.com/common/log" -import "log" -import "mobile.ooyala.com/common/util" -import . "mobile.ooyala.com/common/path" -import vc "mobile.ooyala.com/samples/config/vendor_config" -import zc "mobile.ooyala.com/samples/config/zip_config" - -func main() { - l, err := ol.NewFileAndStdoutLoggerNow(MakeFileAbs("/tmp/android-sample-apps.get_latest_release")) - ol.ColorizedPrintln(l, "GetLatestRelease") - util.MaybeDie(err, nil) - - rootDir, err := util.ToDirAbs(MakeDirRel(".")) - util.MaybeDie(err, l) - - config := vc.MakeConfig("Android", rootDir, l); - zipConfig := zc.MakeConfig("Android", rootDir, l); - - - removeOldOoyalaVendorFolders(config, l) - - downloadNewRCPackages(config, zipConfig, l) - - unzipNewRCPackages(config, zipConfig, l) - - removeZipFiles(config, zipConfig, l) - - //TEMPORARY: Remove all sample apps provided in the packages, until the sample apps are no longer included - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaCoreFolderPath, MakeFileName("SampleApps"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaCoreFolderPath, MakeFileName("APIDocs"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaCoreFolderPath, MakeFileName("DefaultControlsSource"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaFreewheelFolderPath, MakeFileName("FreewheelSampleApp"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaFreewheelFolderPath, MakeFileName("APIDocs"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaIMAFolderPath,MakeFileName("IMASampleApp"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaIMAFolderPath, MakeFileName("APIDocs"))), l); -} - -func removeOldOoyalaVendorFolders(config vc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - util.DeletePath(config.VendorOoyalaFreewheelFolderPath, l); - util.DeletePath(config.VendorOoyalaCoreFolderPath, l); - util.DeletePath(config.VendorOoyalaIMAFolderPath, l); -} - -func downloadNewRCPackages(config vc.Config, zipConfig zc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - _, err := util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "wget '" + zipConfig.CoreSDKURL + "' -O " + zipConfig.CoreSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "wget '" + zipConfig.FreewheelSDKURL + "' -O " + zipConfig.FreewheelSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "wget '" + zipConfig.IMASDKURL + "' -O " + zipConfig.IMASDKFileName.S, l) - util.MaybeDie(err, l) -} - -func unzipNewRCPackages(config vc.Config, zipConfig zc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - _, err := util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "unzip " + zipConfig.CoreSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "unzip " + zipConfig.FreewheelSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "unzip " + zipConfig.IMASDKFileName.S, l) - util.MaybeDie(err, l) -} - -func removeZipFiles(config vc.Config, zipConfig zc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - _, err := util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "rm " + zipConfig.CoreSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "rm " + zipConfig.FreewheelSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "rm " + zipConfig.IMASDKFileName.S, l) - util.MaybeDie(err, l) -} \ No newline at end of file diff --git a/go_script/src/mobile.ooyala.com/samples/merge_into_complete_sample_app/merge_into_complete_sample_app.go b/go_script/src/mobile.ooyala.com/samples/merge_into_complete_sample_app/merge_into_complete_sample_app.go deleted file mode 100644 index 076244f6d..000000000 --- a/go_script/src/mobile.ooyala.com/samples/merge_into_complete_sample_app/merge_into_complete_sample_app.go +++ /dev/null @@ -1,44 +0,0 @@ -package main -import ol "mobile.ooyala.com/common/log" -import "log" -import "mobile.ooyala.com/common/util" -import . "mobile.ooyala.com/common/path" -import sc "mobile.ooyala.com/samples/config/sample_app_config" - - -func main() { - l, err := ol.NewFileAndStdoutLoggerNow(MakeFileAbs("/tmp/android-sample-apps.merge")) - ol.ColorizedPrintln(l, "MergeIntoCompleteSampleApp") - util.MaybeDie(err, nil) - - rootDir, err := util.ToDirAbs(MakeDirRel(".")) - util.MaybeDie(err, l) - - //Make configs - config := sc.MakeConfig("Android", rootDir, l); - - l.Println("We found the following apps:") - for _, element := range config.MergableSampleAppPaths { - l.Println(element.String()) - copyFilesFromSampleApp(element, config, l) - - } -} - -func copyFilesFromSampleApp(sampleAppRootDirAbs DirAbs, config sc.Config, l *log.Logger) { - ol.ColorizedPrintln(l, "Copying from " + sampleAppRootDirAbs.Base().S + " into Complete App") - srcPlayersDirAbs := MakeDirAbs(Join(sampleAppRootDirAbs, config.PlayersPackageDirRel)) - srcListsDirAbs := MakeDirAbs(Join(sampleAppRootDirAbs, config.ListPackageDirRel)) - srcUtilsDirAbs := MakeDirAbs(Join(sampleAppRootDirAbs, config.UtilsPackageDirRel)) - srcLayoutDirAbs := MakeDirAbs(Join(sampleAppRootDirAbs, config.LayoutDirRel)) - - dstPlayersDirAbs := MakeDirAbs(Join(config.CompleteSampleAppPath, config.PlayersPackageDirRel)) - dstListsDirAbs := MakeDirAbs(Join(config.CompleteSampleAppPath, config.ListPackageDirRel)) - dstUtilsDirAbs := MakeDirAbs(Join(config.CompleteSampleAppPath, config.UtilsPackageDirRel)) - dstLayoutDirAbs := MakeDirAbs(Join(config.CompleteSampleAppPath, config.LayoutDirRel)) - - util.CopyPathContents(srcPlayersDirAbs, dstPlayersDirAbs, l) - util.CopyPathContents(srcListsDirAbs, dstListsDirAbs, l) - util.CopyPathContents(srcUtilsDirAbs, dstUtilsDirAbs, l) - util.CopyPathContents(srcLayoutDirAbs, dstLayoutDirAbs, l) -} \ No newline at end of file diff --git a/go_script/src/mobile.ooyala.com/samples/update_from_target_location/update_from_target_location.go b/go_script/src/mobile.ooyala.com/samples/update_from_target_location/update_from_target_location.go deleted file mode 100644 index 450734609..000000000 --- a/go_script/src/mobile.ooyala.com/samples/update_from_target_location/update_from_target_location.go +++ /dev/null @@ -1,127 +0,0 @@ -package main - -import "errors" -import gl "log" -import ol "mobile.ooyala.com/common/log" -import args "mobile.ooyala.com/common/args/parse" -import "log" -import "mobile.ooyala.com/common/util" -import . "mobile.ooyala.com/common/path" -import vc "mobile.ooyala.com/samples/config/vendor_config" -import zc "mobile.ooyala.com/samples/config/zip_config" - -func run(fn func() error, l *gl.Logger) { - err := fn() - if err != nil { - util.Die(err, l) - } -} - -func loadFlags(l *gl.Logger) (args.Config, error) { - c := args.MakeConfig(l) - err := args.ParseArgs(c, l) - return c, err -} - -func main() { - l, err := ol.NewFileAndStdoutLoggerNow(MakeFileAbs("/tmp/android-sample-apps.update_from_target_location")) - ol.ColorizedPrintln(l, "android update from target location") - util.MaybeDie(err, nil) - - rootDir, err := util.ToDirAbs(MakeDirRel(".")) - util.MaybeDie(err, l) - - config := vc.MakeConfig("Android", rootDir, l); - zipConfig := zc.MakeConfig("Android", rootDir, l); - - var configArgs args.Config - run( func() error { var err error; configArgs, err = loadFlags(l); return err }, l) - - sdkFolderPath := *configArgs.Path - - if sdkFolderPath == "" { - util.Die(errors.New("ERROR: no path passed in"), l) - } - - checkSdkExist(sdkFolderPath, zipConfig, l) - - removeOldOoyalaVendorFolders(config, l) - - copyFromTargetFolders(config, zipConfig, l, sdkFolderPath) - - unzipNewRCPackages(config, zipConfig, l) - - removeZipFiles(config, zipConfig, l) - - //TEMPORARY: Remove all sample apps provided in the packages, until the sample apps are no longer included - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaCoreFolderPath, MakeFileName("SampleApps"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaCoreFolderPath, MakeFileName("APIDocs"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaCoreFolderPath, MakeFileName("DefaultControlsSource"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaFreewheelFolderPath, MakeFileName("FreewheelSampleApp"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaFreewheelFolderPath, MakeFileName("APIDocs"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaIMAFolderPath,MakeFileName("IMASampleApp"))), l); - util.DeletePath(MakeFileAbs(Join(config.VendorOoyalaIMAFolderPath, MakeFileName("APIDocs"))), l); -} - -func removeOldOoyalaVendorFolders(config vc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - util.DeletePath(config.VendorOoyalaFreewheelFolderPath, l); - util.DeletePath(config.VendorOoyalaCoreFolderPath, l); - util.DeletePath(config.VendorOoyalaIMAFolderPath, l); -} - -func copyFromTargetFolders(config vc.Config, zipConfig zc.Config, l *log.Logger, sdkFolderPathString string) { - ol.ColorizedMethodPrintln(l) - - if sdkFolderPathString == "" { - util.Die(util.NewErrorWithMessageAndStack("Folder Path String was empty"), l) - } - - sdkFolderPath := MakeDirAbs(sdkFolderPathString) - - _, err := util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "cp " + MakeFileAbs(Join(sdkFolderPath, zipConfig.CoreSDKFileName)).S + " " + zipConfig.CoreSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "cp " + MakeFileAbs(Join(sdkFolderPath, zipConfig.FreewheelSDKFileName)).S + " " + zipConfig.FreewheelSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "cp " + MakeFileAbs(Join(sdkFolderPath, zipConfig.IMASDKFileName)).S + " " + zipConfig.IMASDKFileName.S, l) - util.MaybeDie(err, l) -} - - -func unzipNewRCPackages(config vc.Config, zipConfig zc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - _, err := util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "unzip -o " + zipConfig.CoreSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "unzip -o " + zipConfig.FreewheelSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "unzip -o " + zipConfig.IMASDKFileName.S, l) - util.MaybeDie(err, l) -} - -func removeZipFiles(config vc.Config, zipConfig zc.Config, l *log.Logger) { - ol.ColorizedMethodPrintln(l) - _, err := util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "rm " + zipConfig.CoreSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "rm " + zipConfig.FreewheelSDKFileName.S, l) - util.MaybeDie(err, l) - - _, err = util.RunBashCommandInDir(config.VendorOoyalaRootFolderPath, "rm " + zipConfig.IMASDKFileName.S, l) - util.MaybeDie(err, l) -} - -func checkSdkExist(sdkFolderPathString string, zipConfig zc.Config, l *log.Logger) { - sdkFolderPath := MakeDirAbs(sdkFolderPathString) - - CoreSDKPath := MakeFileAbs(Join(sdkFolderPath, zipConfig.CoreSDKFileName)) - FreewheelSDKPath := MakeFileAbs(Join(sdkFolderPath, zipConfig.FreewheelSDKFileName)) - IMASDKPath := MakeFileAbs(Join(sdkFolderPath, zipConfig.IMASDKFileName)) - - sdkPaths := []Pather{CoreSDKPath, FreewheelSDKPath, IMASDKPath} - - run( func() error { var err error; err = util.RequirePaths(sdkPaths, l); return err }, l) - }