gigamo-aurb 0.6.3 → 0.7.2
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 +41 -0
- data/aurb.gemspec +3 -3
- data/bin/aurb +73 -45
- metadata +3 -3
- data/README +0 -11
data/README.rdoc
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
== Usage
|
2
|
+
|
3
|
+
See <tt>aurb --help</tt> for a full list of commands.
|
4
|
+
|
5
|
+
=== Overview
|
6
|
+
|
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
|
9
|
+
<b>--search</b>:: Searches the AUR for a specified name or description
|
10
|
+
|
11
|
+
== Installation
|
12
|
+
|
13
|
+
Quick and dirty:
|
14
|
+
|
15
|
+
# ruby setup.rb all
|
16
|
+
|
17
|
+
Or you can install it in ~/bin:
|
18
|
+
|
19
|
+
% ruby setup.rb config --bindir=$HOME/bin
|
20
|
+
% ruby setup.rb install
|
21
|
+
|
22
|
+
For more information about setup.rb, see <tt>ruby setup.rb --help</tt>.
|
23
|
+
|
24
|
+
If you prefer RubyGems:
|
25
|
+
|
26
|
+
% gem build aurb.gemspec
|
27
|
+
# gem install aurb-0.7.2.gem
|
28
|
+
|
29
|
+
There is also a github gem available:
|
30
|
+
|
31
|
+
% gem sources -a http://gems.github.com/ (you only need to do this once)
|
32
|
+
# gem install gigamo-aurb
|
33
|
+
|
34
|
+
=== Dependencies
|
35
|
+
|
36
|
+
Aurb requires the 'facets', 'json' and 'highline' rubygems to be installed.
|
37
|
+
|
38
|
+
== Todo
|
39
|
+
|
40
|
+
* Automatically build (and install) the package after download?
|
41
|
+
* Add dependency checking/downloading?
|
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-04-
|
3
|
+
s.version = '0.7.2'
|
4
|
+
s.date = %q{2009-04-24}
|
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}
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.has_rdoc = true
|
12
12
|
s.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'Aurb', '--main', 'README']
|
13
13
|
s.authors = ['Gigamo']
|
14
|
-
s.files = ['bin/aurb', 'aurb.gemspec', 'README']
|
14
|
+
s.files = ['bin/aurb', 'aurb.gemspec', 'README.rdoc']
|
15
15
|
s.add_dependency 'json'
|
16
16
|
s.add_dependency 'facets'
|
17
17
|
s.add_dependency 'highline'
|
data/bin/aurb
CHANGED
@@ -1,56 +1,80 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# Author:: Gigamo <gigamo@gmail.com>
|
3
|
-
# License:: Do whatever you want
|
4
2
|
#
|
3
|
+
# Author:: Gigamo <gigamo@gmail.com>
|
4
|
+
# _
|
5
|
+
# | |
|
6
|
+
# __ _ _ _ _ __| |__
|
7
|
+
# / _` | | | | '__| '_ \
|
8
|
+
# | (_| | |_| | | | |_) |
|
9
|
+
# \__,_|\__,_|_| |_.__/
|
10
|
+
#
|
11
|
+
#
|
12
|
+
# A Ruby AUR (Arch User Repository) utility.
|
13
|
+
#
|
14
|
+
|
5
15
|
%w[optparse pathname fileutils zlib open-uri rubygems cgi json highline/import
|
6
|
-
facets/ansicode facets/minitar facets/version].each {
|
16
|
+
facets/ansicode facets/minitar facets/version].each {|lib| require lib}
|
7
17
|
|
8
18
|
module Aurb
|
9
|
-
|
10
19
|
# Path where PKGBUILDS will get saved to
|
11
|
-
DlPath = File.join
|
20
|
+
DlPath = File.join ENV['HOME'], 'abs'
|
12
21
|
|
13
22
|
# Program Info
|
14
|
-
PrInfo = {:name => 'Aurb', :version => [0,
|
23
|
+
PrInfo = {:name => 'Aurb', :version => [0, 7, 2].join('.'), :release => '2009-04-24'}
|
15
24
|
|
16
25
|
def self.aur
|
17
26
|
@aur ||= Aur.new \
|
18
27
|
:search => proc {|t| "http://aur.archlinux.org/rpc.php?type=search&arg=#{t}"},
|
19
|
-
|
20
|
-
|
28
|
+
:info => proc {|t| "http://aur.archlinux.org/rpc.php?type=info&arg=#{t}"},
|
29
|
+
:path => Pathname.new(DlPath).realpath
|
21
30
|
end
|
22
31
|
|
23
32
|
module Util
|
33
|
+
def die message, code = 1
|
34
|
+
say message
|
35
|
+
exit code.to_i
|
36
|
+
end
|
37
|
+
module_function :die
|
38
|
+
|
24
39
|
def ansi text, effect
|
25
40
|
text = ANSICode.send(effect.to_sym) << text << ANSICode.clear if @opts.color
|
26
41
|
text
|
27
42
|
end
|
43
|
+
|
44
|
+
def yes_or_no? question
|
45
|
+
ask(question, lambda {|yn| yn.downcase[0] == ?y}) do |q|
|
46
|
+
q.readline = true
|
47
|
+
q.default = 'y'
|
48
|
+
q.validate = /\Ay(?:es)?|no?\Z/i
|
49
|
+
q.responses[:not_valid] = 'Yes or no, please.'
|
50
|
+
end
|
51
|
+
end
|
28
52
|
end
|
29
53
|
|
30
54
|
class Aur
|
31
55
|
include Aurb::Util
|
32
56
|
|
33
|
-
def initialize config
|
34
|
-
@
|
35
|
-
@
|
57
|
+
def initialize config
|
58
|
+
@opts = Opts.new
|
59
|
+
@config = config.merge @opts.config
|
36
60
|
end
|
37
61
|
|
38
62
|
def start
|
39
|
-
trap
|
40
|
-
puts "\nInterrupt signal received\n\n"
|
41
|
-
exit 0
|
42
|
-
end
|
43
|
-
|
63
|
+
trap(:INT) {die "\nInterrupt signal received\n\n", 0}
|
44
64
|
instance_eval @opts.cmd
|
45
65
|
end
|
46
66
|
|
47
67
|
def download *packages
|
48
|
-
packages = packages.first if packages.first.is_a?
|
68
|
+
packages = packages.first if packages.first.is_a?(Array)
|
49
69
|
|
50
|
-
|
51
|
-
|
70
|
+
# Don't download a package if it's found in community
|
71
|
+
packages.delete_if {|pkg| in_sync?(pkg)}
|
72
|
+
die 'No package(s) to download. Possibly the package(s) you ' +
|
73
|
+
'specified was/were found in the community repository.' if packages.empty?
|
52
74
|
|
53
|
-
|
75
|
+
say "Targets (#{ansi "#{packages.length}", :magenta}): #{packages.join(', ')}"
|
76
|
+
|
77
|
+
if yes_or_no? 'Proceed? '
|
54
78
|
packages.each do |package|
|
55
79
|
list(package).each do |names|
|
56
80
|
if names.first == package
|
@@ -58,10 +82,7 @@ module Aurb
|
|
58
82
|
fetch package
|
59
83
|
untar package
|
60
84
|
end
|
61
|
-
|
62
|
-
(#{ansi "#{packages.index(package) + 1}", :green}/#{ansi "#{packages.length}", :green}) \
|
63
|
-
#{in_sync?(package) ? "did NOT download #{package}" : "downloaded #{package}"}
|
64
|
-
DOWNLOAD
|
85
|
+
say "(#{packages.index(package)+1}/#{packages.length}) downloaded #{package}"
|
65
86
|
end
|
66
87
|
end
|
67
88
|
end
|
@@ -72,45 +93,38 @@ DOWNLOAD
|
|
72
93
|
list(package).each do |names|
|
73
94
|
result = json(@config[:info][names.last])
|
74
95
|
|
75
|
-
unless result['type']
|
96
|
+
unless result['type'] =~ /error/
|
76
97
|
result = result['results']
|
77
98
|
next if in_sync? result['Name']
|
78
99
|
|
79
|
-
if package.any?
|
80
|
-
result['
|
81
|
-
|
82
|
-
puts <<SEARCH
|
83
|
-
[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] \
|
84
|
-
#{ansi result['Name'], :blue} (#{result['Version']}): #{result['Description']}
|
85
|
-
SEARCH
|
100
|
+
if package.any? {|pac| (result['Name'] && result['Description']).include?(pac)}
|
101
|
+
say "[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] " +
|
102
|
+
"#{ansi result['Name'], :blue} (#{result['Version']}): #{result['Description']}"
|
86
103
|
end
|
87
104
|
end
|
88
105
|
end
|
89
106
|
end
|
90
107
|
|
91
108
|
def check_upgrade
|
92
|
-
raise 'Pacman binary not found' if `which pacman`.strip == ''
|
93
109
|
upgradable = []
|
94
110
|
|
95
|
-
|
111
|
+
say 'Searching for updates'
|
96
112
|
`pacman -Qm`.each_line do |line|
|
97
113
|
name, version = line.chomp.split
|
98
114
|
result = json(@config[:info][name])
|
99
115
|
|
100
|
-
unless result['type']
|
116
|
+
unless result['type'] =~ /error/
|
101
117
|
result = result['results']
|
102
118
|
next if in_sync? result['Name']
|
103
119
|
|
104
120
|
if VersionNumber.new(result['Version']) > VersionNumber.new(version)
|
105
121
|
upgradable << result['Name']
|
106
|
-
|
107
|
-
#{result['Name']}: #{ansi version, :red} => #{ansi result['Version'], :green}
|
108
|
-
UPDATE
|
122
|
+
say " #{name}: #{ansi version, :red} => #{ansi result['Version'], :green}"
|
109
123
|
end
|
110
124
|
end
|
111
125
|
end
|
112
126
|
|
113
|
-
upgradable.
|
127
|
+
upgradable.any? ? download(upgradable) : say('Nothing to update')
|
114
128
|
end
|
115
129
|
|
116
130
|
private
|
@@ -121,7 +135,7 @@ UPDATE
|
|
121
135
|
def list package
|
122
136
|
info, list = json(@config[:search][CGI::escape(package)]), []
|
123
137
|
|
124
|
-
unless info['type']
|
138
|
+
unless info['type'] =~ /error/
|
125
139
|
info['results'].each do |result|
|
126
140
|
list << [result['Name'], result['ID']]
|
127
141
|
end
|
@@ -141,6 +155,7 @@ UPDATE
|
|
141
155
|
end
|
142
156
|
|
143
157
|
def untar package
|
158
|
+
die "#{package}.tar.gz was not found." unless File.exists? "#{package}.tar.gz"
|
144
159
|
FileUtils.rm_r package if File.directory? package
|
145
160
|
|
146
161
|
Archive::Tar::Minitar.unpack \
|
@@ -149,21 +164,25 @@ UPDATE
|
|
149
164
|
end
|
150
165
|
|
151
166
|
def json item
|
152
|
-
JSON.parse
|
167
|
+
JSON.parse open(item).read
|
153
168
|
end
|
154
169
|
end
|
155
170
|
|
156
171
|
class Opts
|
157
|
-
attr_reader :cmd, :color
|
172
|
+
attr_reader :cmd, :config, :color
|
158
173
|
|
159
174
|
def initialize
|
160
|
-
@@args
|
161
|
-
@
|
175
|
+
@@args = ARGV.any? ? ARGV : ['-h']
|
176
|
+
@config = {}
|
177
|
+
@color = true
|
162
178
|
|
179
|
+
# Parse zeh ARGV!
|
163
180
|
parse!
|
164
181
|
end
|
165
182
|
|
166
183
|
private
|
184
|
+
include Aurb::Util
|
185
|
+
|
167
186
|
def parse!
|
168
187
|
OptionParser.new do |o|
|
169
188
|
o.program_name, o.version, o.release = \
|
@@ -171,7 +190,7 @@ UPDATE
|
|
171
190
|
|
172
191
|
o.separator 'Actions (Required):'
|
173
192
|
o.on '-D', '--download P1,P2,...', Array, 'download package(s)' do |d|
|
174
|
-
@cmd = "download('#{d*"', '"}')"
|
193
|
+
@cmd = "download('#{d*"', '"}')" # XXX: Very ugly. Makes instance_eval work though.
|
175
194
|
end
|
176
195
|
o.on '-S', '--search PKG', 'search for a package' do |s|
|
177
196
|
@cmd = "search('#{s}')"
|
@@ -180,10 +199,19 @@ UPDATE
|
|
180
199
|
@cmd = 'check_upgrade'
|
181
200
|
end
|
182
201
|
o.separator 'Optional:'
|
202
|
+
o.on '--save-to [PATH]', "download path [#{DlPath}]" do |d|
|
203
|
+
if File.exists? d = (d[0...1] == '/' ? d : File.join(Dir.pwd, d))
|
204
|
+
@config[:path] = Pathname.new(d).realpath
|
205
|
+
else
|
206
|
+
die 'The path you specified doesn\'t exist'
|
207
|
+
end
|
208
|
+
end
|
183
209
|
o.on '--[no-]color', "use colors? [#{@color ? 'yes' : 'no'}]" do |c|
|
184
210
|
@color = c
|
185
211
|
end
|
186
212
|
end.parse! @@args
|
213
|
+
rescue OptionParser::ParseError
|
214
|
+
die 'I.. I think you broke it...'
|
187
215
|
end
|
188
216
|
end
|
189
217
|
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.
|
4
|
+
version: 0.7.2
|
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-04-
|
12
|
+
date: 2009-04-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -53,7 +53,7 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- bin/aurb
|
55
55
|
- aurb.gemspec
|
56
|
-
- README
|
56
|
+
- README.rdoc
|
57
57
|
has_rdoc: true
|
58
58
|
homepage: http://github.com/gigamo/aurb
|
59
59
|
post_install_message:
|