aurb 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +54 -0
- data/aurb.gemspec +19 -0
- data/bin/aurb +224 -0
- metadata +81 -0
data/README.rdoc
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
== Usage
|
2
|
+
|
3
|
+
See <tt>aurb --help</tt> for a full list of commands.
|
4
|
+
|
5
|
+
=== Quick Overview
|
6
|
+
|
7
|
+
Required options:
|
8
|
+
|
9
|
+
<tt>--download</tt>:: Downloads a specified package and untars it
|
10
|
+
<tt>--search</tt>:: Searches the AUR for a specified name or description
|
11
|
+
<tt>--upgrade</tt>:: Searches the AUR for updates to foreign local packages
|
12
|
+
|
13
|
+
Optional options:
|
14
|
+
|
15
|
+
<tt>--no-color</tt>:: Suppress colored output
|
16
|
+
<tt>--path</tt>:: Override the default save path (defined as DlPath)
|
17
|
+
|
18
|
+
Other:
|
19
|
+
|
20
|
+
<tt>--version</tt>:: Print version and exit
|
21
|
+
|
22
|
+
== Installation
|
23
|
+
|
24
|
+
Quick and dirty:
|
25
|
+
|
26
|
+
# ruby setup.rb all
|
27
|
+
|
28
|
+
Or you can install it in ~/bin:
|
29
|
+
|
30
|
+
% ruby setup.rb config --bindir=$HOME/bin
|
31
|
+
% ruby setup.rb install
|
32
|
+
|
33
|
+
For more information about setup.rb, see <tt>ruby setup.rb --help</tt>.
|
34
|
+
|
35
|
+
There is also a ruby gemspec available.
|
36
|
+
|
37
|
+
=== Dependencies
|
38
|
+
|
39
|
+
Aurb requires the 'facets' and 'yajl-ruby' rubygems to be installed.
|
40
|
+
|
41
|
+
Facets for:
|
42
|
+
|
43
|
+
* Checking version numbers
|
44
|
+
* Coloring text
|
45
|
+
* Untarring
|
46
|
+
|
47
|
+
Yajl for:
|
48
|
+
|
49
|
+
* Parsing the AUR
|
50
|
+
|
51
|
+
== Todo
|
52
|
+
|
53
|
+
* Automatically build (and install) the package after download?
|
54
|
+
* Add dependency checking/downloading?
|
data/aurb.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# aurb.gemspec
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'aurb'
|
5
|
+
s.version = '0.9.3'
|
6
|
+
s.date = %q{2009-12-02}
|
7
|
+
s.summary = %q{An AUR (Arch User Repository) script}
|
8
|
+
s.email = %q{gigamo@gmail.com}
|
9
|
+
s.homepage = %q{http://github.com/gigamo/aurb}
|
10
|
+
s.description = s.summary
|
11
|
+
s.rubyforge_project = %q{aurb}
|
12
|
+
s.executables = ['aurb']
|
13
|
+
s.has_rdoc = true
|
14
|
+
s.rdoc_options = ['--line-numbers', '--inline-source', '--title', 'Aurb', '--main', 'README.rdoc']
|
15
|
+
s.authors = ['Gigamo']
|
16
|
+
s.files = ['bin/aurb', 'aurb.gemspec', 'README.rdoc']
|
17
|
+
s.add_dependency 'yajl-ruby'
|
18
|
+
s.add_dependency 'facets'
|
19
|
+
end
|
data/bin/aurb
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
#
|
4
|
+
#--
|
5
|
+
# Copyright protects this work.
|
6
|
+
# See LICENSE file for details.
|
7
|
+
#++
|
8
|
+
%w[rubygems getoptlong pathname zlib open-uri yajl gettext
|
9
|
+
facets/ansicode facets/minitar facets/version].each do |lib|
|
10
|
+
begin
|
11
|
+
require lib
|
12
|
+
rescue LoadError
|
13
|
+
abort "F: You're missing '#{lib}'.\nPlease make sure you have the necessary rubygems installed."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def _ str
|
18
|
+
GetText::_(str)
|
19
|
+
end
|
20
|
+
|
21
|
+
module Aurb
|
22
|
+
DlPath = File.join ENV['HOME'], 'abs'
|
23
|
+
PrInfo = {:name => 'Aurb', :version => [0, 9, 3].join('.'), :release => '2009-12-02'}
|
24
|
+
|
25
|
+
module Util
|
26
|
+
def ansi text, effect
|
27
|
+
(@config[:color] ? ANSICode.send(effect.to_sym) : '') << text.to_s << ANSICode.clear
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Aur
|
32
|
+
include Aurb::Util
|
33
|
+
|
34
|
+
class << self
|
35
|
+
def start
|
36
|
+
trap :INT do
|
37
|
+
$stderr.puts _("\nInterrupt signal received\n\n")
|
38
|
+
exit 0
|
39
|
+
end
|
40
|
+
|
41
|
+
self.new :rpc => proc {|type, arg| "http://aur.archlinux.org/rpc.php?type=#{type}&arg=#{arg}"}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def initialize config
|
46
|
+
opts = Opts.new
|
47
|
+
@config = config.merge(opts.config)
|
48
|
+
|
49
|
+
opts.cmd.each do |cmd|
|
50
|
+
cmd.length == 1 ? __send__(cmd.first) : __send__(cmd.first, cmd.last)
|
51
|
+
$stdout.puts "\n\n-----" unless cmd == opts.cmd.last
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def download packages
|
56
|
+
packages.delete_if {|pkg| in_sync?(pkg)}
|
57
|
+
abort _('E: The package(s) you specified was/were found in the community repository') if packages.empty?
|
58
|
+
$stdout.puts _("Targets (#{ansi packages.length, :magenta}): #{packages.join(', ')}")
|
59
|
+
packages.each do |package|
|
60
|
+
begin
|
61
|
+
Dir.chdir @config[:path] do
|
62
|
+
fetch package
|
63
|
+
untar package
|
64
|
+
end
|
65
|
+
rescue OpenURI::HTTPError
|
66
|
+
warn _("W: Something went wrong downloading '#{package}'. Are you sure it exists?")
|
67
|
+
package == packages.last ? exit : next
|
68
|
+
end
|
69
|
+
$stdout.puts _("(#{packages.index(package)+1}/#{packages.length}) downloaded #{package}")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def search packages
|
74
|
+
packages.each do |package|
|
75
|
+
list(package).each do |id|
|
76
|
+
result = json @config[:rpc]['info', id]
|
77
|
+
unless result['type'] =~ /error/
|
78
|
+
result = result['results']
|
79
|
+
next if in_sync? result['Name']
|
80
|
+
if package.split.any? {|pac| (result['Name'] + result['Description']).include?(pac)}
|
81
|
+
$stdout.puts _("[#{result['OutOfDate'] == '1' ? ansi('✘', :red) : ansi('✔', :green)}] " +
|
82
|
+
"#{ansi result['Name'], :blue} (#{result['Version']})\n #{result['Description']}")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def check_upgrade
|
90
|
+
upgradables = []
|
91
|
+
IO.popen('pacman -Qm', IO::RDONLY) {|pm| pm.read.lines}.each do |line|
|
92
|
+
name, version = line.chomp.split
|
93
|
+
result = json @config[:rpc]['info', name]
|
94
|
+
unless result['type'] =~ /error/
|
95
|
+
result = result['results']
|
96
|
+
next if in_sync? result['Name']
|
97
|
+
if VersionNumber.new(result['Version']) > VersionNumber.new(version)
|
98
|
+
upgradables << result['Name']
|
99
|
+
$stdout.puts _("* #{name}: #{ansi version, :red} => #{ansi result['Version'], :green}")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
upgradables.any? ? (download upgradables) : ($stdout.puts _('Nothing to update'))
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
def in_sync? package
|
108
|
+
!!Dir["/var/lib/pacman/sync/community/#{package}-*"].first
|
109
|
+
end
|
110
|
+
|
111
|
+
def list package
|
112
|
+
list = []
|
113
|
+
info = json @config[:rpc]['search', URI.escape(package)]
|
114
|
+
unless info['type'] =~ /error/
|
115
|
+
info['results'].each do |result|
|
116
|
+
list << result['ID']
|
117
|
+
end
|
118
|
+
end
|
119
|
+
list
|
120
|
+
end
|
121
|
+
|
122
|
+
def fetch package
|
123
|
+
open "http://aur.archlinux.org/packages/#{package}/#{package}.tar.gz" do |remote|
|
124
|
+
File.open "#{package}.tar.gz", 'wb' do |local|
|
125
|
+
local.write remote.read
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def untar package
|
131
|
+
Archive::Tar::Minitar.unpack \
|
132
|
+
Zlib::GzipReader.new(File.open("#{package}.tar.gz", 'rb')),
|
133
|
+
Dir.pwd
|
134
|
+
File.delete "#{package}.tar.gz"
|
135
|
+
end
|
136
|
+
|
137
|
+
def json item
|
138
|
+
Yajl::Parser.new.parse(open(item).read)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class Opts
|
143
|
+
attr_reader :config, :cmd
|
144
|
+
|
145
|
+
def initialize
|
146
|
+
@cmd = []
|
147
|
+
@config = {:path => DlPath, :color => true}
|
148
|
+
|
149
|
+
parse!
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
private
|
154
|
+
def parse!
|
155
|
+
ARGV.unshift '-h' if ARGV.empty?
|
156
|
+
|
157
|
+
gopts = GetoptLong.new \
|
158
|
+
['--download', '-d', GetoptLong::REQUIRED_ARGUMENT],
|
159
|
+
['--search', '-s', GetoptLong::REQUIRED_ARGUMENT],
|
160
|
+
['--upgrade', '-u', GetoptLong::NO_ARGUMENT ],
|
161
|
+
['--no-color', GetoptLong::NO_ARGUMENT ],
|
162
|
+
['--path', GetoptLong::OPTIONAL_ARGUMENT],
|
163
|
+
['--version', '-v', GetoptLong::NO_ARGUMENT ],
|
164
|
+
['--help', '-h', GetoptLong::NO_ARGUMENT ]
|
165
|
+
|
166
|
+
gopts.each do |opt, arg|
|
167
|
+
case opt
|
168
|
+
when '--download' then @cmd << ['download', arg.split]
|
169
|
+
when '--search' then @cmd << ['search', arg.split]
|
170
|
+
when '--upgrade' then @cmd << ['check_upgrade' ]
|
171
|
+
when '--no-color' then @config[:color] = false
|
172
|
+
when '--path'
|
173
|
+
if File.exists? arg = (arg[0...1] == '/' ? arg : File.join(Dir.pwd, arg))
|
174
|
+
@config[:path] = Pathname.new(arg).realpath || File.expand_path(arg)
|
175
|
+
else
|
176
|
+
warn _("W: '#{arg}' does not exist. Fell back to [#{@config[:path]}]\n")
|
177
|
+
end
|
178
|
+
when '--version'
|
179
|
+
$stdout.puts _('%s %s (%s)' % [:name, :version, :release].map {|key| PrInfo[key]})
|
180
|
+
exit -1
|
181
|
+
when '--help' then print_help
|
182
|
+
end
|
183
|
+
end
|
184
|
+
rescue GetoptLong::Error; exit 2
|
185
|
+
end
|
186
|
+
|
187
|
+
def print_help out = $stdout
|
188
|
+
out.puts _(<<-HELP)
|
189
|
+
Aurb - An AUR (Arch User Repository) script
|
190
|
+
|
191
|
+
Usage:
|
192
|
+
#{name = File.basename $0} [options]
|
193
|
+
|
194
|
+
Options (Required):
|
195
|
+
-d, --download PACKAGE Download package(s).
|
196
|
+
-s, --search PACKAGE Search for package(s).
|
197
|
+
-u, --upgrade Search for package updates.
|
198
|
+
|
199
|
+
Optional:
|
200
|
+
--no-color Disable colored output.
|
201
|
+
--path [PATH] Override the default save path. [#{@config[:path]}]
|
202
|
+
|
203
|
+
Other:
|
204
|
+
--version Show version and exit.
|
205
|
+
--help You're looking at it.
|
206
|
+
|
207
|
+
Examples:
|
208
|
+
#{name} -d 'package1 package2' --path ~/downloads
|
209
|
+
#{name} -s 'package1 package2' --no-color
|
210
|
+
#{name} --upgrade
|
211
|
+
|
212
|
+
Aurb was inspired by arson. Have a look at http://evaryont.github.com/arson
|
213
|
+
HELP
|
214
|
+
exit -1
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
at_exit do
|
220
|
+
if __FILE__ == $0
|
221
|
+
raise $! if $!
|
222
|
+
Aurb::Aur.start
|
223
|
+
end
|
224
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aurb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gigamo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-02 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: yajl-ruby
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: facets
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: An AUR (Arch User Repository) script
|
36
|
+
email: gigamo@gmail.com
|
37
|
+
executables:
|
38
|
+
- aurb
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- bin/aurb
|
45
|
+
- aurb.gemspec
|
46
|
+
- README.rdoc
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://github.com/gigamo/aurb
|
49
|
+
licenses: []
|
50
|
+
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options:
|
53
|
+
- --line-numbers
|
54
|
+
- --inline-source
|
55
|
+
- --title
|
56
|
+
- Aurb
|
57
|
+
- --main
|
58
|
+
- README.rdoc
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
version:
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: "0"
|
72
|
+
version:
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project: aurb
|
76
|
+
rubygems_version: 1.3.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: An AUR (Arch User Repository) script
|
80
|
+
test_files: []
|
81
|
+
|