You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by st...@apache.org on 2016/02/11 02:54:35 UTC
[6/9] incubator-mynewt-newt git commit: add additional_package_paths
to specify additional package search paths in a repository for newt. update
godeps
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/misc.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/misc.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/misc.go
deleted file mode 100644
index d66d2b7..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/misc.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package main
-
-import (
- "fmt"
- curl "github.com/andelf/go-curl"
- "os"
- "reflect"
-)
-
-const endl = "\n"
-
-func main() {
- println("DEBUG chdir=>", os.Chdir("/sadf"))
- ret := curl.EasyInit()
- defer ret.Cleanup()
- print("init =>", ret, " ", reflect.TypeOf(ret).String(), endl)
- ret = ret.Duphandle()
- defer ret.Cleanup()
-
- print("dup =>", ret, " ", reflect.TypeOf(ret).String(), endl)
- print("global init =>", curl.GlobalInit(curl.GLOBAL_ALL), endl)
- print("version =>", curl.Version(), endl)
- // debug
- //print("set verbose =>", ret.Setopt(curl.OPT_VERBOSE, true), endl)
-
- //print("set header =>", ret.Setopt(curl.OPT_HEADER, true), endl)
-
- // auto calculate port
- // print("set port =>", ret.EasySetopt(curl.OPT_PORT, 6060), endl)
- fmt.Printf("XXXX debug setopt %#v \n", ret.Setopt(30000, 19).Error())
-
- print("set timeout =>", ret.Setopt(curl.OPT_TIMEOUT, 20), endl)
-
- //print("set post size =>", ret.Setopt(curl.OPT_POSTFIELDSIZE, 10), endl)
- if ret.Setopt(curl.OPT_URL, "http://www.baidu.com:8000/") != nil {
- println("set url ok!")
- }
- //print("set url =>", ret.Setopt(curl.OPT_URL, "http://commondatastorage.googleapis.com/chromium-browser-continuous/Linux_x64/104547/chrome-linux.zip"), endl)
-
- print("set user_agent =>", ret.Setopt(curl.OPT_USERAGENT, "go-curl v0.0.1") == nil, endl)
- // add to DNS cache
- print("set resolve =>", ret.Setopt(curl.OPT_RESOLVE, []string{"www.baidu.com:8000:127.0.0.1"}) == nil, endl)
- // ret.EasyReset() clean seted
-
- // currently not finished!
- //
- fooTest := func(buf []byte, userdata interface{}) bool {
- // buf := ptr.([]byte)
- println("size=>", len(buf))
- println("DEBUG(in callback)", buf, userdata)
- println("data = >", string(buf))
- return true
- }
-
- ret.Setopt(curl.OPT_WRITEFUNCTION, fooTest) // curl.CallbackWriteFunction(fooTest))
- println("set opt!")
- // for test only
-
- code := ret.Perform()
- // dump.Dump(code)
- fmt.Printf("code -> %v\n", code)
-
- println("================================")
- print("pause =>", ret.Pause(curl.PAUSE_ALL), endl)
-
- print("escape =>", ret.Escape("http://baidu.com/"), endl)
- print("unescape =>", ret.Unescape("http://baidu.com/-%00-%5c"), endl)
-
- print("unescape lenght =>", len(ret.Unescape("http://baidu.com/-%00-%5c")), endl)
- // print("version info data =>", curl.VersionInfo(1), endl)
- ver := curl.VersionInfo(curl.VERSION_NOW)
- fmt.Printf("VersionInfo: Age: %d, Version:%s, Host:%s, Features:%d, SslVer: %s, LibzV: %s, ssh: %s\n",
- ver.Age, ver.Version, ver.Host, ver.Features, ver.SslVersion, ver.LibzVersion, ver.LibsshVersion)
-
- print("Protocols:")
- for _, p := range ver.Protocols {
- print(p, ", ")
- }
- print(endl)
- println(curl.Getdate("20111002 15:05:58 +0800").String())
- ret.Getinfo(curl.INFO_EFFECTIVE_URL)
- ret.Getinfo(curl.INFO_RESPONSE_CODE)
-
- ret.Getinfo(curl.INFO_FILETIME)
- ret.Getinfo(curl.INFO_SSL_ENGINES)
-
- ret.Getinfo(curl.INFO_TOTAL_TIME)
-
- println("================================")
-
- // ret.Getinfo(curl.INFO_SSL_ENGINES)
-
- /* mret := curl.MultiInit()
- mret.AddHandle(ret) // works
- defer mret.Cleanup()
- if ok, handles := mret.Perform(); ok == curl.OK {
- fmt.Printf("ok=%s, handles=%d\n", ok, handles)
- } else {
- fmt.Printf("error calling multi\n")
- }
- */
- println("================================")
- //println(curl.GlobalInit(curl.GLOBAL_SSL))
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_and_select.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_and_select.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_and_select.go
deleted file mode 100644
index 950da36..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_and_select.go
+++ /dev/null
@@ -1,101 +0,0 @@
-package main
-
-/*
-#include <stdlib.h>
-#include <sys/select.h>
-static void _FD_ZERO(void *set) {
- FD_ZERO((fd_set*)set);
-}
-static void _FD_SET(int sysfd, void *set) {
- FD_SET(sysfd, (fd_set*)set);
-}
-static int _FD_ISSET (int sysfd, void *set) {
- return FD_ISSET(sysfd, (fd_set*)set);
-}
-*/
-import "C"
-
-import (
- curl "github.com/Pyrrvs/go-curl"
- "syscall"
- "unsafe"
- "fmt"
-)
-
-func FD_ZERO(set *syscall.FdSet) {
- s := unsafe.Pointer(set)
- C._FD_ZERO(s)
-}
-
-func FD_SET(sysfd int, set *syscall.FdSet) {
- s := unsafe.Pointer(set)
- fd := C.int(sysfd)
- C._FD_SET(fd, s)
-}
-
-func FD_ISSET(sysfd int, set *syscall.FdSet) bool {
- s := unsafe.Pointer(set)
- fd := C.int(sysfd)
- return C._FD_ISSET(fd, s) != 0
-}
-
-func main() {
- var (
- rset, wset, eset syscall.FdSet
- still_running, curl_timeout int = 0, 0
- err error
- )
-
- ch1 := curl.EasyInit()
- ch2 := curl.EasyInit()
-
- ch1.Setopt(curl.OPT_URL, "http://www.163.com")
- ch1.Setopt(curl.OPT_HEADER, 0)
- ch1.Setopt(curl.OPT_VERBOSE, true)
- ch2.Setopt(curl.OPT_URL, "http://www.baidu.com")
- ch2.Setopt(curl.OPT_HEADER, 0)
- ch2.Setopt(curl.OPT_VERBOSE, true)
-
- mh := curl.MultiInit()
-
- mh.AddHandle(ch1)
- mh.AddHandle(ch2)
-
- for {
- FD_ZERO(&rset)
- FD_ZERO(&wset)
- FD_ZERO(&eset)
-
- timeout := syscall.Timeval{Sec:1, Usec:0}
- curl_timeout, err = mh.Timeout()
- if err != nil {
- fmt.Printf("Error multi_timeout: %s\n", err)
- }
- if curl_timeout >= 0 {
- timeout.Sec = int64(curl_timeout / 1000)
- if timeout.Sec > 1 {
- timeout.Sec = 1
- } else {
- timeout.Usec = int64((curl_timeout % 1000)) * 1000
- }
- }
-
- max_fd, err := mh.Fdset(&rset, &wset, &eset)
- if err != nil {
- fmt.Printf("Error FDSET: %s\n", err)
- }
-
- _, err = syscall.Select(int(max_fd + 1), &rset, &wset, &eset, &timeout)
- if err != nil {
- fmt.Printf("Error select: %s\n", err)
- } else {
- still_running, err = mh.Perform()
- if still_running > 0 {
- fmt.Printf("Still running: %d\n", still_running)
- } else {
- break
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_sample.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_sample.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_sample.go
deleted file mode 100644
index a0563a8..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/multi_sample.go
+++ /dev/null
@@ -1,36 +0,0 @@
-
-package main
-
-import (
- curl "github.com/andelf/go-curl"
- "time"
-)
-
-func main() {
-
- ch1 := curl.EasyInit()
- ch2 := curl.EasyInit()
-
- ch1.Setopt(curl.OPT_URL, "http://www.163.com")
- ch1.Setopt(curl.OPT_HEADER, 0)
- ch1.Setopt(curl.OPT_VERBOSE, true)
- ch2.Setopt(curl.OPT_URL, "http://www.baidu.com")
- ch2.Setopt(curl.OPT_HEADER, 0)
- ch2.Setopt(curl.OPT_VERBOSE, true)
-
- mh := curl.MultiInit()
-
- mh.AddHandle(ch1)
- mh.AddHandle(ch2)
-
- for {
- nRunning, _ := mh.Perform()
- // println("n =", nRunning)
- if nRunning == 0 {
- println("ok")
- break
- }
- time.Sleep(1000)
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/post-callback.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/post-callback.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/post-callback.go
deleted file mode 100644
index 3b02802..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/post-callback.go
+++ /dev/null
@@ -1,43 +0,0 @@
-package main
-
-import (
- curl "github.com/andelf/go-curl"
- "time"
-)
-
-const POST_DATA = "a_test_data_only"
-
-var sent = false
-
-func main() {
- // init the curl session
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://www.google.com")
-
- easy.Setopt(curl.OPT_POST, true)
- easy.Setopt(curl.OPT_VERBOSE, true)
-
- easy.Setopt(curl.OPT_READFUNCTION,
- func(ptr []byte, userdata interface{}) int {
- // WARNING: never use append()
- if !sent {
- sent = true
- ret := copy(ptr, POST_DATA)
- return ret
- }
- return 0 // sent ok
- })
-
- // disable HTTP/1.1 Expect 100
- easy.Setopt(curl.OPT_HTTPHEADER, []string{"Expect:"})
- // must set
- easy.Setopt(curl.OPT_POSTFIELDSIZE, len(POST_DATA))
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-
- time.Sleep(10000) // wait gorotine
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/progress.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/progress.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/progress.go
deleted file mode 100644
index 09efcf5..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/progress.go
+++ /dev/null
@@ -1,47 +0,0 @@
-// A sample program to show how to use PROGRESS callback to calculate
-// downloading percentage and speed
-package main
-
-import (
- "fmt"
- curl "github.com/andelf/go-curl"
- "time"
-)
-
-func write_data(ptr []byte, userdata interface{}) bool {
- // make it ok, do nothing
- return true
-}
-
-func main() {
- curl.GlobalInit(curl.GLOBAL_ALL)
-
- // init the curl session
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://curl.haxx.se/download/curl-7.22.0.tar.gz")
-
- easy.Setopt(curl.OPT_WRITEFUNCTION, write_data)
-
- easy.Setopt(curl.OPT_NOPROGRESS, false)
-
- started := int64(0)
- easy.Setopt(curl.OPT_PROGRESSFUNCTION, func(dltotal, dlnow, ultotal, ulnow float64, userdata interface{}) bool {
- // canceled when 50% finished
- if dlnow/dltotal > 0.5 {
- println("")
- // abort downloading
- return false
- }
- if started == 0 {
- started = time.Now().Unix()
- }
- fmt.Printf("Downloaded: %3.2f%%, Speed: %.1fKiB/s \r", dlnow/dltotal*100, dlnow/1000/float64((time.Now().Unix()-started)))
- return true
- })
-
- if err := easy.Perform(); err != nil {
- fmt.Printf("ERROR: %v\n", err)
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_login.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_login.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_login.go
deleted file mode 100644
index 60ef84c..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_login.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// 测试人人网登录, 并保存cookiejar
-package main
-
-import (
- "flag"
- curl "github.com/andelf/go-curl"
-)
-
-func main() {
- // init the curl session
-
- var username *string = flag.String("username", "test", "renren.com email")
- var password *string = flag.String("password", "test", "renren.com password")
-
- flag.Parse()
-
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://m.renren.com/home.do")
-
- easy.Setopt(curl.OPT_PORT, 80)
- easy.Setopt(curl.OPT_VERBOSE, true)
-
- easy.Setopt(curl.OPT_COOKIEJAR, "./cookie.jar")
-
- // disable HTTP/1.1 Expect: 100-continue
- easy.Setopt(curl.OPT_HTTPHEADER, []string{"Expect:"})
-
- postdata := "email=" + *username + "&password=" + *password + "&login=" + easy.Escape("登录")
- easy.Setopt(curl.OPT_POSTFIELDS, postdata)
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_upload.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_upload.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_upload.go
deleted file mode 100644
index d02e320..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/renren_upload.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// 人人网图片上传
-package main
-
-import (
- "fmt"
- curl "github.com/andelf/go-curl"
- "regexp"
- "time"
-)
-
-func getUploadUrl() string {
- page := ""
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- u := "http://3g.renren.com/album/wuploadphoto.do"
- easy.Setopt(curl.OPT_URL, u)
- easy.Setopt(curl.OPT_COOKIEFILE, "./cookie.jar")
- easy.Setopt(curl.OPT_COOKIEJAR, "./cookie.jar")
- easy.Setopt(curl.OPT_VERBOSE, true)
- easy.Setopt(curl.OPT_WRITEFUNCTION, func(ptr []byte, _ interface{}) bool {
- page += string(ptr)
- return true
- })
- easy.Perform()
- // extract url from
- // <form enctype="multipart/form-data" action="http://3g.renren.com/album/wuploadphoto.do?type=3&sid=zv3tiXTZr6Cu1rj5dhgX_X"
- pattern, _ := regexp.Compile(`action="(.*?)"`)
-
- if matches := pattern.FindStringSubmatch(page); len(matches) == 2 {
- return matches[1]
- }
- return ""
-}
-
-func main() {
- // init the curl session
-
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- posturl := getUploadUrl()
-
- easy.Setopt(curl.OPT_URL, posturl)
-
- easy.Setopt(curl.OPT_PORT, 80)
- easy.Setopt(curl.OPT_VERBOSE, true)
-
- // save cookie and load cookie
- easy.Setopt(curl.OPT_COOKIEFILE, "./cookie.jar")
- easy.Setopt(curl.OPT_COOKIEJAR, "./cookie.jar")
-
- // disable HTTP/1.1 Expect: 100-continue
- easy.Setopt(curl.OPT_HTTPHEADER, []string{"Expect:"})
-
- form := curl.NewForm()
- form.Add("albumid", "452618633") // your album id
- form.AddFile("theFile", "./test.jpg")
- form.Add("description", "我就尝试下这段代码靠谱不。。截图下看看")
- form.Add("post", "上传照片")
-
- easy.Setopt(curl.OPT_HTTPPOST, form)
-
- // print upload progress
- easy.Setopt(curl.OPT_NOPROGRESS, false)
- easy.Setopt(curl.OPT_PROGRESSFUNCTION, func(dltotal, dlnow, ultotal, ulnow float64, _ interface{}) bool {
- fmt.Printf("Download %3.2f%%, Uploading %3.2f%%\r", dlnow/dltotal*100, ulnow/ultotal*100)
- return true
- })
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-
- time.Sleep(1000000000) // wait gorotine
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sendrecv.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sendrecv.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sendrecv.go
deleted file mode 100644
index 841825c..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sendrecv.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package main
-
-import (
- "fmt"
- curl "github.com/andelf/go-curl"
- "time"
-)
-
-const POST_DATA = "a_test_data_only"
-
-var sent = false
-
-func main() {
- // init the curl session
-
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- easy.Setopt(curl.OPT_URL, "http://www.renren.com")
-
- easy.Setopt(curl.OPT_PORT, 80)
- easy.Setopt(curl.OPT_VERBOSE, true)
- easy.Setopt(curl.OPT_CONNECT_ONLY, true)
-
- easy.Setopt(curl.OPT_WRITEFUNCTION, nil)
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-
- easy.Send([]byte("HEAD / HTTP/1.0\r\nHost: www.renren.com\r\n\r\n"))
-
- buf := make([]byte, 1000)
- time.Sleep(1000000000) // wait gorotine
- num, err := easy.Recv(buf)
- if err != nil {
- println("ERROR:", err.Error())
- }
- println("recv num = ", num)
- // NOTE: must use buf[:num]
- println(string(buf[:num]))
-
- fmt.Printf("got:\n%#v\n", string(buf[:num]))
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sepheaders.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sepheaders.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sepheaders.go
deleted file mode 100644
index b7603e3..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/sepheaders.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package main
-
-import (
- curl "github.com/andelf/go-curl"
- "os"
-)
-
-const (
- headerfilename = "head.out"
- bodyfilename = "body.out"
-)
-
-func write_data(ptr []byte, userdata interface{}) bool {
- //println("DEBUG(write_data): ", userdata)
- //println("DEBUG", userdata.(interface{}))
- fp := userdata.(*os.File)
- if _, err := fp.Write(ptr); err == nil {
- return true
- }
- return false
-}
-
-func main() {
- curl.GlobalInit(curl.GLOBAL_ALL)
-
- // init the curl session
- easy := curl.EasyInit()
- defer easy.Cleanup()
-
- // set URL to get
- easy.Setopt(curl.OPT_URL, "http://cn.bing.com/")
-
- // no progress meter
- easy.Setopt(curl.OPT_NOPROGRESS, true)
-
- easy.Setopt(curl.OPT_WRITEFUNCTION, write_data)
-
- // write file
- fp, _ := os.OpenFile(bodyfilename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0777)
- defer fp.Close()
- easy.Setopt(curl.OPT_WRITEDATA, fp)
-
- // easy.Setopt(curl.OPT_WRITEHEADER, 0)
-
- if err := easy.Perform(); err != nil {
- println("ERROR: ", err.Error())
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go
deleted file mode 100644
index 8261ec6..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/examples/simple.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package main
-
-import (
- curl "github.com/andelf/go-curl"
-)
-
-func main() {
- easy := curl.EasyInit()
- defer easy.Cleanup()
- if easy != nil {
- easy.Setopt(curl.OPT_URL, "http://www.google.com/")
- easy.Perform()
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go
deleted file mode 100644
index 8976233..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging.go
+++ /dev/null
@@ -1,56 +0,0 @@
-package curl
-
-import (
- "log"
-)
-
-const (
- _DEBUG = 10 * (iota + 1)
- _INFO
- _WARN
- _ERROR
-)
-
-const _DEFAULT_LOG_LEVEL = _WARN
-
-var log_level = _DEFAULT_LOG_LEVEL
-
-// SetLogLevel changes the log level which determines the granularity of the
-// messages that are logged. Available log levels are: "DEBUG", "INFO",
-// "WARN", "ERROR" and "DEFAULT_LOG_LEVEL".
-func SetLogLevel(levelName string) {
- switch levelName {
- case "DEBUG":
- log_level = _DEBUG
- case "INFO":
- log_level = _INFO
- case "WARN":
- log_level = _WARN
- case "ERROR":
- log_level = _ERROR
- case "DEFAULT_LOG_LEVEL":
- log_level = _DEFAULT_LOG_LEVEL
- }
-}
-
-func logf(limitLevel int, format string, args ...interface{}) {
- if log_level <= limitLevel {
- log.Printf(format, args...)
- }
-}
-
-func debugf(format string, args ...interface{}) {
- logf(_DEBUG, format, args...)
-}
-
-func infof(format string, args ...interface{}) {
- logf(_INFO, format, args...)
-}
-
-func warnf(format string, args ...interface{}) {
- logf(_WARN, format, args...)
-}
-
-func errorf(format string, args ...interface{}) {
- logf(_ERROR, format, args...)
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go
deleted file mode 100644
index 387705a..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/logging_test.go
+++ /dev/null
@@ -1,64 +0,0 @@
-
-package curl
-
-import (
- "testing"
- "bytes"
- "log"
- "os"
- "fmt"
- "regexp"
-)
-
-func TestDefaultLogLevel(t *testing.T) {
- if log_level != _DEFAULT_LOG_LEVEL {t.Error("Test failed, expected DEFAULT_LOG_LEVEL level.")}
-}
-
-func TestSetLogLevel(t *testing.T) {
- SetLogLevel("DEBUG")
- defer SetLogLevel("DEFAULT_LOG_LEVEL")
- if log_level != _DEBUG {t.Error("Test failed, expected DEBUG level.")}
- SetLogLevel("INFO")
- if log_level != _INFO {t.Error("Test failed, expected INFO level.")}
- SetLogLevel("WARN")
- if log_level != _WARN {t.Error("Test failed, expected WARN level.")}
- SetLogLevel("ERROR")
- if log_level != _ERROR {t.Error("Test failed, expected ERROR level.")}
-}
-
-var (
- testFormat = "test format %s"
- testArgument = "test string 1"
- expectedRegexp = regexp.MustCompile(".*" + fmt.Sprintf(testFormat, testArgument) + "\n$")
-)
-
-
-func TestLogf(t *testing.T) {
- buf := new(bytes.Buffer)
- log.SetOutput(buf)
- defer log.SetOutput(os.Stderr)
- SetLogLevel("DEBUG")
- defer SetLogLevel("DEFAULT_LOG_LEVEL")
-
- logf(_DEBUG, testFormat, testArgument)
- line := buf.String()
- matched := expectedRegexp.MatchString(line)
- if !matched {
- t.Errorf("log output should match %q and is %q.", expectedRegexp, line)
- }
-}
-
-func TestLogfUsesLogLevel(t *testing.T) {
- buf := new(bytes.Buffer)
- log.SetOutput(buf)
- defer log.SetOutput(os.Stderr)
- SetLogLevel("WARN")
- defer SetLogLevel("DEFAULT_LOG_LEVEL")
-
- logf(_DEBUG, testFormat, testArgument)
- line := buf.String()
- expectedLine := ""
- if line != expectedLine {
- t.Errorf("log output should match %q and is %q.", expectedLine, line)
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py
deleted file mode 100644
index 08047e5..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/codegen.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env python2
-# -*- coding: utf-8 -*-
-
-import re
-
-
-
-opts = []
-codes = []
-infos = []
-pattern = re.compile(r'CINIT\((.*?),\s+(LONG|OBJECTPOINT|FUNCTIONPOINT|OFF_T),\s+(\d+)\)')
-pattern2 = re.compile('^\s+(CURLE_[A-Z_0-9]+),')
-pattern3 = re.compile('^\s+(CURLINFO_[A-Z_0-9]+)\s+=')
-for line in open("./curl/include/curl/curl.h"):
- match = pattern.findall(line)
- if match:
- opts.append(match[0][0])
- if line.startswith('#define CURLOPT_'):
- o = line.split()
- opts.append(o[1][8:]) # strip :(
-
- match = pattern2.findall(line)
- if match:
- codes.append(match[0])
-
- if line.startswith('#define CURLE_'):
- c = line.split()
- codes.append(c[1])
-
- match = pattern3.findall(line)
- if match:
- infos.append(match[0])
-
- if line.startswith('#define CURLINFO_'):
- i = line.split()
- if '0x' not in i[2]: # :(
- infos.append(i[1])
-
-
-template = """
-// generated by codegen.py
-
-package curl
-/*
-#include <curl/curl.h>
-#include "compat.h"
-*/
-import "C"
-
-// CURLcode
-const (
-{code_part}
-)
-
-// easy.Setopt(flag, ...)
-const (
-{opt_part}
-)
-
-// easy.Getinfo(flag)
-const (
-{info_part}
-)
-
-// generated ends
-"""
-
-code_part = []
-for c in codes:
- code_part.append("\t{:<25} = C.{}".format(c[4:], c))
-
-code_part = '\n'.join(code_part)
-
-opt_part = []
-for o in opts:
- opt_part.append("\tOPT_{0:<25} = C.CURLOPT_{0}".format(o))
-
-opt_part = '\n'.join(opt_part)
-
-info_part = []
-for i in infos:
- info_part.append("\t{:<25} = C.{}".format(i[4:], i))
-
-info_part = '\n'.join(info_part)
-
-
-with open('./const_gen.go', 'w') as fp:
- fp.write(template.format(**locals()))
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py
deleted file mode 100644
index e7f2860..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/misc/compatgen.py
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-import re
-import os
-
-def version_symbol(ver):
- os.system("cd ./curl && git checkout {}".format(ver))
- opts = []
- codes = []
- infos = []
- vers = []
- pattern = re.compile(r'CINIT\((.*?), (LONG|OBJECTPOINT|FUNCTIONPOINT|OFF_T), (\d+)\)')
- pattern2 = re.compile('^\s+(CURLE_[A-Z_0-9]+),')
- pattern3 = re.compile('^\s+(CURLINFO_[A-Z_0-9]+)\s+=')
- for line in open("./curl/include/curl/curl.h"):
- match = pattern.findall(line)
- if match:
- opts.append("CURLOPT_" + match[0][0])
- if line.startswith('#define CURLOPT_'):
- o = line.split()
- opts.append(o[1])
-
- match = pattern2.findall(line)
- if match:
- codes.append(match[0])
-
- if line.startswith('#define CURLE_'):
- c = line.split()
- codes.append(c[1])
-
- match = pattern3.findall(line)
- if match:
- infos.append(match[0])
-
- if line.startswith('#define CURLINFO_'):
- i = line.split()
- if '0x' not in i[2]: # :(
- infos.append(i[1])
-
- if line.startswith('#define CURL_VERSION_'):
- i = line.split()
- vers.append(i[1])
-
- return opts, codes, infos, vers
-
-
-versions = """
-curl-7_10_1
-curl-7_10_2
-curl-7_10_3
-curl-7_10_4
-curl-7_10_5
-curl-7_10_6
-curl-7_10_7
-curl-7_10_8
-curl-7_11_0
-curl-7_11_1
-curl-7_11_2
-curl-7_12_0
-curl-7_12_1
-curl-7_12_2
-curl-7_12_3
-curl-7_13_0
-curl-7_13_1
-curl-7_13_2
-curl-7_14_0
-curl-7_14_1
-curl-7_15_0
-curl-7_15_1
-curl-7_15_2
-curl-7_15_3
-curl-7_15_4
-curl-7_15_5
-curl-7_16_0
-curl-7_16_1
-curl-7_16_2
-curl-7_16_3
-curl-7_16_4
-curl-7_17_0
-curl-7_17_1
-curl-7_18_0
-curl-7_18_1
-curl-7_18_2
-curl-7_19_0
-curl-7_19_1
-curl-7_19_2
-curl-7_19_3
-curl-7_19_4
-curl-7_19_5
-curl-7_19_6
-curl-7_19_7
-curl-7_20_0
-curl-7_20_1
-curl-7_21_0
-curl-7_21_1
-curl-7_21_2
-curl-7_21_3
-curl-7_21_4
-curl-7_21_5
-curl-7_21_6
-curl-7_21_7
-curl-7_22_0
-curl-7_23_0
-curl-7_23_1
-curl-7_24_0
-curl-7_25_0
-curl-7_26_0
-curl-7_27_0
-curl-7_28_0
-curl-7_28_1
-curl-7_29_0
-curl-7_30_0
-curl-7_31_0
-curl-7_32_0
-curl-7_33_0
-curl-7_34_0
-curl-7_35_0
-curl-7_36_0""".split()[::-1]
-
-last = version_symbol("master")
-
-template = """
-/* generated by compatgen.py */
-#include<curl/curl.h>
-
-
-"""
-
-result = [template]
-result_tail = ["/* generated ends */\n"]
-if __name__ == '__main__':
- for ver in versions:
- minor, patch = map(int, ver.split("_")[-2:])
-
- opts, codes, infos, vers = curr = version_symbol(ver)
-
- for o in last[0]:
- if o not in opts:
- result.append("#define {} 0".format(o)) # 0 for nil option
- for c in last[1]:
- if c not in codes:
- result.append("#define {} -1".format(c)) # -1 for error
- for i in last[2]:
- if i not in infos:
- result.append("#define {} 0".format(i)) # 0 for nil
- for v in last[3]:
- if v not in vers:
- result.append("#define {} 0".format(v)) # 0 for nil
-
- result.append("#if (LIBCURL_VERSION_MINOR == {} && LIBCURL_VERSION_PATCH < {}) || LIBCURL_VERSION_MINOR < {} ".format(minor, patch, minor))
-
- result_tail.insert(0, "#endif /* 7.{}.{} */".format(minor, patch))
-
- last = curr
-
-result.append("#error your version is TOOOOOOOO low")
-
-result.extend(result_tail)
-
-with open("./compat.h", 'w') as fp:
- fp.write('\n'.join(result))
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go
deleted file mode 100644
index 814fd6e..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/multi.go
+++ /dev/null
@@ -1,154 +0,0 @@
-package curl
-
-/*
-#include <stdlib.h>
-#include <curl/curl.h>
-
-static CURLMcode curl_multi_setopt_long(CURLM *handle, CURLMoption option, long parameter) {
- return curl_multi_setopt(handle, option, parameter);
-}
-static CURLMcode curl_multi_setopt_pointer(CURLM *handle, CURLMoption option, void *parameter) {
- return curl_multi_setopt(handle, option, parameter);
-}
-static CURLMcode curl_multi_fdset_pointer(CURLM *handle,
- void *read_fd_set,
- void *write_fd_set,
- void *exc_fd_set,
- int *max_fd)
-{
- return curl_multi_fdset(handle, read_fd_set, write_fd_set, exc_fd_set, max_fd);
-}
-static CURLMsg *curl_multi_info_read_pointer(CURLM *handle, int *msgs_in_queue)
-{
- return curl_multi_info_read(handle, msgs_in_queue);
-}
-*/
-import "C"
-
-import (
- "unsafe"
- "syscall"
-)
-
-type CurlMultiError C.CURLMcode
-type CurlMultiMsg C.CURLMSG
-
-func (e CurlMultiError) Error() string {
- // ret is const char*, no need to free
- ret := C.curl_multi_strerror(C.CURLMcode(e))
- return C.GoString(ret)
-}
-
-func newCurlMultiError(errno C.CURLMcode) error {
- // cannot use C.CURLM_OK here, cause multi.h use a undefined emum num
- if errno == 0 { // if nothing wrong
- return nil
- }
- return CurlMultiError(errno)
-}
-
-func newCURLMessage(message *C.CURLMsg) (msg *CURLMessage){
- if message == nil {
- return nil
- }
- msg = new(CURLMessage)
- msg.Msg = CurlMultiMsg(message.msg)
- msg.Easy_handle = &CURL{handle: message.easy_handle}
- msg.Data = message.data
- return msg
-}
-
-type CURLM struct {
- handle unsafe.Pointer
-}
-
-type CURLMessage struct {
- Msg CurlMultiMsg
- Easy_handle *CURL
- Data [8]byte
-}
-
-// curl_multi_init - create a multi handle
-func MultiInit() *CURLM {
- p := C.curl_multi_init()
- return &CURLM{p}
-}
-
-// curl_multi_cleanup - close down a multi session
-func (mcurl *CURLM) Cleanup() error {
- p := mcurl.handle
- return newCurlMultiError(C.curl_multi_cleanup(p))
-}
-
-// curl_multi_perform - reads/writes available data from each easy handle
-func (mcurl *CURLM) Perform() (int, error) {
- p := mcurl.handle
- running_handles := C.int(-1)
- err := newCurlMultiError(C.curl_multi_perform(p, &running_handles))
- return int(running_handles), err
-}
-
-// curl_multi_add_handle - add an easy handle to a multi session
-func (mcurl *CURLM) AddHandle(easy *CURL) error {
- mp := mcurl.handle
- easy_handle := easy.handle
- return newCurlMultiError(C.curl_multi_add_handle(mp, easy_handle))
-}
-
-// curl_multi_remove_handle - remove an easy handle from a multi session
-func (mcurl *CURLM) RemoveHandle(easy *CURL) error {
- mp := mcurl.handle
- easy_handle := easy.handle
- return newCurlMultiError(C.curl_multi_remove_handle(mp, easy_handle))
-}
-
-func (mcurl *CURLM) Timeout() (int, error) {
- p := mcurl.handle
- timeout := C.long(-1)
- err := newCurlMultiError(C.curl_multi_timeout(p, &timeout))
- return int(timeout), err
-}
-
-func (mcurl *CURLM) Setopt(opt int, param interface{}) error {
- p := mcurl.handle
- if param == nil {
- return newCurlMultiError(C.curl_multi_setopt_pointer(p, C.CURLMoption(opt), nil))
- }
- switch {
- // currently cannot support these option
- // case MOPT_SOCKETFUNCTION, MOPT_SOCKETDATA, MOPT_TIMERFUNCTION, MOPT_TIMERDATA:
- // panic("not supported CURLM.Setopt opt")
- case opt >= C.CURLOPTTYPE_LONG:
- val := C.long(0)
- switch t := param.(type) {
- case int:
- val := C.long(t)
- return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
- case bool:
- val = C.long(0)
- if t {
- val = C.long(1)
- }
- return newCurlMultiError(C.curl_multi_setopt_long(p, C.CURLMoption(opt), val))
- }
- }
- panic("not supported CURLM.Setopt opt or param")
- return nil
-}
-
-func (mcurl *CURLM) Fdset(rset, wset, eset *syscall.FdSet) (int, error) {
- p := mcurl.handle
- read := unsafe.Pointer(rset)
- write := unsafe.Pointer(wset)
- exc := unsafe.Pointer(eset)
- maxfd := C.int(-1)
- err := newCurlMultiError(C.curl_multi_fdset_pointer(p, read, write,
- exc, &maxfd))
- return int(maxfd), err
-}
-
-func (mcurl *CURLM) Info_read() (*CURLMessage, int) {
- p := mcurl.handle
- left := C.int(0)
- return newCURLMessage(C.curl_multi_info_read_pointer(p, &left)), int(left)
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/share.go
----------------------------------------------------------------------
diff --git a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/share.go b/newt/Godeps/_workspace/src/github.com/andelf/go-curl/share.go
deleted file mode 100644
index 8d1e16d..0000000
--- a/newt/Godeps/_workspace/src/github.com/andelf/go-curl/share.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package curl
-
-/*
-#include <curl/curl.h>
-
-static CURLSHcode curl_share_setopt_long(CURLSH *handle, CURLSHoption option, long parameter) {
- return curl_share_setopt(handle, option, parameter);
-}
-static CURLSHcode curl_share_setopt_pointer(CURLSH *handle, CURLSHoption option, void *parameter) {
- return curl_share_setopt(handle, option, parameter);
-}
-*/
-import "C"
-
-import "unsafe"
-
-// implement os.Error interface
-type CurlShareError C.CURLMcode
-
-func (e CurlShareError) Error() string {
- // ret is const char*, no need to free
- ret := C.curl_share_strerror(C.CURLSHcode(e))
- return C.GoString(ret)
-}
-
-func newCurlShareError(errno C.CURLSHcode) error {
- if errno == 0 { // if nothing wrong
- return nil
- }
- return CurlShareError(errno)
-}
-
-type CURLSH struct {
- handle unsafe.Pointer
-}
-
-func ShareInit() *CURLSH {
- p := C.curl_share_init()
- return &CURLSH{p}
-}
-
-func (shcurl *CURLSH) Cleanup() error {
- p := shcurl.handle
- return newCurlShareError(C.curl_share_cleanup(p))
-}
-
-func (shcurl *CURLSH) Setopt(opt int, param interface{}) error {
- p := shcurl.handle
- if param == nil {
- return newCurlShareError(C.curl_share_setopt_pointer(p, C.CURLSHoption(opt), nil))
- }
- switch opt {
- // case SHOPT_LOCKFUNC, SHOPT_UNLOCKFUNC, SHOPT_USERDATA:
- // panic("not supported")
- case SHOPT_SHARE, SHOPT_UNSHARE:
- if val, ok := param.(int); ok {
- return newCurlShareError(C.curl_share_setopt_long(p, C.CURLSHoption(opt), C.long(val)))
- }
- }
- panic("not supported CURLSH.Setopt opt or param")
- return nil
-}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/cli/pkglist.go
----------------------------------------------------------------------
diff --git a/newt/cli/pkglist.go b/newt/cli/pkglist.go
index 26bcacf..d24963f 100644
--- a/newt/cli/pkglist.go
+++ b/newt/cli/pkglist.go
@@ -46,9 +46,9 @@ type PkgList struct {
}
// Allocate a new package manager structure, and initialize it.
-func NewPkgList(nest *Repo) (*PkgList, error) {
+func NewPkgList(repo *Repo) (*PkgList, error) {
pkgList := &PkgList{
- Repo: nest,
+ Repo: repo,
}
err := pkgList.Init()
@@ -226,10 +226,15 @@ func (pkgList *PkgList) loadPkgDir(baseDir string, pkgPrefix string,
// Load all the packages in the repository into the package structure
func (pkgList *PkgList) loadPkgs() error {
- nest := pkgList.Repo
+ repo := pkgList.Repo
+
+ // XXX: Get additional package search directories from the repo
+ // configuration
+ // If empty, use the default set.
// Multiple package directories to be searched
searchDirs := []string{
+ "app/",
"compiler/",
"fs/",
"libs/",
@@ -243,8 +248,12 @@ func (pkgList *PkgList) loadPkgs() error {
"sys/",
}
+ if len(repo.AddlPackagePaths) > 0 {
+ searchDirs = append(searchDirs, repo.AddlPackagePaths...)
+ }
+
for _, pkgDir := range searchDirs {
- pkgBaseDir := nest.BasePath + "/" + pkgDir
+ pkgBaseDir := repo.BasePath + "/" + pkgDir
if NodeNotExist(pkgBaseDir) {
continue
@@ -943,20 +952,20 @@ func (pkgList *PkgList) InstallPkg(pkgName string, branch string,
log.Printf("[VERBOSE] ", pkgName, " installed already")
return downloaded, nil
}
- nest := pkgList.Repo
+ repo := pkgList.Repo
for _, remoteRepo := range downloaded {
pkg, err = remoteRepo.ResolvePkgName(pkgName)
if err == nil {
log.Print("[VERBOSE] ", pkgName, " present in downloaded pkgList ",
remoteRepo.Name)
- err = remoteRepo.fetchPkg(pkgName, nest.BasePath)
+ err = remoteRepo.fetchPkg(pkgName, repo.BasePath)
if err != nil {
return downloaded, err
}
// update local pkgList
- err = pkgList.loadPkgDir(nest.BasePath, "", pkgName)
+ err = pkgList.loadPkgDir(repo.BasePath, "", pkgName)
if err != nil {
return downloaded, err
}
@@ -980,7 +989,7 @@ func (pkgList *PkgList) InstallPkg(pkgName string, branch string,
}
// Not in downloaded pkgLists
- pkgLists, err := nest.GetPkgLists()
+ pkgLists, err := repo.GetPkgLists()
if err != nil {
return downloaded, err
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0ccd406a/newt/cli/repo.go
----------------------------------------------------------------------
diff --git a/newt/cli/repo.go b/newt/cli/repo.go
index e66e0f3..6e57336 100644
--- a/newt/cli/repo.go
+++ b/newt/cli/repo.go
@@ -18,12 +18,13 @@ package cli
import (
"database/sql"
"fmt"
- _ "github.com/mattn/go-sqlite3"
"io/ioutil"
"log"
"os"
"path"
"path/filepath"
+
+ _ "github.com/mattn/go-sqlite3"
)
type Repo struct {
@@ -39,16 +40,18 @@ type Repo struct {
// Repo File
RepoFile string
- // Base path of the nest
+ // Base path of the repo
BasePath string
// Store of PkgLists
PkgLists map[string]*PkgList
+ AddlPackagePaths []string
+
// Configuration
Config map[string]map[string]string
- // The database handle for the nest configuration database
+ // The database handle for the repo configuration database
db *sql.DB
}
@@ -76,14 +79,14 @@ func NewRepoWithDir(srcDir string) (*Repo, error) {
return n, nil
}
-func CreateRepo(nestName string, destDir string, tadpoleUrl string) error {
+func CreateRepo(repoName string, destDir string, tadpoleUrl string) error {
if tadpoleUrl == "" {
tadpoleUrl = "https://git-wip-us.apache.org/repos/asf/incubator-mynewt-tadpole.git"
}
if NodeExist(destDir) {
return NewNewtError(fmt.Sprintf("Directory %s already exists, "+
- " cannot create new newt nest", destDir))
+ " cannot create new newt repo", destDir))
}
dl, err := NewDownloader()
@@ -91,7 +94,7 @@ func CreateRepo(nestName string, destDir string, tadpoleUrl string) error {
return err
}
- StatusMessage(VERBOSITY_DEFAULT, "Downloading nest skeleton from %s...",
+ StatusMessage(VERBOSITY_DEFAULT, "Downloading repo skeleton from %s...",
tadpoleUrl)
if err := dl.DownloadFile(tadpoleUrl, "master", "/",
destDir); err != nil {
@@ -99,9 +102,9 @@ func CreateRepo(nestName string, destDir string, tadpoleUrl string) error {
}
StatusMessage(VERBOSITY_DEFAULT, OK_STRING)
- // Overwrite nest.yml
- contents := []byte(fmt.Sprintf("nest.name: %s\n", nestName))
- if err := ioutil.WriteFile(destDir+"/nest.yml",
+ // Overwrite repo.yml
+ contents := []byte(fmt.Sprintf("repo.name: %s\n", repoName))
+ if err := ioutil.WriteFile(destDir+"/repo.yml",
contents, 0644); err != nil {
return NewNewtError(err.Error())
}
@@ -112,7 +115,7 @@ func CreateRepo(nestName string, destDir string, tadpoleUrl string) error {
}
// Get a temporary directory to stick stuff in
-func (nest *Repo) GetTmpDir(dirName string, prefix string) (string, error) {
+func (repo *Repo) GetTmpDir(dirName string, prefix string) (string, error) {
tmpDir := dirName
if NodeNotExist(tmpDir) {
if err := os.MkdirAll(tmpDir, 0700); err != nil {
@@ -131,7 +134,7 @@ func (nest *Repo) GetTmpDir(dirName string, prefix string) (string, error) {
// Find the repo file. Searches the current directory, and then recurses
// parent directories until it finds a file named .repo.yml
// if no repo file found in the directory heirarchy, an error is returned
-func (nest *Repo) getRepoFile() (string, error) {
+func (repo *Repo) getRepoFile() (string, error) {
rFile := ""
curDir, err := os.Getwd()
@@ -140,10 +143,10 @@ func (nest *Repo) getRepoFile() (string, error) {
}
for {
- rFile = curDir + "/nest.yml"
- log.Printf("[DEBUG] Searching for nest file at %s", rFile)
+ rFile = curDir + "/repo.yml"
+ log.Printf("[DEBUG] Searching for repo file at %s", rFile)
if _, err := os.Stat(rFile); err == nil {
- log.Printf("[DEBUG] Found nest file at %s!", rFile)
+ log.Printf("[DEBUG] Found repo file at %s!", rFile)
break
}
@@ -159,7 +162,7 @@ func (nest *Repo) getRepoFile() (string, error) {
}
// Create the contents of the configuration database
-func (nest *Repo) createDb(db *sql.DB) error {
+func (repo *Repo) createDb(db *sql.DB) error {
query := `
CREATE TABLE IF NOT EXISTS newt_cfg (
cfg_name VARCHAR(255) NOT NULL,
@@ -177,14 +180,14 @@ func (nest *Repo) createDb(db *sql.DB) error {
// Initialize the configuration database specified by dbName. If the database
// doesn't exist, create it.
-func (nest *Repo) initDb(dbName string) error {
+func (repo *Repo) initDb(dbName string) error {
db, err := sql.Open("sqlite3", dbName)
if err != nil {
return err
}
- nest.db = db
+ repo.db = db
- err = nest.createDb(db)
+ err = repo.createDb(db)
if err != nil {
return err
}
@@ -211,12 +214,12 @@ func (nest *Repo) initDb(dbName string) error {
log.Printf("[DEBUG] Setting sect %s, key %s to val %s", cfgName.String,
cfgKey.String, cfgVal.String)
- _, ok := nest.Config[cfgName.String]
+ _, ok := repo.Config[cfgName.String]
if !ok {
- nest.Config[cfgName.String] = make(map[string]string)
+ repo.Config[cfgName.String] = make(map[string]string)
}
- nest.Config[cfgName.String][cfgKey.String] = cfgVal.String
+ repo.Config[cfgName.String][cfgKey.String] = cfgVal.String
}
return nil
@@ -224,8 +227,8 @@ func (nest *Repo) initDb(dbName string) error {
// Get a configuration variable in section sect, with key
// error is populated if variable doesn't exist
-func (nest *Repo) GetConfig(sect string, key string) (string, error) {
- sectMap, ok := nest.Config[sect]
+func (repo *Repo) GetConfig(sect string, key string) (string, error) {
+ sectMap, ok := repo.Config[sect]
if !ok {
return "", NewNewtError("No configuration section exists")
}
@@ -238,8 +241,8 @@ func (nest *Repo) GetConfig(sect string, key string) (string, error) {
return val, nil
}
-func (nest *Repo) GetConfigSect(sect string) (map[string]string, error) {
- sm, ok := nest.Config[sect]
+func (repo *Repo) GetConfigSect(sect string) (map[string]string, error) {
+ sm, ok := repo.Config[sect]
if !ok {
return nil, NewNewtError("No configuration section exists")
}
@@ -250,8 +253,8 @@ func (nest *Repo) GetConfigSect(sect string) (map[string]string, error) {
// Delete a configuration variable in section sect with key and val
// Returns an error if configuration variable cannot be deleted
// (most likely due to database error or key not existing)
-func (nest *Repo) DelConfig(sect string, key string) error {
- db := nest.db
+func (repo *Repo) DelConfig(sect string, key string) error {
+ db := repo.db
log.Printf("[DEBUG] Deleting sect %s, key %s", sect, key)
@@ -287,17 +290,17 @@ func (nest *Repo) DelConfig(sect string, key string) error {
// Set a configuration variable in section sect with key, and val
// Returns an error if configuration variable cannot be set
// (most likely not able to set it in database.)
-func (nest *Repo) SetConfig(sect string, key string, val string) error {
- _, ok := nest.Config[sect]
+func (repo *Repo) SetConfig(sect string, key string, val string) error {
+ _, ok := repo.Config[sect]
if !ok {
- nest.Config[sect] = make(map[string]string)
+ repo.Config[sect] = make(map[string]string)
}
- nest.Config[sect][key] = val
+ repo.Config[sect][key] = val
// Store config
log.Printf("[DEBUG] Storing value %s into key %s for section %s",
val, sect, key)
- db := nest.db
+ db := repo.db
tx, err := db.Begin()
if err != nil {
@@ -345,22 +348,24 @@ func (nest *Repo) SetConfig(sect string, key string, val string) error {
}
// Load the repo configuration file
-func (nest *Repo) loadConfig() error {
- v, err := ReadConfig(nest.BasePath, "nest")
+func (repo *Repo) loadConfig() error {
+ v, err := ReadConfig(repo.BasePath, "repo")
if err != nil {
return NewNewtError(err.Error())
}
- nest.Name = v.GetString("nest.name")
- if nest.Name == "" {
- return NewNewtError("Repo file must specify nest name")
+ repo.Name = v.GetString("repo.name")
+ if repo.Name == "" {
+ return NewNewtError("Repo file must specify repo name")
}
+ repo.AddlPackagePaths = v.GetStringSlice("repo.additional_package_paths")
+
return nil
}
-func (nest *Repo) LoadPkgLists() error {
- files, err := ioutil.ReadDir(nest.PkgListPath)
+func (repo *Repo) LoadPkgLists() error {
+ files, err := ioutil.ReadDir(repo.PkgListPath)
if err != nil {
return err
}
@@ -369,7 +374,7 @@ func (nest *Repo) LoadPkgLists() error {
if filepath.Ext(file) == ".yml" {
name := file[:len(filepath.Base(file))-len(".yml")]
log.Printf("[DEBUG] Loading PkgList %s", name)
- pkgList, err := NewPkgList(nest)
+ pkgList, err := NewPkgList(repo)
if err != nil {
return err
}
@@ -381,28 +386,28 @@ func (nest *Repo) LoadPkgLists() error {
return nil
}
-func (nest *Repo) InitPath(nestPath string) error {
+func (repo *Repo) InitPath(repoPath string) error {
cwd, err := os.Getwd()
if err != nil {
return NewNewtError(err.Error())
}
- if err = os.Chdir(nestPath); err != nil {
+ if err = os.Chdir(repoPath); err != nil {
return NewNewtError(err.Error())
}
log.Printf("[DEBUG] Searching for repository, starting in directory %s", cwd)
- if nest.RepoFile, err = nest.getRepoFile(); err != nil {
+ if repo.RepoFile, err = repo.getRepoFile(); err != nil {
return err
}
log.Printf("[DEBUG] Repo file found, directory %s, loading configuration...",
- nest.RepoFile)
+ repo.RepoFile)
- nest.BasePath = filepath.ToSlash(path.Dir(nest.RepoFile))
+ repo.BasePath = filepath.ToSlash(path.Dir(repo.RepoFile))
- if err = nest.loadConfig(); err != nil {
+ if err = repo.loadConfig(); err != nil {
return err
}
@@ -414,54 +419,54 @@ func (nest *Repo) InitPath(nestPath string) error {
// Initialze the repository
// returns a NewtError on failure, and nil on success
-func (nest *Repo) Init() error {
+func (repo *Repo) Init() error {
var err error
cwd, err := os.Getwd()
if err != nil {
return NewNewtError(err.Error())
}
- if err := nest.InitPath(cwd); err != nil {
+ if err := repo.InitPath(cwd); err != nil {
return err
}
- log.Printf("[DEBUG] Configuration loaded! Initializing .nest database")
+ log.Printf("[DEBUG] Configuration loaded! Initializing .repo database")
// Create Repo store directory
- nest.StorePath = nest.BasePath + "/.nest/"
- if NodeNotExist(nest.StorePath) {
- if err := os.MkdirAll(nest.StorePath, 0755); err != nil {
+ repo.StorePath = repo.BasePath + "/.repo/"
+ if NodeNotExist(repo.StorePath) {
+ if err := os.MkdirAll(repo.StorePath, 0755); err != nil {
return NewNewtError(err.Error())
}
}
// Create Repo configuration database
- nest.Config = make(map[string]map[string]string)
+ repo.Config = make(map[string]map[string]string)
- dbName := nest.StorePath + "/nest.db"
- if err := nest.initDb(dbName); err != nil {
+ dbName := repo.StorePath + "/repo.db"
+ if err := repo.initDb(dbName); err != nil {
return err
}
log.Printf("[DEBUG] Database initialized.")
// Load PkgLists for the current Repo
- nest.PkgListPath = nest.StorePath + "/pkgLists/"
- if NodeNotExist(nest.PkgListPath) {
- if err := os.MkdirAll(nest.PkgListPath, 0755); err != nil {
+ repo.PkgListPath = repo.StorePath + "/pkgLists/"
+ if NodeNotExist(repo.PkgListPath) {
+ if err := os.MkdirAll(repo.PkgListPath, 0755); err != nil {
return NewNewtError(err.Error())
}
}
- nest.PkgLists = map[string]*PkgList{}
+ repo.PkgLists = map[string]*PkgList{}
- if err := nest.LoadPkgLists(); err != nil {
+ if err := repo.LoadPkgLists(); err != nil {
return err
}
return nil
}
-func (nest *Repo) GetPkgLists() (map[string]*PkgList, error) {
- return nest.PkgLists, nil
+func (repo *Repo) GetPkgLists() (map[string]*PkgList, error) {
+ return repo.PkgLists, nil
}