itamae-plugin-resource-aur_package 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 69fc586fadca9f5bfa53c7d2cd5856e69bcbde04faabe70e1eebab5a4d3db6a0
4
+ data.tar.gz: d51ec68a33fe7a264bdf66f36b0851f18a1d9f6279658d8f647fc91f745ad696
5
+ SHA512:
6
+ metadata.gz: ff2433f594a7c68eec8a52636dd79b19ef2a010b8d59d380596506221ed7e01e7d8143216f84dc3e3e4c57ba3dc488192445805480902fed61a550a9acffb182
7
+ data.tar.gz: 4517a3a7d8172904091f8b56a31ad3a8152b43daef3be435e75a0f93fa3c95c59f7d3aca042bded858b746f710b9e84d4c3b03993bbd3ef4532f54ebb50748b0
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ sudo: required
3
+ dist: xenial
4
+ services:
5
+ - docker
6
+ rvm:
7
+ - 2.6.3
8
+
9
+ before_install: gem install bundler
10
+ bundler_args: "--jobs=4"
11
+ cache: bundler
12
+ script:
13
+ - bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in itamae-plugin-resource-aur_package.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Itamae::Plugin::Resource::AurPackage
2
+
3
+ An Itamae resource for AUR (Arch User Repository)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'itamae-plugin-resource-aur_package'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install itamae-plugin-resource-aur_package
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ aur_package 'rbenv'
25
+ ```
26
+
27
+ Note: It uses `yay` if it is available. If not, it uses `makepkg`.
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pocke/itamae-plugin-resource-aur_package.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
3
+
4
+ desc "Run spec"
5
+ task :spec do
6
+ from_tag = 'itamae-plugin-resource-aur_package-from:from'
7
+ sh "docker build -t #{from_tag} spec/docker/"
8
+ to_tag = 'itamae-plugin-resource-aur_package:to'
9
+ sh 'bundle', 'exec', 'itamae', 'docker', 'spec/recipes/main.rb', "--image=#{from_tag}", "--tag=#{to_tag}", "--log-level=debug"
10
+ sh({ 'DOCKER_IMAGE' => to_tag }, "bundle", 'exec', 'rspec')
11
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "itamae/plugin/resource/aur_package"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "itamae-plugin-resource-aur_package"
6
+ spec.version = '0.1.0'
7
+ spec.authors = ["Masataka Pocke Kuwabara"]
8
+ spec.email = ["kuwabara@pocke.me"]
9
+
10
+ spec.summary = %q{An Itamae resource for AUR}
11
+ spec.description = %q{An Itamae resource for AUR (Arch User Repository)}
12
+ spec.homepage = "https://github.com/pocke/itamae-plugin-resource-aur_package"
13
+
14
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = spec.homepage
18
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_runtime_dependency "itamae"
30
+ spec.add_development_dependency "bundler", ">= 2"
31
+ spec.add_development_dependency "rake", "~> 12.0"
32
+ spec.add_development_dependency "docker-api"
33
+ spec.add_development_dependency "serverspec"
34
+ end
@@ -0,0 +1,75 @@
1
+ require 'itamae'
2
+
3
+ module Itamae
4
+ module Plugin
5
+ module Resource
6
+ class AurPackage < ::Itamae::Resource::Base
7
+ class NotSupportedError < StandardError
8
+ def initialize(os)
9
+ @os = os
10
+ end
11
+
12
+ def message
13
+ "AurPackage only supports Arch Linux, but it is #{@os[:family]}"
14
+ end
15
+ end
16
+
17
+ define_attribute :action, default: :install
18
+ define_attribute :name, type: String, default_name: true
19
+ define_attribute :options, type: String
20
+ define_attribute :version, type: String
21
+
22
+ def run
23
+ os = backend.instance_variable_get(:@backend).os_info
24
+ raise NotSupportedError.new(os) unless os[:family] == 'arch'
25
+
26
+ super
27
+ end
28
+
29
+ def pre_action
30
+ case @current_action
31
+ when :install
32
+ attributes.installed = true
33
+ when :remove
34
+ attributes.installed = false
35
+ end
36
+ end
37
+
38
+ def set_current_attributes
39
+ current.installed = run_specinfra(:check_package_is_installed, attributes.name)
40
+
41
+ if current.installed
42
+ current.version = run_specinfra(:get_package_version, attributes.name).stdout.strip
43
+ end
44
+ end
45
+
46
+ def action_install(action_options)
47
+ if run_specinfra(:check_package_is_installed, attributes.name, attributes.version)
48
+ return
49
+ end
50
+
51
+ yay_executable = run_command('which yay', error: false).exit_status == 0
52
+ if yay_executable
53
+ run_command("yay -S --noconfirm #{attributes.options} #{attributes.name}")
54
+ else
55
+ name = attributes.name
56
+ tmp_dir = "/tmp/itamae-plugin-resource-aur_package-#{name}-#{Time.now.to_f}"
57
+ run_command("mkdir #{tmp_dir}")
58
+ run_command("curl -L -O https://aur.archlinux.org/cgit/aur.git/snapshot/#{name}.tar.gz", cwd: tmp_dir)
59
+ run_command("tar -xvf #{name}.tar.gz", cwd: tmp_dir)
60
+ run_command("makepkg -si --noconfirm #{attributes.options}", cwd: "#{tmp_dir}/#{name}" )
61
+ run_command("rm -rf #{tmp_dir}")
62
+ end
63
+ updated!
64
+ end
65
+
66
+ def action_remove(action_options)
67
+ if run_specinfra(:check_package_is_installed, attributes.name, nil)
68
+ run_specinfra(:remove_package, attributes.name, attributes.options)
69
+ updated!
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itamae-plugin-resource-aur_package
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masataka Pocke Kuwabara
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-06-09 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: '2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: docker-api
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: serverspec
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
+ description: An Itamae resource for AUR (Arch User Repository)
84
+ email:
85
+ - kuwabara@pocke.me
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - Gemfile
93
+ - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/setup
97
+ - itamae-plugin-resource-aur_package.gemspec
98
+ - lib/itamae/plugin/resource/aur_package.rb
99
+ homepage: https://github.com/pocke/itamae-plugin-resource-aur_package
100
+ licenses: []
101
+ metadata:
102
+ homepage_uri: https://github.com/pocke/itamae-plugin-resource-aur_package
103
+ source_code_uri: https://github.com/pocke/itamae-plugin-resource-aur_package
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubygems_version: 3.0.3
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: An Itamae resource for AUR
123
+ test_files: []