licensed 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/CONTRIBUTING.md +7 -4
- data/README.md +4 -0
- data/Rakefile +28 -2
- data/docker/Dockerfile.build-linux +11 -0
- data/docs/packaging.md +53 -0
- data/docs/sources/bundler.md +26 -3
- data/docs/sources/dep.md +1 -9
- data/lib/licensed/shell.rb +2 -2
- data/lib/licensed/source/bundler.rb +137 -16
- data/lib/licensed/source/dep.rb +1 -9
- data/lib/licensed/source/pip.rb +14 -6
- data/lib/licensed/version.rb +1 -1
- data/licensed.gemspec +4 -2
- data/script/build-rubyc-exe +58 -0
- data/script/package +20 -0
- data/script/packages/linux +51 -0
- data/script/packages/mac +35 -0
- data/script/source-setup/bundler +1 -1
- metadata +14 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1d1f0def7d120443e89895960f41bb7dd90a63f
|
4
|
+
data.tar.gz: 951687b4ab3804df152f6dbbbfd4ffd2db3e3c71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7ca6dc13ebb771ed191e36fde4ab7c75aaadd1ca2e406a925595f3ee98553f660a8d81c677a2d87c346c0bfb32b8693e07cf90f8c5b6e0a817f368326d5f262
|
7
|
+
data.tar.gz: '0197b0088dd379120614fb725efd41a58d3eed9744e32928220ecb431d63f8be5229888f1857e1ef2b5a3cbfc7810524b10b33c84c71a9990000c26f7f7bb912'
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## 1.2.0 - 2018-06-22
|
10
|
+
### Added
|
11
|
+
- Building and packaging distributable exes for licensed releases
|
12
|
+
- Can now configure which Gemfile groups are excluded from dependency enumeration
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
- Bundler is no longer always reported as a dependency
|
16
|
+
- Set the minimum required ruby version for licensed
|
17
|
+
|
9
18
|
## 1.1.0 - 2018-06-04
|
10
19
|
### Added
|
11
20
|
- Pip dependency source :tada:
|
@@ -36,4 +45,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
36
45
|
|
37
46
|
Initial release :tada:
|
38
47
|
|
39
|
-
[Unreleased]: https://github.com/github/licensed/compare/
|
48
|
+
[Unreleased]: https://github.com/github/licensed/compare/1.2.0...HEAD
|
data/CONTRIBUTING.md
CHANGED
@@ -40,8 +40,8 @@ Pull requests that include a new dependency source must also
|
|
40
40
|
If you are the current maintainer of this gem:
|
41
41
|
|
42
42
|
1. Create a branch for the release: git checkout -b cut-release-vxx.xx.xx
|
43
|
-
2. Make sure your local dependencies are up to date: script/bootstrap
|
44
|
-
3. Ensure that tests are green: bundle exec rake test
|
43
|
+
2. Make sure your local dependencies are up to date: `script/bootstrap`
|
44
|
+
3. Ensure that tests are green: `bundle exec rake test`
|
45
45
|
4. Bump gem version in lib/licensed/version.rb.
|
46
46
|
5. Update [`CHANGELOG.md`](CHANGELOG.md)
|
47
47
|
6. Make a PR to github/licensed.
|
@@ -51,8 +51,11 @@ If you are the current maintainer of this gem:
|
|
51
51
|
2. Install the new gem locally
|
52
52
|
3. Test behavior locally, branch deploy, whatever needs to happen
|
53
53
|
9. Merge github/licensed PR
|
54
|
-
10. Tag and push: git tag
|
55
|
-
11. Push to rubygems.org -- gem push licensed-x.xx.xx.gem
|
54
|
+
10. Tag and push: `git tag x.xx.xx; git push --tags`
|
55
|
+
11. Push to rubygems.org -- `gem push licensed-x.xx.xx.gem`
|
56
|
+
12. Build packages for new tag: `VERSION=x.xx.xx bundle exec rake package`
|
57
|
+
13. Create release for new tag at github/licensed.
|
58
|
+
14. Add built packages to new release
|
56
59
|
|
57
60
|
## Resources
|
58
61
|
|
data/README.md
CHANGED
@@ -118,6 +118,10 @@ if Licensed::Shell.tool_available?('bundle')
|
|
118
118
|
end
|
119
119
|
```
|
120
120
|
|
121
|
+
## Packaging
|
122
|
+
|
123
|
+
Licensed can be built into an exe and packaged for distribution to systems that don't have ruby already available. See the [packaging documentation](./docs/packaging.md) for details.
|
124
|
+
|
121
125
|
## Contributing
|
122
126
|
|
123
127
|
Bug reports and pull requests are welcome on GitHub at https://github.com/github/licensed. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org/) code of conduct. See [CONTRIBUTING](CONTRIBUTING.md) for more details.
|
data/Rakefile
CHANGED
@@ -47,7 +47,8 @@ namespace :test do
|
|
47
47
|
|
48
48
|
# use negative lookahead to exclude all source tests except
|
49
49
|
# the tests for `source`
|
50
|
-
t.test_files = FileList["test/**/*_test.rb"].exclude(/test\/source\/(?!#{source}).*?_test.rb
|
50
|
+
t.test_files = FileList["test/**/*_test.rb"].exclude(/test\/source\/(?!#{source}).*?_test.rb/,
|
51
|
+
"test/fixtures/**/*_test.rb")
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -55,9 +56,34 @@ end
|
|
55
56
|
Rake::TestTask.new(:test) do |t|
|
56
57
|
t.libs << "test"
|
57
58
|
t.libs << "lib"
|
58
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
59
|
+
t.test_files = FileList["test/**/*_test.rb"].exclude("test/fixtures/**/*_test.rb")
|
59
60
|
end
|
60
61
|
|
62
|
+
packages_search = File.expand_path("script/packages/*", __dir__)
|
63
|
+
platforms = Dir[packages_search].map { |f| File.basename(f, ".*") }
|
64
|
+
|
65
|
+
namespace :package do
|
66
|
+
platforms.each do |platform|
|
67
|
+
desc "Package licensed for #{platform}"
|
68
|
+
task platform.to_sym do
|
69
|
+
puts "Packaging licensed for #{platform}"
|
70
|
+
|
71
|
+
if Bundler.with_original_env { system("script/packages/#{platform}") }
|
72
|
+
# green
|
73
|
+
puts "\033[32mCompleted packaging for #{platform}.\e[0m"
|
74
|
+
else
|
75
|
+
# red
|
76
|
+
puts "\033[31mEncountered an error packaging for #{platform}.\e[0m"
|
77
|
+
end
|
78
|
+
|
79
|
+
puts
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "Package licensed for all platforms"
|
85
|
+
task package: platforms.map { |platform| "package:#{platform}" }
|
86
|
+
|
61
87
|
# add rubocop task
|
62
88
|
# -S adds styleguide urls to offense messages
|
63
89
|
RuboCop::RakeTask.new do |t|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
FROM ruby:2.4-slim-stretch
|
2
|
+
|
3
|
+
RUN apt-get update \
|
4
|
+
&& apt-get install -y --no-install-recommends cmake make gcc pkg-config squashfs-tools git curl bison \
|
5
|
+
&& rm -rf /var/lib/apt/lists/*
|
6
|
+
|
7
|
+
RUN curl -L http://enclose.io/rubyc/rubyc-linux-x64.gz | gunzip > /usr/local/bin/rubyc \
|
8
|
+
&& chmod +x /usr/local/bin/rubyc
|
9
|
+
|
10
|
+
ENV CPPFLAGS="-P"
|
11
|
+
ENV RUBYC="/usr/local/bin/rubyc"
|
data/docs/packaging.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Packaging licensed for distribution
|
2
|
+
|
3
|
+
Licensed is built into executables and packaged for distribution using [ruby-packer][ruby-packer].
|
4
|
+
|
5
|
+
Executable packages are currently supported for:
|
6
|
+
1. Linux
|
7
|
+
2. MacOS / Darwin
|
8
|
+
|
9
|
+
The packaged executables contain a self-expanding file system containing ruby, licensed and all of it's runtime dependencies. Licensed is run inside the contained file system, allowing usage in scenarios where ruby is not available on the host system.
|
10
|
+
|
11
|
+
### Building packages
|
12
|
+
|
13
|
+
Packages are built as `licensed-$VERSION-$PLATFORM-x64.tar.gz` tarballs that contain a single `./licensed` executable. After building a package through the available scripting, it will be available in the `pkg` directory.
|
14
|
+
|
15
|
+
By default an exe is built for the current licensed git `HEAD`. The
|
16
|
+
`$VERSION` in the package name will be set to the current branch name if
|
17
|
+
available, otherwise the current SHA. To use a specific licensed version,
|
18
|
+
set a `VERSION` environment variable when calling the packaging scripts. `VERSION` can be set to any value that works with `git checkout`.
|
19
|
+
|
20
|
+
#### Building all packages
|
21
|
+
```bash
|
22
|
+
# build all packages
|
23
|
+
$ script/package
|
24
|
+
```
|
25
|
+
or
|
26
|
+
```bash
|
27
|
+
# build all packages
|
28
|
+
$ bundle exec rake package
|
29
|
+
```
|
30
|
+
|
31
|
+
#### Building packages for a single platform
|
32
|
+
```bash
|
33
|
+
# build package for linux
|
34
|
+
$ script/package linux
|
35
|
+
```
|
36
|
+
or
|
37
|
+
```bash
|
38
|
+
# build package for linux
|
39
|
+
$ bundle exec rake package:linux
|
40
|
+
```
|
41
|
+
|
42
|
+
#### Building packages for a specific version
|
43
|
+
```bash
|
44
|
+
# VERSION can be set to anything that works with git checkout - tag, branch, SHA1
|
45
|
+
$ VERSION="1.1.0" script/package
|
46
|
+
```
|
47
|
+
or
|
48
|
+
```bash
|
49
|
+
# VERSION can be set to anything that works with git checkout - tag, branch, SHA1
|
50
|
+
$ VERSION="1.1.0" bundle exec rake package
|
51
|
+
```
|
52
|
+
|
53
|
+
[ruby-packer]: https://github.com/pmq20/ruby-packer
|
data/docs/sources/bundler.md
CHANGED
@@ -2,6 +2,29 @@
|
|
2
2
|
|
3
3
|
The bundler source will detect dependencies `Gemfile` and `Gemfile.lock` files are found at an apps `source_path`. The source uses the `Bundler` API to enumerate dependencies from `Gemfile` and `Gemfile.lock`.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
### Excluding gem groups
|
6
|
+
|
7
|
+
The bundler source determines which gem groups to include or exclude with the following logic, in order of precedence.
|
8
|
+
1. Include all groups specified in the Gemfile
|
9
|
+
2. Exclude all groups from the `without` bundler configuration (e.g. `.bundle/config`)
|
10
|
+
3. Include all groups from the `with` bundler configuration (e.g. `.bundle/config`)
|
11
|
+
4. Exclude all groups from the `without` licensed configuration (`:development` and `:test` if not otherwise specified)
|
12
|
+
|
13
|
+
`licensed` can be configured to override the default "without" development and test groups in the configuration file.
|
14
|
+
|
15
|
+
Strings and string arrays are both :+1:
|
16
|
+
|
17
|
+
```yml
|
18
|
+
rubygems:
|
19
|
+
without: development
|
20
|
+
```
|
21
|
+
|
22
|
+
or
|
23
|
+
|
24
|
+
```yml
|
25
|
+
rubygems:
|
26
|
+
without:
|
27
|
+
- build
|
28
|
+
- development
|
29
|
+
- test
|
30
|
+
```
|
data/docs/sources/dep.md
CHANGED
@@ -3,17 +3,9 @@ This source is intended to be used when all of a projects dependencies have been
|
|
3
3
|
|
4
4
|
# Go Dep
|
5
5
|
|
6
|
-
The dep source will detect dependencies when the source is enabled and
|
6
|
+
The dep source will detect dependencies when the source is enabled and `Gopkg.lock` is found at an apps `source_path`. It
|
7
7
|
parses the `Gopkg.lock` file to find packages that have been vendored into the project directory.
|
8
8
|
|
9
|
-
This source will self-disable if the `ignored` property in `Gopkg.toml` has any values. While strongly discouraged, the source can be forced to run
|
10
|
-
via configuration.
|
11
|
-
|
12
|
-
```yml
|
13
|
-
dep:
|
14
|
-
allow_ignored: true # force source to run even if `Gopkg.toml` is non-empty
|
15
|
-
```
|
16
|
-
|
17
9
|
#### Limitations
|
18
10
|
|
19
11
|
The dep dependency source has some limitations compared to the general-purpose go source.
|
data/lib/licensed/shell.rb
CHANGED
@@ -6,8 +6,8 @@ module Licensed
|
|
6
6
|
# Executes a command, returning its standard output on success. On failure,
|
7
7
|
# it raises an exception that contains the error output, unless
|
8
8
|
# `allow_failure` is true, in which case it returns an empty string.
|
9
|
-
def self.execute(cmd, *args, allow_failure: false)
|
10
|
-
stdout, stderr, status = Open3.capture3(cmd, *args)
|
9
|
+
def self.execute(cmd, *args, allow_failure: false, env: {})
|
10
|
+
stdout, stderr, status = Open3.capture3(env, cmd, *args)
|
11
11
|
|
12
12
|
if status.success?
|
13
13
|
stdout.strip
|
@@ -8,6 +8,7 @@ module Licensed
|
|
8
8
|
module Source
|
9
9
|
class Bundler
|
10
10
|
GEMFILES = %w{Gemfile gems.rb}.freeze
|
11
|
+
DEFAULT_WITHOUT_GROUPS = %i{development test}
|
11
12
|
|
12
13
|
def self.type
|
13
14
|
"rubygem"
|
@@ -23,8 +24,8 @@ module Licensed
|
|
23
24
|
|
24
25
|
def dependencies
|
25
26
|
@dependencies ||= with_local_configuration do
|
26
|
-
|
27
|
-
Dependency.new(spec.gem_dir, {
|
27
|
+
specs.map do |spec|
|
28
|
+
Licensed::Dependency.new(spec.gem_dir, {
|
28
29
|
"type" => Bundler.type,
|
29
30
|
"name" => spec.name,
|
30
31
|
"version" => spec.version.to_s,
|
@@ -35,14 +36,139 @@ module Licensed
|
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
39
|
+
# Returns an array of Gem::Specifications for all gem dependencies
|
40
|
+
def specs
|
41
|
+
# get the specifications for all dependencies in a Gemfile
|
42
|
+
root_dependencies = definition.dependencies.select { |d| include?(d, nil) }
|
43
|
+
root_specs = specs_for_dependencies(root_dependencies, nil).compact
|
44
|
+
|
45
|
+
# recursively find the remaining specifications
|
46
|
+
all_specs = recursive_specs(root_specs)
|
47
|
+
|
48
|
+
# delete any specifications loaded from a gemspec
|
49
|
+
all_specs.delete_if { |s| s.source.is_a?(::Bundler::Source::Gemspec) }
|
50
|
+
end
|
51
|
+
|
52
|
+
# Recursively finds the dependencies for Gem specifications.
|
53
|
+
# Returns a `Set` containing the package names for all dependencies
|
54
|
+
def recursive_specs(specs, results = Set.new)
|
55
|
+
return [] if specs.nil? || specs.empty?
|
56
|
+
|
57
|
+
new_specs = Set.new(specs) - results.to_a
|
58
|
+
return [] if new_specs.empty?
|
59
|
+
|
60
|
+
results.merge new_specs
|
61
|
+
|
62
|
+
dependency_specs = new_specs.flat_map { |s| specs_for_dependencies(s.dependencies, s.source) }
|
63
|
+
|
64
|
+
return results if dependency_specs.empty?
|
65
|
+
|
66
|
+
results.merge recursive_specs(dependency_specs, results)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Returns the specs for dependencies that pass the checks in `include?`
|
70
|
+
# Raises an error if the specification isn't found
|
71
|
+
def specs_for_dependencies(dependencies, source)
|
72
|
+
included_dependencies = dependencies.select { |d| include?(d, source) }
|
73
|
+
included_dependencies.map do |dep|
|
74
|
+
gem_spec(dep) || raise("Unable to find a specification for #{dep.name} (#{dep.requirement}) in any sources")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
# Returns a Gem::Specification for the provided gem argument. If a
|
79
|
+
# Gem::Specification isn't found, an error will be raised.
|
80
|
+
def gem_spec(dependency)
|
81
|
+
return unless dependency
|
82
|
+
|
83
|
+
# bundler specifications aren't put in ::Bundler.specs_path, even if the
|
84
|
+
# gem is a runtime dependency. it needs to be handled specially
|
85
|
+
return bundler_spec if dependency.name == "bundler"
|
86
|
+
|
87
|
+
# find a specifiction from the resolved ::Bundler::Definition specs
|
88
|
+
spec = definition.resolve.find { |s| s.satisfies?(dependency) }
|
89
|
+
return spec unless spec.is_a?(::Bundler::LazySpecification)
|
90
|
+
|
91
|
+
# if the specification is coming from a gemspec source,
|
92
|
+
# we can get a non-lazy specification straight from the source
|
93
|
+
if spec.source.is_a?(::Bundler::Source::Gemspec)
|
94
|
+
return spec.source.specs.first
|
95
|
+
end
|
96
|
+
|
97
|
+
# look for a specification at the bundler specs path
|
98
|
+
spec_path = ::Bundler.specs_path.join("#{spec.full_name}.gemspec")
|
99
|
+
return unless File.exist?(spec_path.to_s)
|
100
|
+
Gem::Specification.load(spec_path.to_s)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Returns whether a dependency should be included in the final
|
104
|
+
def include?(dependency, source)
|
105
|
+
# ::Bundler::Dependency has an extra `should_include?`
|
106
|
+
return false unless dependency.should_include? if dependency.respond_to?(:should_include?)
|
107
|
+
|
108
|
+
# Don't return gems added from `add_development_dependency` in a gemspec
|
109
|
+
# if the :development group is excluded
|
110
|
+
gemspec_source = source.is_a?(::Bundler::Source::Gemspec)
|
111
|
+
return false if dependency.type == :development && (!gemspec_source || exclude_development_dependencies?)
|
112
|
+
|
113
|
+
# Gem::Dependency don't have groups - in our usage these objects always
|
114
|
+
# come as child-dependencies and are never directly from a Gemfile.
|
115
|
+
# We assume that all Gem::Dependencies are ok at this point
|
116
|
+
return true if dependency.groups.nil?
|
117
|
+
|
118
|
+
# check if the dependency is in any groups we're interested in
|
119
|
+
(dependency.groups & groups).any?
|
120
|
+
end
|
121
|
+
|
122
|
+
# Returns whether development dependencies should be excluded
|
123
|
+
def exclude_development_dependencies?
|
124
|
+
@include_development ||= begin
|
125
|
+
# check whether the development dependency group is explicitly removed
|
126
|
+
# or added via bundler and licensed configurations
|
127
|
+
groups = [:development] - Array(::Bundler.settings[:without]) + Array(::Bundler.settings[:with]) - exclude_groups
|
128
|
+
!groups.include?(:development)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# Returns a gemspec for bundler, found and loaded by running `gem specification bundler`
|
133
|
+
# This is a hack to work around bundler not placing it's own spec at
|
134
|
+
# `::Bundler.specs_path` when it's an explicit dependency
|
135
|
+
def bundler_spec
|
136
|
+
# cache this so we run CLI commands as few times as possible
|
137
|
+
return @bundler_spec if defined?(@bundler_spec)
|
138
|
+
|
139
|
+
# finding the bundler gem is dependent on having `gem` available
|
140
|
+
unless Licensed::Shell.tool_available?("gem")
|
141
|
+
@bundler_spec = nil
|
142
|
+
return
|
143
|
+
end
|
144
|
+
|
145
|
+
# Bundler is always used from the default gem install location.
|
146
|
+
# we can use `gem specification bundler` with a clean ENV to
|
147
|
+
# get the system bundler gem as YAML
|
148
|
+
yaml = ::Bundler.with_original_env { Licensed::Shell.execute("gem", "specification", "bundler") }
|
149
|
+
@bundler_spec = Gem::Specification.from_yaml(yaml)
|
150
|
+
end
|
151
|
+
|
38
152
|
# Build the bundler definition
|
39
153
|
def definition
|
40
154
|
@definition ||= ::Bundler::Definition.build(gemfile_path, lockfile_path, nil)
|
41
155
|
end
|
42
156
|
|
43
|
-
# Returns the bundle definition groups,
|
157
|
+
# Returns the bundle definition groups, removing "without" groups,
|
158
|
+
# and including "with" groups
|
44
159
|
def groups
|
45
|
-
definition.groups - [:
|
160
|
+
definition.groups - Array(::Bundler.settings[:without]) + Array(::Bundler.settings[:with]) - exclude_groups
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns any groups to exclude specified from both licensed configuration
|
164
|
+
# and bundler configuration.
|
165
|
+
# Defaults to [:development, :test] + ::Bundler.settings[:without]
|
166
|
+
def exclude_groups
|
167
|
+
@exclude_groups ||= begin
|
168
|
+
exclude = Array(@config.dig("rubygems", "without"))
|
169
|
+
exclude.push(*DEFAULT_WITHOUT_GROUPS) if exclude.empty?
|
170
|
+
exclude.uniq.map(&:to_sym)
|
171
|
+
end
|
46
172
|
end
|
47
173
|
|
48
174
|
# Returns the path to the Bundler Gemfile
|
@@ -61,20 +187,15 @@ module Licensed
|
|
61
187
|
|
62
188
|
# helper to clear all bundler environment around a yielded block
|
63
189
|
def with_local_configuration
|
64
|
-
|
65
|
-
|
66
|
-
# with a clean, original environment
|
67
|
-
::Bundler.with_original_env do
|
68
|
-
# force bundler to use the local gem file
|
69
|
-
ENV["BUNDLE_GEMFILE"] = gemfile_path.to_s
|
190
|
+
# force bundler to use the local gem file
|
191
|
+
original_bundle_gemfile, ENV["BUNDLE_GEMFILE"] = ENV["BUNDLE_GEMFILE"], gemfile_path.to_s
|
70
192
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
193
|
+
# reset all bundler configuration
|
194
|
+
::Bundler.reset!
|
195
|
+
# and re-configure with settings for current directory
|
196
|
+
::Bundler.configure
|
75
197
|
|
76
|
-
|
77
|
-
end
|
198
|
+
yield
|
78
199
|
ensure
|
79
200
|
ENV["BUNDLE_GEMFILE"] = original_bundle_gemfile
|
80
201
|
# restore bundler configuration
|
data/lib/licensed/source/dep.rb
CHANGED
@@ -60,21 +60,13 @@ module Licensed
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def go_dep_available?
|
63
|
-
|
64
|
-
return true if @config.dig("dep", "allow_ignored") == true
|
65
|
-
|
66
|
-
gopkg_toml = Tomlrb.load_file(gopkg_toml_path, symbolize_keys: true)
|
67
|
-
gopkg_toml[:ignored].nil? || gopkg_toml[:ignored].empty?
|
63
|
+
gopkg_lock_path.exist?
|
68
64
|
end
|
69
65
|
|
70
66
|
def gopkg_lock_path
|
71
67
|
@config.pwd.join("Gopkg.lock")
|
72
68
|
end
|
73
69
|
|
74
|
-
def gopkg_toml_path
|
75
|
-
@config.pwd.join("Gopkg.toml")
|
76
|
-
end
|
77
|
-
|
78
70
|
# Returns a list of go standard packages
|
79
71
|
def go_std_packages
|
80
72
|
@std_packages ||= begin
|
data/lib/licensed/source/pip.rb
CHANGED
@@ -14,6 +14,7 @@ module Licensed
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def enabled?
|
17
|
+
return unless virtual_env_pip && Licensed::Shell.tool_available?(virtual_env_pip)
|
17
18
|
File.exist?(@config.pwd.join("requirements.txt"))
|
18
19
|
end
|
19
20
|
|
@@ -50,13 +51,20 @@ module Licensed
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def pip_command(*args)
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
Licensed::Shell.execute(virtual_env_pip, "--disable-pip-version-check", "show", *args)
|
55
|
+
end
|
56
|
+
|
57
|
+
def virtual_env_pip
|
58
|
+
return unless virtual_env_dir
|
59
|
+
File.join(virtual_env_dir, "bin", "pip")
|
60
|
+
end
|
61
|
+
|
62
|
+
def virtual_env_dir
|
63
|
+
return @virtual_env_dir if defined?(@virtual_env_dir)
|
64
|
+
@virtual_env_dir = begin
|
65
|
+
venv_dir = @config.dig("python", "virtual_env_dir")
|
66
|
+
File.expand_path(venv_dir, Licensed::Git.repository_root) if venv_dir
|
56
67
|
end
|
57
|
-
venv_dir = File.expand_path(venv_dir, Licensed::Git.repository_root)
|
58
|
-
pip = File.join(venv_dir, "bin", "pip")
|
59
|
-
Licensed::Shell.execute(pip, "--disable-pip-version-check", "show", *args)
|
60
68
|
end
|
61
69
|
end
|
62
70
|
end
|
data/lib/licensed/version.rb
CHANGED
data/licensed.gemspec
CHANGED
@@ -21,18 +21,20 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
+
spec.required_ruby_version = ">= 2.3.0"
|
25
|
+
|
24
26
|
spec.add_dependency "licensee", "~> 9.0"
|
25
27
|
spec.add_dependency "thor", "~>0.19"
|
26
28
|
spec.add_dependency "octokit", "~>4.0"
|
27
29
|
spec.add_dependency "pathname-common_prefix", "~>0.0.1"
|
28
30
|
spec.add_dependency "tomlrb", "~>1.2"
|
31
|
+
spec.add_dependency "bundler", "~> 1.10"
|
29
32
|
|
30
|
-
spec.add_development_dependency "bundler", "~> 1.10"
|
31
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
32
34
|
spec.add_development_dependency "minitest", "~> 5.8"
|
33
35
|
spec.add_development_dependency "vcr", "~> 2.9"
|
34
36
|
spec.add_development_dependency "webmock", "~> 1.21"
|
35
37
|
spec.add_development_dependency "rubocop", "~> 0.49"
|
36
38
|
spec.add_development_dependency "rubocop-github", "~> 0.6"
|
37
|
-
spec.add_development_dependency "byebug"
|
39
|
+
spec.add_development_dependency "byebug", "~> 10.0.0"
|
38
40
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#/ Usage: script/build-rubyc-exe <RUBYC> [VERSION]
|
3
|
+
#/
|
4
|
+
#/ WARNING: You should not need to call this directly. Please create packages using
|
5
|
+
#/ `script/package [platform]` or `bundle exec rake package[platform]`
|
6
|
+
#/
|
7
|
+
#/ Builds a distributable package for licensed for a given RUBYC compiler and licensed VERSION.
|
8
|
+
#/ Packages are of the form licensed-$VERSION-$PLATFORM-x64.tar.gz and contain a `./licensed` executable
|
9
|
+
#/ Built Packages are placed in the <root>/pkg directory.
|
10
|
+
#/
|
11
|
+
#/ OPTIONS:
|
12
|
+
#/ <RUBYC> The path to a rubyc compiler that should be used to compile the target executable
|
13
|
+
#/ [VERSION] (optional, default to current git branch or SHA1) version of licensed to build exe at
|
14
|
+
#/
|
15
|
+
#/ EXAMPLES:
|
16
|
+
#/
|
17
|
+
#/ Builds a package for version 1.1.0 using a local rubyc compiler
|
18
|
+
#/ $ build-rubyc-exe RUBYC="./rubyc-darwin" VERSION="1.1.0"
|
19
|
+
#/
|
20
|
+
|
21
|
+
set -euo pipefail
|
22
|
+
|
23
|
+
usage(){
|
24
|
+
grep "^#/" <"$0" | cut -c3-
|
25
|
+
}
|
26
|
+
|
27
|
+
BASE_DIR="$(cd "$(dirname $0)/.." && pwd)"
|
28
|
+
VERSION=${VERSION:=""}
|
29
|
+
RUBYC=${RUBYC:=""}
|
30
|
+
if [ ! -f "$RUBYC" ]; then
|
31
|
+
echo "Please specify a rubyc compiler" >&2
|
32
|
+
usage
|
33
|
+
exit 127
|
34
|
+
fi
|
35
|
+
|
36
|
+
BUILD_DEST="$(mktemp -d)"
|
37
|
+
trap "rm -rf $BUILD_DEST" EXIT
|
38
|
+
|
39
|
+
if [ -n "$VERSION" ]; then
|
40
|
+
git checkout "$VERSION"
|
41
|
+
CURRENT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
|
42
|
+
trap "rm -rf $BUILD_DEST; git checkout $CURRENT_BRANCH" EXIT
|
43
|
+
else
|
44
|
+
VERSION="$(git rev-parse --abbrev-ref HEAD)"
|
45
|
+
fi
|
46
|
+
|
47
|
+
PACKAGE_DEST="$BASE_DIR/pkg"
|
48
|
+
mkdir -p "$PACKAGE_DEST"
|
49
|
+
|
50
|
+
PLATFORM="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
51
|
+
TARGET="licensed-$VERSION-$PLATFORM-x64.tar.gz"
|
52
|
+
|
53
|
+
"$RUBYC" --clean-tmpdir -o "$BUILD_DEST/licensed" "$BASE_DIR/exe/licensed"
|
54
|
+
|
55
|
+
chmod +x $BUILD_DEST/licensed
|
56
|
+
tar -C "$BUILD_DEST" -czf "$PACKAGE_DEST/$TARGET" "./licensed"
|
57
|
+
|
58
|
+
echo "licensed built to $PACKAGE_DEST/$TARGET"
|
data/script/package
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#/ Usage: script/package [PLATFORM] [VERSION]
|
3
|
+
#/
|
4
|
+
#/ Builds distributable packages for licensed.
|
5
|
+
#/ Packages are of the form licensed-$VERSION-$PLATFORM-x64.tar.gz and contain a `./licensed` executable
|
6
|
+
#/ Built packages are placed in the <root>/pkg directory.
|
7
|
+
#/
|
8
|
+
#/ OPTIONS:
|
9
|
+
#/ [PLATFORM] (optional, default to all platforms) platform to build exe for
|
10
|
+
#/ [VERSION] (optional, default to current git branch or SHA1) version of licensed to build exe at
|
11
|
+
#/
|
12
|
+
|
13
|
+
set -e
|
14
|
+
|
15
|
+
PLATFORM=""
|
16
|
+
if [ -n "$1" ]; then
|
17
|
+
PLATFORM=":$1"
|
18
|
+
fi
|
19
|
+
|
20
|
+
bundle exec rake "package$PLATFORM"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#/ Usage: script/packages/linux [VERSION]
|
3
|
+
#/
|
4
|
+
#/ WARNING: You should not need to call this directly. Please create packages using
|
5
|
+
#/ `script/package [platform]` or `bundle exec rake package[platform]`
|
6
|
+
#/
|
7
|
+
#/ Builds a linux distributable package for licensed for a given and licensed VERSION.
|
8
|
+
#/ Packages are of the form licensed-$VERSION-linux-x64.tar.gz and contain a `./licensed` executable
|
9
|
+
#/ Built packages are placed in the <root>/pkg directory.
|
10
|
+
#/
|
11
|
+
#/ If calling from a non-linux OS, docker is used to build a linux binary
|
12
|
+
#/
|
13
|
+
#/ OPTIONS:
|
14
|
+
#/ [VERSION] (optional, default to current git branch or SHA1) version of licensed to build exe at
|
15
|
+
#/
|
16
|
+
|
17
|
+
set -euo pipefail
|
18
|
+
|
19
|
+
BASE_DIR="$(cd "$(dirname $0)/../.." && pwd)"
|
20
|
+
VERSION=${VERSION:=""}
|
21
|
+
|
22
|
+
build_linux_docker() {
|
23
|
+
IMAGE="licensed/build-linux"
|
24
|
+
docker build -t "$IMAGE" - < "$BASE_DIR/docker/Dockerfile.build-linux"
|
25
|
+
docker run --rm \
|
26
|
+
-e VERSION="$VERSION" \
|
27
|
+
-v "$BASE_DIR":/var/licensed \
|
28
|
+
-w /var/licensed \
|
29
|
+
"$IMAGE" \
|
30
|
+
"script/build-rubyc-exe"
|
31
|
+
}
|
32
|
+
|
33
|
+
build_linux_local() {
|
34
|
+
sudo apt-get update && \
|
35
|
+
apt-get install -y --no-install-recommends cmake make gcc pkg-config squashfs-tools curl bison git
|
36
|
+
|
37
|
+
if [ ! -f "$BASE_DIR/bin/rubyc-linux" ]; then
|
38
|
+
mkdir -p "$BASE_DIR/bin"
|
39
|
+
curl -L http://enclose.io/rubyc/rubyc-linux-x64.gz | gunzip > "$BASE_DIR/bin/rubyc-linux"
|
40
|
+
chmod +x "$BASE_DIR/bin/rubyc-linux"
|
41
|
+
fi
|
42
|
+
|
43
|
+
export CPPFLAGS="-P"
|
44
|
+
RUBYC="$BASE_DIR/bin/rubyc-linux" "$BASE_DIR"/script/build-rubyc-exe
|
45
|
+
}
|
46
|
+
|
47
|
+
if [[ "$(uname -s)" != "Linux" ]]; then
|
48
|
+
build_linux_docker
|
49
|
+
else
|
50
|
+
build_linux_local
|
51
|
+
fi
|
data/script/packages/mac
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#/ Usage: script/packages/mac [VERSION]
|
3
|
+
#/
|
4
|
+
#/ WARNING: You should not need to call this directly. Please create packages using
|
5
|
+
#/ `script/package [platform]` or `bundle exec rake package[platform]`
|
6
|
+
#/
|
7
|
+
#/ Builds a mac distributable package for licensed for a given licensed VERSION.
|
8
|
+
#/ Packages are of the form licensed-$VERSION-darwin-x64.tar.gz and contain a `./licensed` executable
|
9
|
+
#/ Built packages are placed in the <root>/pkg directory.
|
10
|
+
#/
|
11
|
+
#/ Must be called from a Mac OS.
|
12
|
+
#/
|
13
|
+
#/ OPTIONS:
|
14
|
+
#/ [VERSION] (optional, default to current git branch or SHA1) version of licensed to build exe at
|
15
|
+
#/
|
16
|
+
|
17
|
+
set -euo pipefail
|
18
|
+
|
19
|
+
if [[ "$(uname -s)" != "Darwin" ]]; then
|
20
|
+
echo "A Mac OS is required to build a licensed executable for mac" >&2
|
21
|
+
exit 1
|
22
|
+
fi
|
23
|
+
|
24
|
+
BASE_DIR="$(cd "$(dirname $0)/../.." && pwd)"
|
25
|
+
|
26
|
+
brew update
|
27
|
+
brew list "squashfs" &>/dev/null || brew install "squashfs"
|
28
|
+
|
29
|
+
if [ ! -f "$BASE_DIR/bin/rubyc-darwin" ]; then
|
30
|
+
mkdir -p "$BASE_DIR/bin"
|
31
|
+
curl -L http://enclose.io/rubyc/rubyc-darwin-x64.gz | gunzip > "$BASE_DIR/bin/rubyc-darwin"
|
32
|
+
chmod +x "$BASE_DIR/bin/rubyc-darwin"
|
33
|
+
fi
|
34
|
+
|
35
|
+
RUBYC="$BASE_DIR/bin/rubyc-darwin" "$BASE_DIR"/script/build-rubyc-exe
|
data/script/source-setup/bundler
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: licensed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: licensee
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '1.10'
|
90
|
-
type: :
|
90
|
+
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
@@ -182,16 +182,16 @@ dependencies:
|
|
182
182
|
name: byebug
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- - "
|
185
|
+
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
187
|
+
version: 10.0.0
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- - "
|
192
|
+
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
194
|
+
version: 10.0.0
|
195
195
|
description: Licensed automates extracting and validating the licenses of dependencies.
|
196
196
|
email:
|
197
197
|
- opensource+licensed@github.com
|
@@ -211,7 +211,9 @@ files:
|
|
211
211
|
- LICENSE
|
212
212
|
- README.md
|
213
213
|
- Rakefile
|
214
|
+
- docker/Dockerfile.build-linux
|
214
215
|
- docs/configuration.md
|
216
|
+
- docs/packaging.md
|
215
217
|
- docs/sources/bower.md
|
216
218
|
- docs/sources/bundler.md
|
217
219
|
- docs/sources/cabal.md
|
@@ -244,8 +246,12 @@ files:
|
|
244
246
|
- lib/licensed/version.rb
|
245
247
|
- licensed.gemspec
|
246
248
|
- script/bootstrap
|
249
|
+
- script/build-rubyc-exe
|
247
250
|
- script/cibuild
|
248
251
|
- script/console
|
252
|
+
- script/package
|
253
|
+
- script/packages/linux
|
254
|
+
- script/packages/mac
|
249
255
|
- script/setup
|
250
256
|
- script/source-setup/bower
|
251
257
|
- script/source-setup/bundler
|
@@ -266,7 +272,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
266
272
|
requirements:
|
267
273
|
- - ">="
|
268
274
|
- !ruby/object:Gem::Version
|
269
|
-
version:
|
275
|
+
version: 2.3.0
|
270
276
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
277
|
requirements:
|
272
278
|
- - ">="
|