gigamo-aurb 0.7.2 → 0.8.1
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 +1 -1
- data/aurb.gemspec +3 -3
- data/bin/aurb +144 -85
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -5,7 +5,7 @@ See <tt>aurb --help</tt> for a full list of commands.
|
|
5
5
|
=== Overview
|
6
6
|
|
7
7
|
<b>--upgrade</b>:: Searches the AUR for upgrades to local packages that don't exist in any official repository
|
8
|
-
<b>--download</b>:: Downloads your specified package from the AUR and untars it
|
8
|
+
<b>--download</b>:: Downloads your specified package(s) from the AUR and untars it
|
9
9
|
<b>--search</b>:: Searches the AUR for a specified name or description
|
10
10
|
|
11
11
|
== Installation
|
data/aurb.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'aurb'
|
3
|
-
s.version = '0.
|
4
|
-
s.date = %q{2009-
|
3
|
+
s.version = '0.8.1'
|
4
|
+
s.date = %q{2009-05-03}
|
5
5
|
s.summary = %q{A simple AUR utility}
|
6
6
|
s.email = %q{gigamo@gmail.com}
|
7
7
|
s.homepage = %q{http://github.com/gigamo/aurb}
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.rubyforge_project = %q{aurb}
|
10
10
|
s.executables = ['aurb']
|
11
11
|
s.has_rdoc = true
|
12
|
-
s.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'Aurb', '--main', 'README']
|
12
|
+
s.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'Aurb', '--main', 'README.rdoc']
|
13
13
|
s.authors = ['Gigamo']
|
14
14
|
s.files = ['bin/aurb', 'aurb.gemspec', 'README.rdoc']
|
15
15
|
s.add_dependency 'json'
|
data/bin/aurb
CHANGED
@@ -1,52 +1,56 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
#++
|
3
|
+
# Copyright (C) 2009 Gigamo
|
2
4
|
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# / _` | | | | '__| '_ \
|
8
|
-
# | (_| | |_| | | | |_) |
|
9
|
-
# \__,_|\__,_|_| |_.__/
|
5
|
+
# This program is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU General Public License
|
7
|
+
# as published by the Free Software Foundation; either version 2
|
8
|
+
# of the License, or (at your option) any later version.
|
10
9
|
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
11
14
|
#
|
12
|
-
#
|
13
|
-
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
18
|
+
#--
|
19
|
+
# Inspired by arson (http://evaryont.github.com/arson)
|
14
20
|
|
15
|
-
%w[
|
21
|
+
%w[getoptlong pathname fileutils zlib open-uri rubygems json highline/import
|
16
22
|
facets/ansicode facets/minitar facets/version].each {|lib| require lib}
|
17
23
|
|
18
24
|
module Aurb
|
19
|
-
#
|
25
|
+
# Default download path
|
20
26
|
DlPath = File.join ENV['HOME'], 'abs'
|
21
27
|
|
22
|
-
# Program
|
23
|
-
PrInfo = {:name => 'Aurb', :version => [0,
|
28
|
+
# Program info
|
29
|
+
PrInfo = {:name => 'Aurb', :version => [0, 8, 1].join('.'), :release => '2009-05-03'}
|
24
30
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
class << self
|
32
|
+
def aur
|
33
|
+
@aur ||= Aur.new \
|
34
|
+
:rpc => proc {|t, a| "http://aur.archlinux.org/rpc.php?type=#{t}&arg=#{a}"}
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
38
|
module Util
|
33
|
-
def
|
34
|
-
|
35
|
-
exit code.to_i
|
39
|
+
def set_trap
|
40
|
+
trap(:INT) {abort "\nInterrupt signal received\n\n"}
|
36
41
|
end
|
37
|
-
module_function :die
|
38
42
|
|
39
43
|
def ansi text, effect
|
40
|
-
text = ANSICode.send(effect.to_sym) << text << ANSICode.clear if @
|
44
|
+
text = ANSICode.send(effect.to_sym) << text.to_s << ANSICode.clear if @config[:color]
|
41
45
|
text
|
42
46
|
end
|
43
47
|
|
44
48
|
def yes_or_no? question
|
45
|
-
ask
|
49
|
+
ask question, lambda {|yn| yn.downcase[0] == ?y} do |q|
|
46
50
|
q.readline = true
|
47
51
|
q.default = 'y'
|
48
52
|
q.validate = /\Ay(?:es)?|no?\Z/i
|
49
|
-
q.responses[:not_valid] = 'Yes or no, please
|
53
|
+
q.responses[:not_valid] = 'Yes or no, please'
|
50
54
|
end
|
51
55
|
end
|
52
56
|
end
|
@@ -56,50 +60,49 @@ module Aurb
|
|
56
60
|
|
57
61
|
def initialize config
|
58
62
|
@opts = Opts.new
|
59
|
-
@config = config.merge
|
63
|
+
@config = config.merge(@opts.config)
|
60
64
|
end
|
61
65
|
|
62
66
|
def start
|
63
|
-
|
67
|
+
set_trap
|
64
68
|
instance_eval @opts.cmd
|
65
69
|
end
|
66
70
|
|
67
|
-
def download
|
68
|
-
packages = packages.
|
69
|
-
|
70
|
-
# Don't download a package if it's found in community
|
71
|
+
def download packages
|
72
|
+
packages = packages.split
|
71
73
|
packages.delete_if {|pkg| in_sync?(pkg)}
|
72
|
-
|
73
|
-
'specified was/were found in the community repository
|
74
|
-
|
75
|
-
say "Targets (#{ansi "#{packages.length}", :magenta}): #{packages.join(', ')}"
|
74
|
+
abort 'FATAL: No package(s) to download. Possibly the package(s) you ' +
|
75
|
+
'specified was/were found in the community repository?' if packages.empty?
|
76
|
+
say "Targets (#{ansi packages.length, :magenta}): #{packages.join(', ')}"
|
76
77
|
|
77
78
|
if yes_or_no? 'Proceed? '
|
78
79
|
packages.each do |package|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
untar package
|
84
|
-
end
|
85
|
-
say "(#{packages.index(package)+1}/#{packages.length}) downloaded #{package}"
|
80
|
+
begin
|
81
|
+
FileUtils.cd @config[:path] do
|
82
|
+
fetch package
|
83
|
+
untar package
|
86
84
|
end
|
85
|
+
rescue OpenURI::HTTPError
|
86
|
+
say "Something went wrong downloading '#{package}'. Are you sure it exists?"
|
87
|
+
package == packages.last ? exit : next
|
87
88
|
end
|
89
|
+
|
90
|
+
say "(#{packages.index(package)+1}/#{packages.length}) downloaded #{package}"
|
88
91
|
end
|
89
92
|
end
|
90
93
|
end
|
91
94
|
|
92
95
|
def search package
|
93
96
|
list(package).each do |names|
|
94
|
-
result = json
|
97
|
+
result = json @config[:rpc]['info', names.last]
|
95
98
|
|
96
99
|
unless result['type'] =~ /error/
|
97
100
|
result = result['results']
|
98
101
|
next if in_sync? result['Name']
|
99
102
|
|
100
|
-
if package.any? {|pac|
|
103
|
+
if package.any? {|pac| result['Name'].include?(pac) || result['Description'].include?(pac)}
|
101
104
|
say "[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] " +
|
102
|
-
"#{ansi result['Name'], :blue} (#{result['Version']})
|
105
|
+
"#{ansi result['Name'], :blue} (#{result['Version']})\n #{result['Description']}"
|
103
106
|
end
|
104
107
|
end
|
105
108
|
end
|
@@ -107,11 +110,11 @@ module Aurb
|
|
107
110
|
|
108
111
|
def check_upgrade
|
109
112
|
upgradable = []
|
110
|
-
|
111
113
|
say 'Searching for updates'
|
112
|
-
|
114
|
+
|
115
|
+
IO.popen('pacman -Qm', IO::RDONLY) {|pm| pm.read.lines}.each do |line|
|
113
116
|
name, version = line.chomp.split
|
114
|
-
result = json
|
117
|
+
result = json @config[:rpc]['info', name]
|
115
118
|
|
116
119
|
unless result['type'] =~ /error/
|
117
120
|
result = result['results']
|
@@ -124,7 +127,7 @@ module Aurb
|
|
124
127
|
end
|
125
128
|
end
|
126
129
|
|
127
|
-
upgradable.any? ? download
|
130
|
+
upgradable.any? ? (say "\n"; download upgradable) : say('Nothing to update')
|
128
131
|
end
|
129
132
|
|
130
133
|
private
|
@@ -133,7 +136,7 @@ module Aurb
|
|
133
136
|
end
|
134
137
|
|
135
138
|
def list package
|
136
|
-
info, list = json(@config[:
|
139
|
+
info, list = json(@config[:rpc]['search', URI.escape(package)]), []
|
137
140
|
|
138
141
|
unless info['type'] =~ /error/
|
139
142
|
info['results'].each do |result|
|
@@ -145,22 +148,22 @@ module Aurb
|
|
145
148
|
end
|
146
149
|
|
147
150
|
def fetch package
|
148
|
-
|
149
|
-
|
150
|
-
open("http://aur.archlinux.org/packages/#{package}/#{package}.tar.gz") do |remote|
|
151
|
-
File.open("#{package}.tar.gz", 'wb') do |local|
|
151
|
+
open "http://aur.archlinux.org/packages/#{package}/#{package}.tar.gz" do |remote|
|
152
|
+
File.open "#{package}.tar.gz", 'wb' do |local|
|
152
153
|
local.write remote.read
|
153
154
|
end
|
154
155
|
end
|
155
156
|
end
|
156
157
|
|
157
158
|
def untar package
|
158
|
-
|
159
|
-
|
159
|
+
abort "FATAL: #{package}.tar.gz not found for untar" \
|
160
|
+
unless File.exists? "#{package}.tar.gz" # This should never, ever happen.
|
160
161
|
|
161
162
|
Archive::Tar::Minitar.unpack \
|
162
163
|
Zlib::GzipReader.new(File.open("#{package}.tar.gz", 'rb')),
|
163
164
|
Dir.pwd
|
165
|
+
|
166
|
+
FileUtils.rm "#{package}.tar.gz" if File.exists? "#{package}.tar.gz"
|
164
167
|
end
|
165
168
|
|
166
169
|
def json item
|
@@ -169,13 +172,10 @@ module Aurb
|
|
169
172
|
end
|
170
173
|
|
171
174
|
class Opts
|
172
|
-
attr_reader :cmd, :config
|
175
|
+
attr_reader :cmd, :config
|
173
176
|
|
174
177
|
def initialize
|
175
|
-
|
176
|
-
@config = {}
|
177
|
-
@color = true
|
178
|
-
|
178
|
+
@config = {:path => DlPath, :color => true}
|
179
179
|
# Parse zeh ARGV!
|
180
180
|
parse!
|
181
181
|
end
|
@@ -184,34 +184,54 @@ module Aurb
|
|
184
184
|
include Aurb::Util
|
185
185
|
|
186
186
|
def parse!
|
187
|
-
|
188
|
-
|
189
|
-
|
187
|
+
if ARGV.empty?
|
188
|
+
abort 'No argument given. Try --help.'
|
189
|
+
end
|
190
190
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
191
|
+
gopts = GetoptLong.new \
|
192
|
+
['--download', '-d', GetoptLong::REQUIRED_ARGUMENT],
|
193
|
+
['--search', '-s', GetoptLong::REQUIRED_ARGUMENT],
|
194
|
+
['--upgrade', '-u', GetoptLong::NO_ARGUMENT],
|
195
|
+
['--color', GetoptLong::NO_ARGUMENT],
|
196
|
+
['--path', GetoptLong::OPTIONAL_ARGUMENT],
|
197
|
+
['--version', '-v', GetoptLong::NO_ARGUMENT],
|
198
|
+
['--help', '-h', GetoptLong::NO_ARGUMENT]
|
199
|
+
|
200
|
+
gopts.each do |opt, arg|
|
201
|
+
case opt
|
202
|
+
when '--download' then @cmd = "download '#{arg}'"
|
203
|
+
when '--search' then @cmd = "search '#{arg}'"
|
204
|
+
when '--upgrade' then @cmd = 'check_upgrade'
|
205
|
+
when '--color' then @config[:color] = !@config[:color]
|
206
|
+
when '--path' then
|
207
|
+
if File.exists? arg = (arg[0...1] == '/' ? arg : File.join(Dir.pwd, arg))
|
208
|
+
@config[:path] = Pathname.new(arg).realpath
|
205
209
|
else
|
206
|
-
|
210
|
+
warn "WARN: '#{arg}' does not exist. Fell back to [#{@config[:path]}]\n"
|
207
211
|
end
|
212
|
+
when '--version' then abort '%s %s (%s)' % [
|
213
|
+
:name, :version, :release
|
214
|
+
].map {|key| PrInfo[key]}
|
215
|
+
when '--help' then abort <<HELP
|
216
|
+
Aurb - An AUR utility written in Ruby.
|
217
|
+
|
218
|
+
Usage:
|
219
|
+
#$0 [options]
|
220
|
+
|
221
|
+
Options (Required):
|
222
|
+
-d, --download PACKAGE Download a package.
|
223
|
+
-s, --search PACKAGE Search for package(s).
|
224
|
+
-u, --upgrade Search for package updates.
|
225
|
+
|
226
|
+
Optional:
|
227
|
+
--color Use colors? [#{@config[:color]}]
|
228
|
+
--path [PATH] Override the default save path. [#{@config[:path]}]
|
229
|
+
--version Show version and exit.
|
230
|
+
HELP
|
208
231
|
end
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
end.parse! @@args
|
213
|
-
rescue OptionParser::ParseError
|
214
|
-
die 'I.. I think you broke it...'
|
232
|
+
end
|
233
|
+
rescue GetoptLong::Error
|
234
|
+
abort $!.message
|
215
235
|
end
|
216
236
|
end
|
217
237
|
end
|
@@ -222,3 +242,42 @@ at_exit do
|
|
222
242
|
Aurb.aur.start
|
223
243
|
end
|
224
244
|
end
|
245
|
+
|
246
|
+
__END__
|
247
|
+
|
248
|
+
=head1 NAME
|
249
|
+
|
250
|
+
Aurb - A Ruby AUR Utility
|
251
|
+
|
252
|
+
=head1 SYNOPSIS
|
253
|
+
|
254
|
+
aurb --help
|
255
|
+
|
256
|
+
=head1 DESCRIPTION
|
257
|
+
|
258
|
+
Aurb is a small AUR utility written in Ruby. It can download and search for packages,
|
259
|
+
and search the AUR for updates to local packages. Run aurb -h for more information.
|
260
|
+
|
261
|
+
=head1 AUTHOR
|
262
|
+
|
263
|
+
Gigamo <lt>gigamo at gmail dot com<gt>
|
264
|
+
|
265
|
+
=head1 COPYRIGHT AND LICENSE
|
266
|
+
|
267
|
+
Copyright (C) 2009 Gigamo
|
268
|
+
|
269
|
+
This program is free software; you can redistribute it and/or
|
270
|
+
modify it under the terms of the GNU General Public License
|
271
|
+
as published by the Free Software Foundation; either version 2
|
272
|
+
of the License, or (at your option) any later version.
|
273
|
+
|
274
|
+
This program is distributed in the hope that it will be useful,
|
275
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
276
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
277
|
+
GNU General Public License for more details.
|
278
|
+
|
279
|
+
You should have received a copy of the GNU General Public License
|
280
|
+
along with this program; if not, write to the Free Software
|
281
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
282
|
+
|
283
|
+
=cut
|
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.
|
4
|
+
version: 0.8.1
|
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-
|
12
|
+
date: 2009-05-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -63,7 +63,7 @@ rdoc_options:
|
|
63
63
|
- --title
|
64
64
|
- Aurb
|
65
65
|
- --main
|
66
|
-
- README
|
66
|
+
- README.rdoc
|
67
67
|
require_paths:
|
68
68
|
- lib
|
69
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|