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 spec | 5 package spec |
6 | 6 |
7 import ( | 7 import ( |
8 "crypto/sha256" | 8 "crypto/sha256" |
9 "encoding/hex" | 9 "encoding/hex" |
10 "fmt" | 10 "fmt" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 pos++ | 63 pos++ |
64 } | 64 } |
65 spec.Wheel = spec.Wheel[:pos] | 65 spec.Wheel = spec.Wheel[:pos] |
66 | 66 |
67 sort.Sort(specPackageSlice(spec.Wheel)) | 67 sort.Sort(specPackageSlice(spec.Wheel)) |
68 | 68 |
69 // No duplicate packages. Since we're sorted, we can just check for no | 69 // No duplicate packages. Since we're sorted, we can just check for no |
70 // immediate repetitions. | 70 // immediate repetitions. |
71 for i, pkg := range spec.Wheel { | 71 for i, pkg := range spec.Wheel { |
72 if i > 0 && pkg.Name == spec.Wheel[i-1].Name { | 72 if i > 0 && pkg.Name == spec.Wheel[i-1].Name { |
73 » » » return errors.Reason("duplicate spec entries for package
%(path)q"). | 73 » » » return errors.Reason("duplicate spec entries for package
%q", pkg.Name).Err() |
74 » » » » D("name", pkg.Name). | |
75 » » » » Err() | |
76 } | 74 } |
77 } | 75 } |
78 | 76 |
79 return nil | 77 return nil |
80 } | 78 } |
81 | 79 |
82 // Hash hashes the contents of the supplied "spec" and "rt" and returns the | 80 // Hash hashes the contents of the supplied "spec" and "rt" and returns the |
83 // result as a hex-encoded string. | 81 // result as a hex-encoded string. |
84 // | 82 // |
85 // If not empty, the contents of extra are prefixed to hash string. This can | 83 // If not empty, the contents of extra are prefixed to hash string. This can |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 func (s pep425TagSlice) Len() int { return len(s) } | 127 func (s pep425TagSlice) Len() int { return len(s) } |
130 func (s pep425TagSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } | 128 func (s pep425TagSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } |
131 | 129 |
132 func (s pep425TagSlice) Less(i, j int) bool { | 130 func (s pep425TagSlice) Less(i, j int) bool { |
133 return sortby.Chain{ | 131 return sortby.Chain{ |
134 func(i, j int) bool { return s[i].Python < s[j].Python }, | 132 func(i, j int) bool { return s[i].Python < s[j].Python }, |
135 func(i, j int) bool { return s[i].Abi < s[j].Abi }, | 133 func(i, j int) bool { return s[i].Abi < s[j].Abi }, |
136 func(i, j int) bool { return s[i].Platform < s[j].Platform }, | 134 func(i, j int) bool { return s[i].Platform < s[j].Platform }, |
137 }.Use(i, j) | 135 }.Use(i, j) |
138 } | 136 } |
OLD | NEW |