| OLD | NEW |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package venv | 5 package venv |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "archive/zip" | 8 "archive/zip" |
| 9 "crypto/sha256" | 9 "crypto/sha256" |
| 10 "encoding/hex" | 10 "encoding/hex" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 func (tl *testingLoader) Resolve(c context.Context, root string, packages []*vpy
thon.Spec_Package) error { | 133 func (tl *testingLoader) Resolve(c context.Context, root string, packages []*vpy
thon.Spec_Package) error { |
| 134 for _, pkg := range packages { | 134 for _, pkg := range packages { |
| 135 pkg.Version = "resolved" | 135 pkg.Version = "resolved" |
| 136 } | 136 } |
| 137 return nil | 137 return nil |
| 138 } | 138 } |
| 139 | 139 |
| 140 func (tl *testingLoader) Ensure(c context.Context, root string, packages []*vpyt
hon.Spec_Package) error { | 140 func (tl *testingLoader) Ensure(c context.Context, root string, packages []*vpyt
hon.Spec_Package) error { |
| 141 for _, pkg := range packages { | 141 for _, pkg := range packages { |
| 142 » » if err := tl.installPackage(pkg.Path, root); err != nil { | 142 » » if err := tl.installPackage(pkg.Name, root); err != nil { |
| 143 return err | 143 return err |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 return nil | 146 return nil |
| 147 } | 147 } |
| 148 | 148 |
| 149 func (tl *testingLoader) installPackage(name, root string) error { | 149 func (tl *testingLoader) installPackage(name, root string) error { |
| 150 switch name { | 150 switch name { |
| 151 case "foo/bar/virtualenv": | 151 case "foo/bar/virtualenv": |
| 152 return unzip(tl.virtualEnvZIP, root) | 152 return unzip(tl.virtualEnvZIP, root) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 187 } |
| 188 | 188 |
| 189 srcDir := filepath.Join(testDataDir, w.Distribution+".src") | 189 srcDir := filepath.Join(testDataDir, w.Distribution+".src") |
| 190 | 190 |
| 191 // Create a bootstrap wheel-generating VirtualEnv! | 191 // Create a bootstrap wheel-generating VirtualEnv! |
| 192 cfg := Config{ | 192 cfg := Config{ |
| 193 MaxHashLen: 1, // Only going to be 1 enviroment. | 193 MaxHashLen: 1, // Only going to be 1 enviroment. |
| 194 BaseDir: filepath.Join(outDir, ".env"), | 194 BaseDir: filepath.Join(outDir, ".env"), |
| 195 Python: py.Python, | 195 Python: py.Python, |
| 196 Package: vpython.Spec_Package{ | 196 Package: vpython.Spec_Package{ |
| 197 » » » Path: "foo/bar/virtualenv", | 197 » » » Name: "foo/bar/virtualenv", |
| 198 Version: "whatever", | 198 Version: "whatever", |
| 199 }, | 199 }, |
| 200 Loader: tl, | 200 Loader: tl, |
| 201 Spec: &vpython.Spec{}, | 201 Spec: &vpython.Spec{}, |
| 202 | 202 |
| 203 // Testing parameters for this bootstrap wheel-building environm
ent. | 203 // Testing parameters for this bootstrap wheel-building environm
ent. |
| 204 testPreserveInstallationCapability: true, | 204 testPreserveInstallationCapability: true, |
| 205 testLeaveReadWrite: true, | 205 testLeaveReadWrite: true, |
| 206 } | 206 } |
| 207 | 207 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 if _, err := io.Copy(dfd, sfd); err != nil { | 429 if _, err := io.Copy(dfd, sfd); err != nil { |
| 430 return errors.Annotate(err).Reason("failed to copy file").Err() | 430 return errors.Annotate(err).Reason("failed to copy file").Err() |
| 431 } | 431 } |
| 432 if fi != nil { | 432 if fi != nil { |
| 433 if err := os.Chmod(dst, fi.Mode()); err != nil { | 433 if err := os.Chmod(dst, fi.Mode()); err != nil { |
| 434 return errors.Annotate(err).Reason("failed to chmod").Er
r() | 434 return errors.Annotate(err).Reason("failed to chmod").Er
r() |
| 435 } | 435 } |
| 436 } | 436 } |
| 437 return nil | 437 return nil |
| 438 } | 438 } |
| OLD | NEW |