@@ -102,12 +102,13 @@ func downloadFile(filename, url string) error {
102
102
103
103
// upstream describes the upstream repo we are about to package.
104
104
type upstream struct {
105
- tarPath string // path to the generated orig tarball tempfile
106
- version string // Debian package upstream version number, e.g. 0.0~git20180204.1d24609
107
- firstMain string // import path of the first main package within repo, if any
108
- vendorDirs []string // all vendor sub directories, relative to the repo directory
109
- repoDeps []string // the repository paths of all dependencies (e.g. github.com/zyedidia/glob)
110
- hasGodeps bool // whether the Godeps/_workspace directory exists
105
+ tarPath string // path to the downloaded or generated orig tarball tempfile
106
+ compression string // compression method, either "gz" or "xz"
107
+ version string // Debian package upstream version number, e.g. 0.0~git20180204.1d24609
108
+ firstMain string // import path of the first main package within repo, if any
109
+ vendorDirs []string // all vendor sub directories, relative to the repo directory
110
+ repoDeps []string // the repository paths of all dependencies (e.g. github.com/zyedidia/glob)
111
+ hasGodeps bool // whether the Godeps/_workspace directory exists
111
112
}
112
113
113
114
func (u * upstream ) get (gopath , repo , rev string ) error {
@@ -126,6 +127,36 @@ func (u *upstream) get(gopath, repo, rev string) error {
126
127
return rr .VCS .Create (dir , rr .Repo )
127
128
}
128
129
130
+ func (u * upstream ) tarballFromHoster (repo string ) error {
131
+ var url string
132
+ parts := strings .Split (repo , "/" )
133
+ if len (parts ) < 3 {
134
+ return fmt .Errorf ("Unsupported hoster" )
135
+ }
136
+ host , owner , project := parts [0 ], parts [1 ], parts [2 ]
137
+
138
+ switch host {
139
+ case "github.com" :
140
+ url = fmt .Sprintf ("https://%s/%s/%s/archive/v%s.tar.%s" ,
141
+ host , owner , project , u .version , u .compression )
142
+ case "gitlab.com" :
143
+ url = fmt .Sprintf ("https://%s/%s/%s/-/archive/v%s/%s-%s.tar.%s" ,
144
+ host , owner , project , u .version , project , u .version , u .compression )
145
+ default :
146
+ return fmt .Errorf ("Unsupported hoster" )
147
+ }
148
+
149
+ done := make (chan struct {})
150
+ go progressSize ("Download" , u .tarPath , done )
151
+
152
+ log .Printf ("Downloading %s" , url )
153
+ err := downloadFile (u .tarPath , url )
154
+
155
+ close (done )
156
+
157
+ return err
158
+ }
159
+
129
160
func (u * upstream ) tar (gopath , repo string ) error {
130
161
f , err := ioutil .TempFile ("" , "dh-make-golang" )
131
162
if err != nil {
0 commit comments