itamae-plugin-recipe-rust 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +109 -0
- data/Rakefile +39 -0
- data/itamae-plugin-recipe-rust.gemspec +43 -0
- data/lib/itamae/plugin/recipe/rust/install.rb +43 -0
- data/lib/itamae/plugin/recipe/rust/system.rb +7 -0
- data/lib/itamae/plugin/recipe/rust/user.rb +19 -0
- data/lib/itamae/plugin/recipe/rust/version.rb +11 -0
- data/lib/itamae/plugin/recipe/rust.rb +3 -0
- data/mrblib +1 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2b96bd538971aaca68fb377a88f29cdc73640d2053f5eb1601053fccdafff67f
|
4
|
+
data.tar.gz: 3f3bd72ae4bea42bfc2f342f4f61e591c44fd9be24b941b4ddfbe8aa60026ad0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e54bbd56871bf7c79e839d39dfbc59c2594ccfabfe2d2b237a33568ee57ce9b951e7a98a15abcb81dc9fb82a49752fc7d9f2982cdea2d314331b3db12f938cd
|
7
|
+
data.tar.gz: a7e52df8051cf103bb9035b9c5ed08b85c184411a4bbdf53ca68ca867ac288d52c78eeab0f483e9874904037cd32eceec90d5599154ef4f890ac97d1927a3a6d
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 sue445
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Itamae::Plugin::Recipe::Rust
|
2
|
+
[Itamae](https://github.com/itamae-kitchen/itamae) plugin to install [Rust](https://www.rust-lang.org/)
|
3
|
+
|
4
|
+
[![test](https://github.com/itamae-plugins/itamae-plugin-recipe-rust/actions/workflows/test.yml/badge.svg)](https://github.com/itamae-plugins/itamae-plugin-recipe-rust/actions/workflows/test.yml)
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'itamae-plugin-recipe-rust'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle install
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install itamae-plugin-recipe-rust
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### System wide installation
|
25
|
+
Install Rust to `/usr/local/cargo` or some shared path
|
26
|
+
|
27
|
+
#### Recipe
|
28
|
+
```ruby
|
29
|
+
# your recipe
|
30
|
+
include_recipe "rust::system"
|
31
|
+
```
|
32
|
+
|
33
|
+
#### Node
|
34
|
+
Use this with `itamae -y node.yml`
|
35
|
+
|
36
|
+
```yaml
|
37
|
+
rust:
|
38
|
+
# Rust install dir, optional (default: /usr/local/cargo)
|
39
|
+
cargo_home: /usr/local/cargo
|
40
|
+
|
41
|
+
# Version of Rust to install, optional (default: latest)
|
42
|
+
# version: 1.58.1
|
43
|
+
|
44
|
+
# Passed to `rustup install`, optional (This is used to install a specific version of Rust)
|
45
|
+
# rustup_install_option: "--profile minimal"
|
46
|
+
```
|
47
|
+
|
48
|
+
#### .bashrc
|
49
|
+
Recommend to append this to `.bashrc` in your server.
|
50
|
+
|
51
|
+
```bash
|
52
|
+
export CARGO_HOME=/usr/local/rust
|
53
|
+
export PATH="${CARGO_HOME}/bin:${PATH}"
|
54
|
+
```
|
55
|
+
|
56
|
+
### Installation for a user
|
57
|
+
Install Rust to `~/.cargo`
|
58
|
+
|
59
|
+
#### Recipe
|
60
|
+
```ruby
|
61
|
+
# your recipe
|
62
|
+
include_recipe "rust::user"
|
63
|
+
```
|
64
|
+
|
65
|
+
#### Node
|
66
|
+
Use this with `itamae -y node.yml`
|
67
|
+
|
68
|
+
```yaml
|
69
|
+
rust:
|
70
|
+
# User to be installed, optional (default: ENV["USER"])
|
71
|
+
user: deploy
|
72
|
+
|
73
|
+
# Rust install dir, optional (default: "/home/#{node[:rust][:user]}/.cargo" or "/Users/#{node[:rust][:user]}/.cargo" (MacOS))
|
74
|
+
# cargo_home: /home/deploy/.cargo
|
75
|
+
|
76
|
+
# Version of Rust to install, optional (default: latest)
|
77
|
+
# version: 1.58.1
|
78
|
+
|
79
|
+
# Passed to `rustup install`, optional (This is used to install a specific version of Rust)
|
80
|
+
# rustup_install_option: "--profile minimal"
|
81
|
+
```
|
82
|
+
|
83
|
+
## mitamae
|
84
|
+
This plugin can be used for [mitamae](https://github.com/itamae-kitchen/mitamae) too. Put this repository under `./plugins` as git submodule.
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
node.reverse_merge!(
|
88
|
+
rust: {
|
89
|
+
user: "deploy",
|
90
|
+
version: "1.58.1",
|
91
|
+
}
|
92
|
+
)
|
93
|
+
|
94
|
+
include_recipe "rust::user"
|
95
|
+
```
|
96
|
+
|
97
|
+
## Development
|
98
|
+
|
99
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
100
|
+
|
101
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
102
|
+
|
103
|
+
## Contributing
|
104
|
+
|
105
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/itamae-plugins/itamae-plugin-recipe-rust.
|
106
|
+
|
107
|
+
## License
|
108
|
+
|
109
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
|
6
|
+
ENV["TEST_IMAGE"] = "itamae-plugin:latest"
|
7
|
+
ENV["SOURCE_IMAGE"] ||= "ubuntu:jammy"
|
8
|
+
|
9
|
+
targets = %i(system user)
|
10
|
+
|
11
|
+
namespace :test do
|
12
|
+
targets.each do |target|
|
13
|
+
namespace target do
|
14
|
+
node_yaml = "#{__dir__}/spec/#{target}/recipes/node.yml"
|
15
|
+
test_image = "itamae-plugin:#{target}"
|
16
|
+
|
17
|
+
desc "Run itamae to #{target}"
|
18
|
+
task :itamae do
|
19
|
+
ENV["TEST_IMAGE"] = "itamae-plugin:#{target}"
|
20
|
+
sh "itamae docker --node-yaml=#{node_yaml} spec/#{target}/recipes/install.rb --image=#{ENV["SOURCE_IMAGE"]} --tag #{test_image}"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Run serverspec tests to #{target}"
|
24
|
+
RSpec::Core::RakeTask.new(:serverspec) do |t|
|
25
|
+
ENV["TEST_IMAGE"] = test_image
|
26
|
+
ENV["NODE_YAML"] = node_yaml
|
27
|
+
t.pattern = "spec/#{target}/*_spec.rb"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Run itamae and serverspec tests to #{target} "
|
32
|
+
task target => ["#{target}:itamae", "#{target}:serverspec"]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Run test"
|
37
|
+
task :test => targets.map { |target| "test:#{target}" }
|
38
|
+
|
39
|
+
task default: :test
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/itamae/plugin/recipe/rust/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "itamae-plugin-recipe-rust"
|
7
|
+
spec.version = Itamae::Plugin::Recipe::Rust::VERSION
|
8
|
+
spec.authors = ["sue445"]
|
9
|
+
spec.email = ["sue445@sue445.net"]
|
10
|
+
|
11
|
+
spec.summary = "Itamae plugin to install Rust"
|
12
|
+
spec.description = "Itamae plugin to install Rust"
|
13
|
+
spec.homepage = "https://github.com/itamae-plugins/itamae-plugin-recipe-rust"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 2.3.0"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
20
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_dependency "itamae"
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler"
|
36
|
+
spec.add_development_dependency "docker-api"
|
37
|
+
spec.add_development_dependency "rake"
|
38
|
+
spec.add_development_dependency "rspec"
|
39
|
+
spec.add_development_dependency "serverspec"
|
40
|
+
|
41
|
+
# For more information and examples about making a new gem, check out our
|
42
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
43
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# c.f. https://www.rust-lang.org/learn/get-started
|
2
|
+
|
3
|
+
[
|
4
|
+
"curl"
|
5
|
+
].each do |name|
|
6
|
+
package name
|
7
|
+
end
|
8
|
+
|
9
|
+
rust_env = "CARGO_HOME=#{node[:rust][:cargo_home]}"
|
10
|
+
rustc = "#{rust_env} #{node[:rust][:cargo_home]}/bin/rustc"
|
11
|
+
rustup = "#{rust_env} #{node[:rust][:cargo_home]}/bin/rustup"
|
12
|
+
|
13
|
+
execute "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | #{rust_env} sh -s -- -y" do
|
14
|
+
not_if "#{rustc} --version"
|
15
|
+
|
16
|
+
if node[:rust][:user]
|
17
|
+
user node[:rust][:user]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if node[:rust][:version]
|
22
|
+
rustup_install = "#{rustup} install #{node[:rust][:version]}"
|
23
|
+
|
24
|
+
if node[:rust][:rustup_install_option]
|
25
|
+
rustup_install << " #{node[:rust][:rustup_install_option]}"
|
26
|
+
end
|
27
|
+
|
28
|
+
execute rustup_install do
|
29
|
+
not_if "#{rustc} --version | grep #{node[:rust][:version]}"
|
30
|
+
|
31
|
+
if node[:rust][:user]
|
32
|
+
user node[:rust][:user]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
execute "#{rustup} default #{node[:rust][:version]}" do
|
37
|
+
not_if "#{rustc} --version | grep #{node[:rust][:version]}"
|
38
|
+
|
39
|
+
if node[:rust][:user]
|
40
|
+
user node[:rust][:user]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
node.reverse_merge!(
|
2
|
+
rust: {
|
3
|
+
user: ENV["USER"],
|
4
|
+
},
|
5
|
+
)
|
6
|
+
|
7
|
+
unless node[:rust][:cargo_home]
|
8
|
+
user_dir =
|
9
|
+
case node[:platform]
|
10
|
+
when "osx", "darwin"
|
11
|
+
"/Users"
|
12
|
+
else
|
13
|
+
"/home"
|
14
|
+
end
|
15
|
+
|
16
|
+
node[:rust][:cargo_home] = File.join(user_dir, node[:rust][:user], ".cargo")
|
17
|
+
end
|
18
|
+
|
19
|
+
include_recipe "rust::install"
|
data/mrblib
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lib
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itamae-plugin-recipe-rust
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- sue445
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: itamae
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: docker-api
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: serverspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Itamae plugin to install Rust
|
98
|
+
email:
|
99
|
+
- sue445@sue445.net
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".rspec"
|
105
|
+
- CHANGELOG.md
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- itamae-plugin-recipe-rust.gemspec
|
111
|
+
- lib/itamae/plugin/recipe/rust.rb
|
112
|
+
- lib/itamae/plugin/recipe/rust/install.rb
|
113
|
+
- lib/itamae/plugin/recipe/rust/system.rb
|
114
|
+
- lib/itamae/plugin/recipe/rust/user.rb
|
115
|
+
- lib/itamae/plugin/recipe/rust/version.rb
|
116
|
+
- mrblib
|
117
|
+
homepage: https://github.com/itamae-plugins/itamae-plugin-recipe-rust
|
118
|
+
licenses:
|
119
|
+
- MIT
|
120
|
+
metadata:
|
121
|
+
homepage_uri: https://github.com/itamae-plugins/itamae-plugin-recipe-rust
|
122
|
+
source_code_uri: https://github.com/itamae-plugins/itamae-plugin-recipe-rust
|
123
|
+
changelog_uri: https://github.com/itamae-plugins/itamae-plugin-recipe-rust/blob/main/CHANGELOG.md
|
124
|
+
rubygems_mfa_required: 'true'
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 2.3.0
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubygems_version: 3.3.7
|
141
|
+
signing_key:
|
142
|
+
specification_version: 4
|
143
|
+
summary: Itamae plugin to install Rust
|
144
|
+
test_files: []
|