gembuild 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +26 -0
- data/.rspec +2 -0
- data/.travis.yml +15 -0
- data/CHANGELOG.md +15 -0
- data/Gemfile +3 -0
- data/LICENSE +675 -0
- data/README.md +80 -0
- data/Rakefile +14 -0
- data/bin/gembuild +10 -0
- data/gembuild.gemspec +45 -0
- data/lib/gembuild.rb +142 -0
- data/lib/gembuild/aur_scraper.rb +159 -0
- data/lib/gembuild/exceptions.rb +31 -0
- data/lib/gembuild/gem_scraper.rb +205 -0
- data/lib/gembuild/pkgbuild.erb +32 -0
- data/lib/gembuild/pkgbuild.rb +283 -0
- data/lib/gembuild/project.rb +167 -0
- data/lib/gembuild/version.rb +23 -0
- metadata +301 -0
@@ -0,0 +1,167 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Gembuild: create Arch Linux PKGBUILDs for ruby gems.
|
4
|
+
# Copyright (C) 2015 Mario Finelli <mario@finel.li>
|
5
|
+
#
|
6
|
+
# This program is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'English'
|
20
|
+
|
21
|
+
module Gembuild
|
22
|
+
# This class is mostly responsible for creating new AUR packages: checking
|
23
|
+
# out, adding files and committing to git.
|
24
|
+
#
|
25
|
+
# @!attribute [r] config
|
26
|
+
# @return [Hash] the response from Gembuild.configure
|
27
|
+
# @!attribute [r] full_path
|
28
|
+
# @return [String] the full local path to the project
|
29
|
+
# @!attribute [r] gemname
|
30
|
+
# @return [String] the name of the gem
|
31
|
+
# @!attribute [r] pkgdir
|
32
|
+
# @return [String] where repositories are checked out
|
33
|
+
# @!attribute [r] pkgname
|
34
|
+
# @return [String] the AUR package
|
35
|
+
class Project
|
36
|
+
attr_reader :config, :full_path, :gemname, :pkgdir, :pkgname
|
37
|
+
|
38
|
+
# A standard gitignore for new projects that only allows the following
|
39
|
+
# whitelisted files: itself, the PKGBUILD and the .SRCINFO.
|
40
|
+
GITIGNORE = "*\n!.gitignore\n!PKGBUILD\n!.SRCINFO\n"
|
41
|
+
|
42
|
+
# Return a new project instance.
|
43
|
+
#
|
44
|
+
# @param gemname [String] The ruby gem for which to create a project.
|
45
|
+
# @return [Gembuild::Project] the new project instance
|
46
|
+
def initialize(gemname)
|
47
|
+
@pkgname = "ruby-#{gemname}"
|
48
|
+
@gemname = gemname
|
49
|
+
|
50
|
+
@config = Gembuild.configure
|
51
|
+
@pkgdir = @config[:pkgdir]
|
52
|
+
@full_path = File.join(@pkgdir, @pkgname)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Git clone the project if it hasn't already been checked out. If it has
|
56
|
+
# then pull master to ensure the most recent update.
|
57
|
+
#
|
58
|
+
# @return [void]
|
59
|
+
def clone_and_update!
|
60
|
+
if File.directory?(full_path)
|
61
|
+
`cd #{full_path} && git checkout master && git pull origin master`
|
62
|
+
else
|
63
|
+
`git clone ssh://aur@aur4.archlinux.org/#{pkgname}.git #{full_path}`
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Write a standard gitignore file if none exists.
|
68
|
+
#
|
69
|
+
# @return [void]
|
70
|
+
def write_gitignore!
|
71
|
+
ignore_path = File.join(full_path, '.gitignore')
|
72
|
+
|
73
|
+
File.write(ignore_path, GITIGNORE) unless File.exist?(ignore_path)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Ensure that the git user and email address are correct for the
|
77
|
+
# repository.
|
78
|
+
#
|
79
|
+
# @param name [String] The user name to send to git.
|
80
|
+
# @param email [String] The user email to send to git.
|
81
|
+
# @return [void]
|
82
|
+
def configure_git!(name, email)
|
83
|
+
`cd #{full_path} && git config user.name "#{name}"`
|
84
|
+
`cd #{full_path} && git config user.email "#{email}"`
|
85
|
+
end
|
86
|
+
|
87
|
+
# Read into memory the PKGBUILD in the project's directory or an empty
|
88
|
+
# string if none exists.
|
89
|
+
#
|
90
|
+
# @return [String] the existing pkgbuild or an empty string
|
91
|
+
def load_existing_pkgbuild
|
92
|
+
pkgbuild_path = File.join(full_path, 'PKGBUILD')
|
93
|
+
|
94
|
+
if File.file?(pkgbuild_path)
|
95
|
+
File.read(pkgbuild_path)
|
96
|
+
else
|
97
|
+
''
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Update the package metadata with mksrcinfo and then stage all changes
|
102
|
+
# with git.
|
103
|
+
#
|
104
|
+
# @return [void]
|
105
|
+
def stage_changes!
|
106
|
+
`cd #{full_path} && mksrcinfo && git add .`
|
107
|
+
end
|
108
|
+
|
109
|
+
# Determine the commit message depending upon whether it's the initial
|
110
|
+
# commit or we're bumping the release.
|
111
|
+
#
|
112
|
+
# @param version [String] The version of the package to include in the
|
113
|
+
# commit message.
|
114
|
+
# @return [String] the appropriate commit message
|
115
|
+
def commit_message(version)
|
116
|
+
`cd #{full_path} && git rev-parse HEAD &> /dev/null`
|
117
|
+
|
118
|
+
if !$CHILD_STATUS.success?
|
119
|
+
'Initial commit'
|
120
|
+
else
|
121
|
+
"Bump version to #{version}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Commit the currently staged changeset.
|
126
|
+
#
|
127
|
+
# @param message [String] The requested commit message.
|
128
|
+
# @return [void]
|
129
|
+
def commit_changes!(message)
|
130
|
+
`cd #{full_path} && git commit -m "#{message}"`
|
131
|
+
end
|
132
|
+
|
133
|
+
# Get the gembuild configuration and ensure that the pkgdir exists
|
134
|
+
# creating it if necessary.
|
135
|
+
#
|
136
|
+
# @return [void]
|
137
|
+
def ensure_pkgdir!
|
138
|
+
FileUtils.mkdir_p(pkgdir) unless File.directory?(pkgdir)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Ensure that the project directory has been created and is up-to-date.
|
142
|
+
#
|
143
|
+
# @return [void]
|
144
|
+
def prepare_working_directory!
|
145
|
+
ensure_pkgdir!
|
146
|
+
clone_and_update!
|
147
|
+
write_gitignore!
|
148
|
+
configure_git!(config[:name], config[:email])
|
149
|
+
end
|
150
|
+
|
151
|
+
# Make sure that the working directory is created and up to date, and that
|
152
|
+
# git is configured for the project. Then create an updated PKGBUILD based
|
153
|
+
# on the most recent version of the gem and write it out. Generate the
|
154
|
+
# updated metadata using `mksrcinfo` and then commit all changes to git.
|
155
|
+
#
|
156
|
+
# @return [void]
|
157
|
+
def clone_and_commit!
|
158
|
+
prepare_working_directory!
|
159
|
+
|
160
|
+
pkgbuild = Gembuild::Pkgbuild.create(gemname, load_existing_pkgbuild)
|
161
|
+
pkgbuild.write(full_path)
|
162
|
+
|
163
|
+
stage_changes!
|
164
|
+
commit_changes!(commit_message(pkgbuild.pkgver))
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Gembuild: create Arch Linux PKGBUILDs for ruby gems.
|
4
|
+
# Copyright (C) 2015 Mario Finelli <mario@finel.li>
|
5
|
+
#
|
6
|
+
# This program is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# This program is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
# Create Arch Linux PKGBUILDs for ruby gems.
|
20
|
+
module Gembuild
|
21
|
+
# Current version of Gembuild.
|
22
|
+
VERSION = '1.0.0'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,301 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gembuild
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mario Finelli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mechanize
|
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: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: bundler
|
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: coveralls
|
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: mutant-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: pry
|
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
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: redcarpet
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rubocop-rspec
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubycritic
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: ruby-lint
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: simplecov
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: vcr
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: webmock
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: yard
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
251
|
+
description: Generate PKGBUILDs for ruby gems.
|
252
|
+
email:
|
253
|
+
- mario@finel.li
|
254
|
+
executables:
|
255
|
+
- gembuild
|
256
|
+
extensions: []
|
257
|
+
extra_rdoc_files: []
|
258
|
+
files:
|
259
|
+
- ".gitignore"
|
260
|
+
- ".rspec"
|
261
|
+
- ".travis.yml"
|
262
|
+
- CHANGELOG.md
|
263
|
+
- Gemfile
|
264
|
+
- LICENSE
|
265
|
+
- README.md
|
266
|
+
- Rakefile
|
267
|
+
- bin/gembuild
|
268
|
+
- gembuild.gemspec
|
269
|
+
- lib/gembuild.rb
|
270
|
+
- lib/gembuild/aur_scraper.rb
|
271
|
+
- lib/gembuild/exceptions.rb
|
272
|
+
- lib/gembuild/gem_scraper.rb
|
273
|
+
- lib/gembuild/pkgbuild.erb
|
274
|
+
- lib/gembuild/pkgbuild.rb
|
275
|
+
- lib/gembuild/project.rb
|
276
|
+
- lib/gembuild/version.rb
|
277
|
+
homepage: https://github.com/mfinelli/gembuild
|
278
|
+
licenses:
|
279
|
+
- GPL-3.0+
|
280
|
+
metadata: {}
|
281
|
+
post_install_message:
|
282
|
+
rdoc_options: []
|
283
|
+
require_paths:
|
284
|
+
- lib
|
285
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
286
|
+
requirements:
|
287
|
+
- - ">="
|
288
|
+
- !ruby/object:Gem::Version
|
289
|
+
version: '0'
|
290
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
291
|
+
requirements:
|
292
|
+
- - ">="
|
293
|
+
- !ruby/object:Gem::Version
|
294
|
+
version: '0'
|
295
|
+
requirements: []
|
296
|
+
rubyforge_project:
|
297
|
+
rubygems_version: 2.5.1
|
298
|
+
signing_key:
|
299
|
+
specification_version: 4
|
300
|
+
summary: Generate PKGBUILDs for ruby gems.
|
301
|
+
test_files: []
|