Browse Source

v0.1.4 Build 0522

pull/103/head
Unknown 12 years ago
parent
commit
44b1e326b1
  1. 3
      .gitignore
  2. 4
      README.md
  3. 2
      conf/gpm.toml
  4. 16
      doc/bitbucket.go
  5. 1
      doc/github.go
  6. 21
      doc/google.go
  7. 15
      doc/launchpad.go
  8. 3
      install.go
  9. 58
      repo/bundles/test_bundle.json

3
.gitignore vendored

@ -22,5 +22,4 @@ _testmain.go
*.exe
gpm
data/
repo/
data/

4
README.md

@ -12,7 +12,7 @@ gpm(Go Package Manager) is a Go package manage tool for search, install, update
## Todo
- Command `build` add current path to GOPATH temporary.
- Command `remove` is for removing packages.
- Add gpm working principle design.
- Add support for downloading tarballs from user sources.
- After downloaded all packages in bundles or snapshots, need to check if all dependencies have been downloaded as well.
@ -26,7 +26,7 @@ gpm(Go Package Manager) is a Go package manage tool for search, install, update
- Command `check` is for checking and downloading all missing dependencies.
- Command `daemon` is for auto-compile web applications when debug it locally.
- Command `update` is for checking updates.
- Command `remove` is for removing packages.
- Command `search` is for searching packages.
- Add feature "struct generator".
- i18n support for Chinese.
- Add built-in application version in order to backup data when users update.

2
conf/gpm.toml

@ -1,7 +1,7 @@
# This is a configuration file for gpm with toml format.
title = "gpm(Go Package Manager)"
version = "v0.1.3 Build 0522"
version = "v0.1.4 Build 0522"
username = ""
password = ""
user_language = "en-US"

16
doc/bitbucket.go

@ -23,9 +23,8 @@ var (
// GetBitbucketDoc downloads tarball from bitbucket.org.
func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH string, node *Node, cmdFlags map[string]bool) ([]string, error) {
commit := node.Value
// Check version control.
if m := bitbucketEtagRe.FindStringSubmatch(commit); m != nil {
if m := bitbucketEtagRe.FindStringSubmatch(node.Value); m != nil {
match["vcs"] = m[1]
} else {
var repo struct {
@ -39,10 +38,10 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH
// bundle and snapshot will have commit 'B' and 'S',
// but does not need to download dependencies.
isCheckImport := len(commit) == 0
isCheckImport := len(node.Value) == 0
// Check if download with specific revision.
if isCheckImport || len(commit) == 1 {
if isCheckImport || len(node.Value) == 1 {
tags := make(map[string]string)
for _, nodeType := range []string{"branches", "tags"} {
var nodes map[string]struct {
@ -63,7 +62,7 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH
return nil, err
}
} else {
match["commit"] = commit
match["commit"] = node.Value
}
// We use .tar.gz here.
@ -78,6 +77,7 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH
projectPath := expand("bitbucket.org/{owner}/{repo}", match)
installPath := installGOPATH + "/src/" + projectPath
node.ImportPath = projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
@ -142,12 +142,6 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH
}
}
node.Value = commit
/* node := &Node{
ImportPath: projectPath,
Commit: commit,
}*/
var imports []string
// Check if need to check imports.

1
doc/github.go

@ -103,6 +103,7 @@ func GetGithubDoc(client *http.Client, match map[string]string, installGOPATH st
projectPath := expand("github.com/{owner}/{repo}", match)
installPath := installGOPATH + "/src/" + projectPath
node.ImportPath = projectPath
// Remove old files.
os.RemoveAll(installPath + "/")

21
doc/google.go

@ -50,9 +50,8 @@ func getGoogleVCS(client *http.Client, match map[string]string) error {
// GetGoogleDoc downloads raw files from code.google.com.
func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH string, node *Node, cmdFlags map[string]bool) ([]string, error) {
setupGoogleMatch(match)
commit := node.Value
// Check version control.
if m := googleEtagRe.FindStringSubmatch(commit); m != nil {
if m := googleEtagRe.FindStringSubmatch(node.Value); m != nil {
match["vcs"] = m[1]
} else if err := getGoogleVCS(client, match); err != nil {
return nil, err
@ -60,12 +59,15 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH st
// bundle and snapshot will have commit 'B' and 'S',
// but does not need to download dependencies.
isCheckImport := len(commit) == 0
isCheckImport := len(node.Value) == 0
if len(node.Value) == 1 {
node.Value = ""
}
rootPath := expand("http://{subrepo}{dot}{repo}.googlecode.com/{vcs}{dir}/", match)
// Scrape the repo browser to find the project revision and individual Go files.
p, err := httpGetBytes(client, rootPath+"?r="+commit, nil)
p, err := httpGetBytes(client, rootPath+"?r="+node.Value, nil)
if err != nil {
return nil, err
}
@ -78,6 +80,7 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH st
projectPath := expand("code.google.com/p/{repo}{dot}{subrepo}{dir}", match)
installPath := installGOPATH + "/src/" + projectPath
node.ImportPath = projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
@ -90,7 +93,7 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH st
fname := strings.Split(string(m[1]), "?")[0]
files = append(files, &source{
name: fname,
rawURL: expand("http://{subrepo}{dot}{repo}.googlecode.com/{vcs}{dir}/{0}", match, fname) + "?r=" + commit,
rawURL: expand("http://{subrepo}{dot}{repo}.googlecode.com/{vcs}{dir}/{0}", match, fname) + "?r=" + node.Value,
})
}
@ -128,17 +131,11 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH st
}
}
err = downloadFiles(client, match, rootPath, installPath+"/", commit, dirs)
err = downloadFiles(client, match, rootPath, installPath+"/", node.Value, dirs)
if err != nil {
return nil, err
}
node.Value = commit
/* node := &Node{
ImportPath: projectPath,
Commit: commit,
}*/
var imports []string
// Check if need to check imports.

15
doc/launchpad.go

@ -35,17 +35,17 @@ func GetLaunchpadDoc(client *http.Client, match map[string]string, installGOPATH
return nil, err
}
}
commit := node.Value
// bundle and snapshot will have commit 'B' and 'S',
// but does not need to download dependencies.
isCheckImport := len(commit) == 0
isCheckImport := len(node.Value) == 0
var downloadPath string
// Check if download with specific revision.
if isCheckImport || len(commit) == 1 {
if isCheckImport || len(node.Value) == 1 {
downloadPath = expand("https://bazaar.launchpad.net/+branch/{repo}/tarball", match)
} else {
downloadPath = expand("https://bazaar.launchpad.net/+branch/{repo}/tarball/"+commit, match)
downloadPath = expand("https://bazaar.launchpad.net/+branch/{repo}/tarball/"+node.Value, match)
}
// Scrape the repo browser to find the project revision and individual Go files.
@ -56,6 +56,7 @@ func GetLaunchpadDoc(client *http.Client, match map[string]string, installGOPATH
projectPath := expand("launchpad.net/{repo}", match)
installPath := installGOPATH + "/src/" + projectPath
node.ImportPath = projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
@ -120,12 +121,6 @@ func GetLaunchpadDoc(client *http.Client, match map[string]string, installGOPATH
}
}
node.Value = commit
/* node := &Node{
ImportPath: projectPath,
Commit: commit,
}*/
var imports []string
// Check if need to check imports.

3
install.go

@ -240,6 +240,9 @@ func downloadPackages(nodes []*doc.Node) {
// saveNode saves node into local nodes.
func saveNode(n *doc.Node) {
// Node dependencies list.
n.Deps = nil
// Check if this node exists.
for i, v := range localNodes {
if n.ImportPath == v.ImportPath {

58
repo/bundles/test_bundle.json

@ -0,0 +1,58 @@
{
"id": 0,
"user_id": 0,
"bundle_name": "bundle_test",
"comment": "just a test",
"timestamp": 0,
"nodes": [
{
"import_path": "github.com/astaxie/beego",
"type": "tag",
"value": "v0.6.0",
"deps":[
{
"import_path": "github.com/russross/blackfriday",
"type": "commit",
"value": "",
"deps": null
},
{
"import_path": "code.google.com/p/vitess/go/memcache",
"type": "commit",
"value": "",
"deps": null
},
{
"import_path": "github.com/garyburd/redigo/redis",
"type": "commit",
"value": "aa31b4b202d4ea44ca45b3c93d71575c02ba35dc",
"deps": null
},
{
"import_path": "github.com/go-sql-driver/mysql",
"type": "tag",
"value": "v1.0",
"deps": null
}
]
},
{
"import_path": "github.com/coocood/qbs",
"type": "branch",
"value": "master",
"deps": null
},
{
"import_path": "bitbucket.org/zombiezen/gopdf/pdf",
"type": "commit",
"value": "",
"deps": null
},
{
"import_path": "launchpad.net/goamz/aws",
"type": "commit",
"value": "",
"deps": null
}
]
}
Loading…
Cancel
Save