gigamo-aurb 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +3 -0
- data/aurb.gemspec +3 -3
- data/bin/aurb +114 -62
- metadata +4 -4
data/README.rdoc
CHANGED
data/aurb.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'aurb'
|
3
|
-
s.version = '0.8.
|
4
|
-
s.date = %q{2009-05-
|
5
|
-
s.summary = %q{
|
3
|
+
s.version = '0.8.3'
|
4
|
+
s.date = %q{2009-05-07}
|
5
|
+
s.summary = %q{An AUR utility written in Ruby}
|
6
6
|
s.email = %q{gigamo@gmail.com}
|
7
7
|
s.homepage = %q{http://github.com/gigamo/aurb}
|
8
8
|
s.description = s.summary
|
data/bin/aurb
CHANGED
@@ -17,40 +17,70 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
18
18
|
#--
|
19
19
|
# Inspired by arson (http://evaryont.github.com/arson)
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
require 'rubygems'
|
21
|
+
|
22
|
+
{
|
23
|
+
:getopt => ['getoptlong', true ],
|
24
|
+
:pathname => ['pathname', false],
|
25
|
+
:zlib => ['zlib', true ],
|
26
|
+
:openuri => ['open-uri', true ],
|
27
|
+
:json => ['json', true ],
|
28
|
+
:highline => ['highline/import', false],
|
29
|
+
:ansicode => ['facets/ansicode', false],
|
30
|
+
:minitar => ['facets/minitar', true ],
|
31
|
+
:version => ['facets/version', true ],
|
32
|
+
}.each do |key, info|
|
33
|
+
path, required = info[0, 2]
|
34
|
+
$have_lib ||= {}
|
35
|
+
|
36
|
+
begin
|
37
|
+
require path
|
38
|
+
$have_lib[key] = true
|
39
|
+
rescue LoadError
|
40
|
+
if required
|
41
|
+
abort <<-ERR
|
42
|
+
You're missing '#{lib}'.
|
43
|
+
Please make sure you have the necessary rubygems installed.
|
44
|
+
ERR
|
45
|
+
else
|
46
|
+
$have_lib[key] = false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
23
50
|
|
24
51
|
module Aurb
|
25
52
|
# Default download path
|
26
53
|
DlPath = File.join ENV['HOME'], 'abs'
|
27
54
|
|
28
55
|
# Program info
|
29
|
-
PrInfo = {:name => 'Aurb', :version => [0, 8,
|
56
|
+
PrInfo = {:name => 'Aurb', :version => [0, 8, 3].join('.'), :release => '2009-05-07'}
|
30
57
|
|
31
58
|
class << self
|
32
59
|
def aur
|
33
60
|
@aur ||= Aur.new \
|
34
|
-
:rpc => proc {|
|
61
|
+
:rpc => proc {|type, arg| "http://aur.archlinux.org/rpc.php?type=#{type}&arg=#{arg}"}
|
35
62
|
end
|
36
63
|
end
|
37
64
|
|
38
65
|
module Util
|
39
|
-
def set_trap
|
40
|
-
trap(:INT) {abort "\nInterrupt signal received\n\n"}
|
41
|
-
end
|
42
|
-
|
43
66
|
def ansi text, effect
|
44
|
-
|
67
|
+
if @config[:color] && $have_lib[:ansicode]
|
68
|
+
text = ANSICode.send(effect.to_sym) << text.to_s << ANSICode.clear
|
69
|
+
end
|
45
70
|
text
|
46
71
|
end
|
47
72
|
|
48
73
|
def yes_or_no? question
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
74
|
+
if $have_lib[:highline]
|
75
|
+
ask question, lambda {|yn| yn.downcase[0] == ?y} do |q|
|
76
|
+
q.readline = true
|
77
|
+
q.validate = /\Ay(?:es)?|no?\Z/i
|
78
|
+
q.responses[:not_valid] = 'Yes or no, please'
|
79
|
+
end
|
80
|
+
else
|
81
|
+
$stdout.print question
|
82
|
+
answer = $stdin.gets.chomp
|
83
|
+
answer =~ /\Ay(?:es)?|no?\Z/i
|
54
84
|
end
|
55
85
|
end
|
56
86
|
end
|
@@ -58,52 +88,54 @@ module Aurb
|
|
58
88
|
class Aur
|
59
89
|
include Aurb::Util
|
60
90
|
|
61
|
-
def initialize config
|
62
|
-
@opts = Opts.new
|
63
|
-
@config = config.merge(@opts.config)
|
64
|
-
end
|
65
|
-
|
66
91
|
def start
|
67
|
-
|
92
|
+
trap :INT do
|
93
|
+
$stderr.puts "\nInterrupt signal received\n\n"
|
94
|
+
exit 0
|
95
|
+
end
|
96
|
+
|
68
97
|
@opts.cmd.each do |cmd|
|
69
|
-
|
70
|
-
|
98
|
+
cmd.length == 1 ? __send__(cmd.first) : __send__(cmd.first, cmd.last)
|
99
|
+
$stdout.puts "\n\n-----" unless cmd == @opts.cmd.last
|
71
100
|
end
|
72
101
|
end
|
73
102
|
|
103
|
+
def initialize config
|
104
|
+
@opts = Opts.new
|
105
|
+
@config = config.merge(@opts.config)
|
106
|
+
end
|
107
|
+
|
74
108
|
def download packages
|
75
|
-
packages = packages.split
|
76
109
|
packages.delete_if {|pkg| in_sync?(pkg)}
|
77
|
-
abort '
|
110
|
+
abort 'ERROR: No package(s) to download. Possibly the package(s) you ' +
|
78
111
|
'specified was/were found in the community repository?' if packages.empty?
|
112
|
+
|
79
113
|
say "Targets (#{ansi packages.length, :magenta}): #{packages.join(', ')}"
|
80
|
-
if yes_or_no? 'Proceed? '
|
114
|
+
if yes_or_no? 'Proceed? [yn] '
|
81
115
|
packages.each do |package|
|
82
116
|
begin
|
83
|
-
|
117
|
+
Dir.chdir @config[:path] do
|
84
118
|
fetch package
|
85
119
|
untar package
|
86
120
|
end
|
87
|
-
rescue OpenURI::HTTPError
|
88
|
-
|
89
|
-
"---\n#{e.message}"
|
121
|
+
rescue OpenURI::HTTPError
|
122
|
+
$stderr.puts "Something went wrong downloading '#{package}'. Are you sure it exists?"
|
90
123
|
package == packages.last ? exit : next
|
91
124
|
end
|
92
|
-
|
125
|
+
$stdout.puts "(#{packages.index(package)+1}/#{packages.length}) downloaded #{package}"
|
93
126
|
end
|
94
127
|
end
|
95
128
|
end
|
96
129
|
|
97
130
|
def search packages
|
98
|
-
packages = packages.split
|
99
131
|
packages.each do |package|
|
100
|
-
list(package).each do |
|
101
|
-
result = json @config[:rpc]['info',
|
132
|
+
list(package).each do |id|
|
133
|
+
result = json @config[:rpc]['info', id]
|
102
134
|
unless result['type'] =~ /error/
|
103
135
|
result = result['results']
|
104
136
|
next if in_sync? result['Name']
|
105
137
|
if package.any? {|pac| result['Name'].include?(pac) || result['Description'].include?(pac)}
|
106
|
-
|
138
|
+
$stdout.puts "[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] " +
|
107
139
|
"#{ansi result['Name'], :blue} (#{result['Version']})\n #{result['Description']}"
|
108
140
|
end
|
109
141
|
end
|
@@ -112,8 +144,7 @@ module Aurb
|
|
112
144
|
end
|
113
145
|
|
114
146
|
def check_upgrade
|
115
|
-
upgradable
|
116
|
-
say 'Searching for updates'
|
147
|
+
upgradable ||= []
|
117
148
|
IO.popen('pacman -Qm', IO::RDONLY) {|pm| pm.read.lines}.each do |line|
|
118
149
|
name, version = line.chomp.split
|
119
150
|
result = json @config[:rpc]['info', name]
|
@@ -122,11 +153,11 @@ module Aurb
|
|
122
153
|
next if in_sync? result['Name']
|
123
154
|
if VersionNumber.new(result['Version']) > VersionNumber.new(version)
|
124
155
|
upgradable << result['Name']
|
125
|
-
|
156
|
+
$stdout.puts "> #{name}: #{ansi version, :red} => #{ansi result['Version'], :green}"
|
126
157
|
end
|
127
158
|
end
|
128
159
|
end
|
129
|
-
upgradable.any? ? (
|
160
|
+
upgradable.any? ? ($stdout.puts; download upgradable) : ($stdout.puts 'Nothing to update')
|
130
161
|
end
|
131
162
|
|
132
163
|
private
|
@@ -135,10 +166,10 @@ module Aurb
|
|
135
166
|
end
|
136
167
|
|
137
168
|
def list package
|
138
|
-
|
169
|
+
list, info = [], json(@config[:rpc]['search', URI.escape(package)])
|
139
170
|
unless info['type'] =~ /error/
|
140
171
|
info['results'].each do |result|
|
141
|
-
list <<
|
172
|
+
list << result['ID']
|
142
173
|
end
|
143
174
|
end
|
144
175
|
list.sort
|
@@ -157,7 +188,7 @@ module Aurb
|
|
157
188
|
Zlib::GzipReader.new(File.open("#{package}.tar.gz", 'rb')),
|
158
189
|
Dir.pwd
|
159
190
|
|
160
|
-
|
191
|
+
File.delete "#{package}.tar.gz"
|
161
192
|
end
|
162
193
|
|
163
194
|
def json item
|
@@ -166,14 +197,13 @@ module Aurb
|
|
166
197
|
end
|
167
198
|
|
168
199
|
class Opts
|
169
|
-
attr_reader :config
|
170
|
-
attr_reader :cmd
|
200
|
+
attr_reader :config, :cmd
|
171
201
|
|
172
202
|
def initialize
|
173
|
-
@config = {:path => DlPath, :color => true}
|
174
|
-
@cmd = []
|
203
|
+
@config, @cmd = {:path => DlPath, :color => true}, []
|
175
204
|
|
176
205
|
parse!
|
206
|
+
self
|
177
207
|
end
|
178
208
|
|
179
209
|
private
|
@@ -190,24 +220,33 @@ module Aurb
|
|
190
220
|
|
191
221
|
gopts.each do |opt, arg|
|
192
222
|
case opt
|
193
|
-
when '--download' then @cmd <<
|
194
|
-
when '--search' then @cmd <<
|
195
|
-
when '--upgrade' then @cmd << 'check_upgrade'
|
223
|
+
when '--download' then @cmd << ['download', arg.split]
|
224
|
+
when '--search' then @cmd << ['search', arg.split]
|
225
|
+
when '--upgrade' then @cmd << ['check_upgrade']
|
196
226
|
when '--no-color' then @config[:color] = false
|
197
227
|
when '--path' then
|
198
228
|
if File.exists? arg = (arg[0...1] == '/' ? arg : File.join(Dir.pwd, arg))
|
199
|
-
@config[:path] = Pathname.new(arg).realpath
|
229
|
+
@config[:path] = Pathname.new(arg).realpath || File.expand_path(arg)
|
200
230
|
else
|
201
231
|
warn "WARN: '#{arg}' does not exist. Fell back to [#{@config[:path]}]\n"
|
202
232
|
end
|
203
|
-
when '--version' then
|
204
|
-
|
205
|
-
|
206
|
-
|
233
|
+
when '--version' then $stderr.puts '%s %s (%s)' %
|
234
|
+
[
|
235
|
+
:name, :version, :release
|
236
|
+
].map {|key| PrInfo[key]}
|
237
|
+
exit -1
|
238
|
+
when '--help' then print_help
|
239
|
+
end
|
240
|
+
end
|
241
|
+
rescue GetoptLong::Error; exit 2
|
242
|
+
end
|
243
|
+
|
244
|
+
def print_help out = $stderr
|
245
|
+
out.puts <<-HELP
|
207
246
|
Aurb - An AUR utility written in Ruby.
|
208
247
|
|
209
248
|
Usage:
|
210
|
-
#{File.basename $0} [options]
|
249
|
+
#{name = File.basename $0} [options]
|
211
250
|
|
212
251
|
Options (Required):
|
213
252
|
-d, --download PACKAGE Download a package.
|
@@ -215,13 +254,26 @@ Options (Required):
|
|
215
254
|
-u, --upgrade Search for package updates.
|
216
255
|
|
217
256
|
Optional:
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
257
|
+
--no-color Disable colored output.
|
258
|
+
--path [PATH] Override the default save path. [#{@config[:path]}]
|
259
|
+
|
260
|
+
Other:
|
261
|
+
--version Show version and exit.
|
262
|
+
--help This message.
|
263
|
+
|
264
|
+
Examples:
|
265
|
+
#{name} -d 'package1 package2' --path ~/downloads
|
266
|
+
#{name} -s 'package1 package2' --no-color
|
267
|
+
#{name} --upgrade
|
268
|
+
|
269
|
+
You can also chain commands, like so:
|
270
|
+
|
271
|
+
#{name} -d 'thispackage' -s 'thatpackage' -u
|
272
|
+
|
273
|
+
Aurb was inspired by arson. Do have a look at http://evaryont.github.com/arson
|
274
|
+
For further information you can contact the author at <gigamo@gmail.com>.
|
275
|
+
HELP
|
276
|
+
exit -1
|
225
277
|
end
|
226
278
|
end
|
227
279
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gigamo-aurb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gigamo
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-07 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: "0"
|
44
44
|
version:
|
45
|
-
description:
|
45
|
+
description: An AUR utility written in Ruby
|
46
46
|
email: gigamo@gmail.com
|
47
47
|
executables:
|
48
48
|
- aurb
|
@@ -84,6 +84,6 @@ rubyforge_project: aurb
|
|
84
84
|
rubygems_version: 1.2.0
|
85
85
|
signing_key:
|
86
86
|
specification_version: 2
|
87
|
-
summary:
|
87
|
+
summary: An AUR utility written in Ruby
|
88
88
|
test_files: []
|
89
89
|
|