Browse Source

command install add feature: auto-install all packages after downloaded

pull/103/head
Unknown 12 years ago
parent
commit
bcbbd3117e
  1. 4
      README.md
  2. 2
      conf/gpm.toml
  3. 6
      doc/bitbucket.go
  4. 8
      doc/github.go
  5. 6
      doc/google.go
  6. 6
      doc/launchpad.go
  7. 7
      doc/vcs.go
  8. 17
      doc/walker.go
  9. 13
      install.go

4
README.md

@ -9,7 +9,6 @@ gpm(Go Package Manager) is a Go package manage tool for search, install, update
- Command `install` add support for downloading code from git.oschina.net, gitcafe.com, *.codeplex.com;
- Add support for downloading tarballs from user sources.
- Command `install` installs all packages after downloaded.
- After downloaded all packages in bundles or snapshots, need to check if all dependencies have been downloaded as well.
- Develop user source API server template application to support user sources in bundles.
- Add bundle and snapshot parser code for downloading by bundle or snapshot id.
@ -21,4 +20,5 @@ gpm(Go Package Manager) is a Go package manage tool for search, install, update
- Add feature for downloading through version control tools, and use `checkout` to switch to specific revision; this feature only be enabled when users use bundle or snapshot id.
- Add support for downloading by tag for packages in github.com, bitbucket.org.
- Get author commit time and save in node.
- Save node information after downloaded, and check for next time, reduce download times.
- Save node information after downloaded, and check for next time, reduce download times.
- Collect download and installation results and report to users in the end.

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.0.4 Build 0520"
version = "v0.0.5 Build 0521"
username = ""
password = ""
user_language = "en-US"

6
doc/bitbucket.go

@ -75,7 +75,8 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH
return nil, nil, err
}
installPath := installGOPATH + "/src/" + match["importPath"]
projectPath := expand("bitbucket.org/{owner}/{repo}", match)
installPath := installGOPATH + "/src/" + projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
@ -151,10 +152,11 @@ func GetBitbucketDoc(client *http.Client, match map[string]string, installGOPATH
// Check if need to check imports.
if isCheckImport {
for _, d := range dirs {
imports, err = checkImports(d+"/", match["importPath"])
importPkgs, err := checkImports(d+"/", match["importPath"])
if err != nil {
return nil, nil, err
}
imports = append(imports, importPkgs...)
}
}

8
doc/github.go

@ -87,7 +87,8 @@ func GetGithubDoc(client *http.Client, match map[string]string, installGOPATH, c
}
shaName := expand("{repo}-{sha}", match)
installPath := installGOPATH + "/src/" + match["importPath"]
projectPath := expand("github.com/{owner}/{repo}", match)
installPath := installGOPATH + "/src/" + projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
@ -95,6 +96,8 @@ func GetGithubDoc(client *http.Client, match map[string]string, installGOPATH, c
os.MkdirAll(installPath+"/", os.ModePerm)
dirs := make([]string, 0, 5)
// Need to add root path because we cannot get from tarball.
dirs = append(dirs, installPath+"/")
for _, f := range r.File {
absPath := strings.Replace(f.FileInfo().Name(), shaName, installPath, 1)
@ -142,10 +145,11 @@ func GetGithubDoc(client *http.Client, match map[string]string, installGOPATH, c
// Check if need to check imports.
if isCheckImport {
for _, d := range dirs {
imports, err = checkImports(d, match["importPath"])
importPkgs, err := checkImports(d, match["importPath"])
if err != nil {
return nil, nil, err
}
imports = append(imports, importPkgs...)
}
}

6
doc/google.go

@ -75,7 +75,8 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH, c
errors.New("doc.GetGoogleDoc(): Could not find revision for " + match["importPath"])
}
installPath := installGOPATH + "/src/" + match["importPath"]
projectPath := expand("code.google.com/p/{repo}{dot}{subrepo}{dir}", match)
installPath := installGOPATH + "/src/" + projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
@ -154,10 +155,11 @@ func GetGoogleDoc(client *http.Client, match map[string]string, installGOPATH, c
for _, d := range dirs {
if d.IsDir() && !(!cmdFlags["-e"] && strings.Contains(d.Name(), "example")) {
absPath := installPath + "/" + d.Name() + "/"
imports, err = checkImports(absPath, match["importPath"])
importPkgs, err := checkImports(absPath, match["importPath"])
if err != nil {
return nil, nil, err
}
imports = append(imports, importPkgs...)
}
}
}

6
doc/launchpad.go

@ -54,7 +54,8 @@ func GetLaunchpadDoc(client *http.Client, match map[string]string, installGOPATH
return nil, nil, err
}
installPath := installGOPATH + "/src/" + match["importPath"]
projectPath := expand("launchpad.net/{repo}", match)
installPath := installGOPATH + "/src/" + projectPath
// Remove old files.
os.RemoveAll(installPath + "/")
@ -130,10 +131,11 @@ func GetLaunchpadDoc(client *http.Client, match map[string]string, installGOPATH
// Check if need to check imports.
if isCheckImport {
for _, d := range dirs {
imports, err = checkImports(d+"/", match["importPath"])
importPkgs, err := checkImports(d+"/", match["importPath"])
if err != nil {
return nil, nil, err
}
imports = append(imports, importPkgs...)
}
}

7
doc/vcs.go

@ -178,7 +178,7 @@ func expand(template string, match map[string]string, subs ...string) string {
}
// checkImports checks package denpendencies.
func checkImports(absPath, importPath string) (imports []string, err error) {
func checkImports(absPath, importPath string) (importPkgs []string, err error) {
dir, err := os.Open(absPath)
if err != nil {
return nil, err
@ -218,12 +218,11 @@ func checkImports(absPath, importPath string) (imports []string, err error) {
// Check if has Go source files.
if len(files) > 0 {
w := &walker{ImportPath: importPath}
importPkgs, err := w.build(files)
importPkgs, err = w.build(files)
if err != nil {
return nil, err
}
imports = append(imports, importPkgs...)
}
return imports, nil
return importPkgs, err
}

17
doc/walker.go

@ -1,17 +1,8 @@
// Copyright 2011 Gary Burd
// Copyright 2013 Unknown
// Copyright 2012 Gary Burd
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
// Copyright (c) 2013 GPMGo Members. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package doc

13
install.go

@ -115,9 +115,17 @@ func runInstall(cmd *Command, args []string) {
commits := make([]string, len(args))
downloadPackages(args, commits)
if !cmdInstall.Flags["d"] && cmdInstall.Flags["-p"] {
if !cmdInstall.Flags["-d"] && cmdInstall.Flags["-p"] {
// Install packages all together.
fmt.Printf("Installing package: %s.\n")
var cmdArgs []string
cmdArgs = append(cmdArgs, "install")
cmdArgs = append(cmdArgs, "<blank>")
for k := range downloadCache {
fmt.Printf("Installing package: %s.\n", k)
cmdArgs[1] = k
executeGoCommand(cmdArgs)
}
}
fmt.Println("Well done.")
@ -189,7 +197,6 @@ func downloadPackage(path, commit string) (pkg *doc.Package, imports []string) {
return nil, nil
}
//fmt.Println(pkg)
return pkg, imports
}
}

Loading…
Cancel
Save