evaryont-arson 2.0.0
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.mkd +42 -0
- data/Rakefile +44 -0
- data/VERSION.yml +4 -0
- data/arson.gemspec +37 -0
- data/bin/arson +74 -0
- data/lib/arson/colorful.rb +18 -0
- data/lib/arson/download.rb +35 -0
- data/lib/arson/search.rb +44 -0
- data/lib/arson/upgrade.rb +26 -0
- data/lib/arson/version.rb +5 -0
- data/lib/arson.rb +42 -0
- metadata +83 -0
data/README.mkd
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# This is arson 2.0, the hot AUR search helper!
|
2
|
+
|
3
|
+
There is 3 primary (and only, ever) functions of arson:
|
4
|
+
|
5
|
+
* Searching
|
6
|
+
* Downloading
|
7
|
+
* Updating
|
8
|
+
|
9
|
+
-----
|
10
|
+
|
11
|
+
### Searching
|
12
|
+
|
13
|
+
arson's default fall back action. If arson doesn't understand your parameter,
|
14
|
+
it will search the AUR with them (after URL escaping them) and display the
|
15
|
+
results to you, in color.
|
16
|
+
|
17
|
+
-----
|
18
|
+
|
19
|
+
### Downloading
|
20
|
+
|
21
|
+
If you pass arson the parameter "aur/foo" (however many spaces between) it will
|
22
|
+
attempt to download the package. Or, if the search results only have 1 result,
|
23
|
+
arson will download that package instead of displaying only 1. If you pass the
|
24
|
+
category (i.e. "aur-system/arson") arson will understand that as well.
|
25
|
+
|
26
|
+
|
27
|
+
-----
|
28
|
+
|
29
|
+
### Updating
|
30
|
+
|
31
|
+
If you pass "?" as the only parameter, arson will search through the locally
|
32
|
+
installed foreign packages (as reported by `pacman -Qm') and return a list
|
33
|
+
of possible updates available in the AUR.
|
34
|
+
|
35
|
+
-----
|
36
|
+
|
37
|
+
You can not pass anything to arson to get a quick summary of these options.
|
38
|
+
|
39
|
+
|
40
|
+
(ps: Yes, I did report arson as dead, and within the hour restart development
|
41
|
+
on it. I'm crazy like that, I guess. Also, Daenyth and rson wanted me to
|
42
|
+
continue. Yay having people who actually like my software!)
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
begin; require 'rubygems'; rescue LoadError; end
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gemspec|
|
8
|
+
gemspec.name = 'arson'
|
9
|
+
gemspec.author = "Colin 'Evaryont' Shea"
|
10
|
+
gemspec.summary = "The HOT AUR search helper"
|
11
|
+
gemspec.description = gemspec.summary
|
12
|
+
gemspec.email = 'evaryont@saphrix.com'
|
13
|
+
gemspec.homepage = 'http://evaryont.github.com/arson/'
|
14
|
+
gemspec.platform = Gem::Platform::RUBY
|
15
|
+
gemspec.files = `git ls-files`.split("\n").sort
|
16
|
+
gemspec.has_rdoc = true
|
17
|
+
gemspec.require_path = 'lib'
|
18
|
+
gemspec.bindir = "bin"
|
19
|
+
gemspec.executables = ["arson"]
|
20
|
+
|
21
|
+
gemspec.add_dependency('json', '>= 1.1.3')
|
22
|
+
gemspec.add_dependency('facets', '>= 2.5.1')
|
23
|
+
end
|
24
|
+
rescue LoadError
|
25
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
26
|
+
end
|
27
|
+
|
28
|
+
namespace :version do
|
29
|
+
desc "Writes the version to lib/arson/version.rb"
|
30
|
+
task :ruby do
|
31
|
+
version = Jeweler::Version.new(".")
|
32
|
+
# TODO: This is hard coded 'arson' but it should be dynamic, given
|
33
|
+
# the gem spec
|
34
|
+
file = File.open("lib/arson/version.rb", "w")
|
35
|
+
# TODO: and so should this class template
|
36
|
+
file.write <<-CLASS
|
37
|
+
# Automattically generated by `rake version:write' - use version:bump to change
|
38
|
+
# this, do not edit this directly, as it will be overwritten!
|
39
|
+
class Arson
|
40
|
+
VERSION = [#{version.major}, #{version.minor}, #{version.patch}]
|
41
|
+
end
|
42
|
+
CLASS
|
43
|
+
end
|
44
|
+
end
|
data/VERSION.yml
ADDED
data/arson.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{arson}
|
5
|
+
s.version = "2.0.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Colin 'Evaryont' Shea"]
|
9
|
+
s.date = %q{2009-04-28}
|
10
|
+
s.default_executable = %q{arson}
|
11
|
+
s.description = %q{The HOT AUR search helper}
|
12
|
+
s.email = %q{evaryont@saphrix.com}
|
13
|
+
s.executables = ["arson"]
|
14
|
+
s.files = ["README.mkd", "Rakefile", "VERSION.yml", "arson.gemspec", "bin/arson", "lib/arson.rb", "lib/arson/colorful.rb", "lib/arson/download.rb", "lib/arson/search.rb", "lib/arson/upgrade.rb", "lib/arson/version.rb"]
|
15
|
+
s.has_rdoc = true
|
16
|
+
s.homepage = %q{http://evaryont.github.com/arson/}
|
17
|
+
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{The HOT AUR search helper}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_runtime_dependency(%q<json>, [">= 1.1.3"])
|
28
|
+
s.add_runtime_dependency(%q<facets>, [">= 2.5.1"])
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<json>, [">= 1.1.3"])
|
31
|
+
s.add_dependency(%q<facets>, [">= 2.5.1"])
|
32
|
+
end
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<json>, [">= 1.1.3"])
|
35
|
+
s.add_dependency(%q<facets>, [">= 2.5.1"])
|
36
|
+
end
|
37
|
+
end
|
data/bin/arson
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
|
5
|
+
require 'arson'
|
6
|
+
require 'arson/colorful'
|
7
|
+
|
8
|
+
|
9
|
+
if ARGV.to_s == ""
|
10
|
+
puts "arson #{Arson::VERSION.join('.')} [Colin 'Evaryont' Shea <evaryont@saphrix.com>]"
|
11
|
+
puts "Please specifiy what to search for as the parameters to this script:"
|
12
|
+
puts Arson.colorful(:italic, " #{Arson::PROGRAM} pacman")
|
13
|
+
puts ""
|
14
|
+
puts "If you want to download a package, run #{Arson::PROGRAM} as such:"
|
15
|
+
puts Arson.colorful(:italic, " #{Arson::PROGRAM} aur/arson")
|
16
|
+
puts "(note: you can include the -category bit if you wish)"
|
17
|
+
puts ""
|
18
|
+
puts "Passing '?' to arson will cause it to check for any upgrades"
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
|
22
|
+
if pkg = ARGV.to_s.scan(/^aur(?:-.*)\/(.*)$/).flatten[0]
|
23
|
+
if pkg = Arson.find_exact(pkg)
|
24
|
+
puts "Downloading #{pkg}..."
|
25
|
+
Arson.download(pkg)
|
26
|
+
exit 0
|
27
|
+
else
|
28
|
+
warn "I think you attempted to download a package, but I couldn't find it"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if ARGV.to_s =~ /\?/
|
33
|
+
print "Checking for upgrades..."
|
34
|
+
$stdout.flush
|
35
|
+
upgrades = Arson.check_upgrades
|
36
|
+
unless upgrades.empty?
|
37
|
+
print "\n"
|
38
|
+
$stdout.flush
|
39
|
+
upgrades.each do |line, new_version|
|
40
|
+
puts "#{line.strip} #{Arson::ASCII_CHECK} #{Arson.colorful("Green", new_version)}"
|
41
|
+
end
|
42
|
+
else
|
43
|
+
puts "Nothing to update"
|
44
|
+
end
|
45
|
+
exit 0
|
46
|
+
end
|
47
|
+
|
48
|
+
packages = Arson.search(ARGV)
|
49
|
+
if packages.length > 1
|
50
|
+
packages.each do |pkg|
|
51
|
+
name = Arson.colorful("White", pkg['Name'])
|
52
|
+
name = Arson.colorful("Red", name) if pkg["OutOfDate"] == "1"
|
53
|
+
if Arson::Categories[pkg['CategoryID'].to_i] && Arson::Categories[pkg['CategoryID'].to_i] != "nil"
|
54
|
+
category = "-#{Arson::Categories[pkg['CategoryID'].to_i]}"
|
55
|
+
else
|
56
|
+
category = ""
|
57
|
+
end
|
58
|
+
|
59
|
+
puts <<-HERE
|
60
|
+
#{Arson.colorful("Magenta", "aur#{category}")}/#{name} #{Arson.colorful("Green",pkg['Version'])}
|
61
|
+
#{pkg['Description']}
|
62
|
+
HERE
|
63
|
+
$stdout.flush
|
64
|
+
end
|
65
|
+
|
66
|
+
if File.exists? "/usr/bin/pacman-color"
|
67
|
+
exec "/usr/bin/pacman-color -Ss #{ARGV.join(' ')}"
|
68
|
+
else
|
69
|
+
exec "/usr/bin/pacman -Ss #{ARGV.join(' ')}"
|
70
|
+
end
|
71
|
+
else
|
72
|
+
puts "Downloading #{packages.first['Name']}..."
|
73
|
+
Arson.download(packages.first)
|
74
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Arson
|
2
|
+
class << self
|
3
|
+
def colorful(color, string)
|
4
|
+
return string unless $stdout.tty?
|
5
|
+
colored = ""
|
6
|
+
if color.is_a? String
|
7
|
+
Colors[color].each do |effect|
|
8
|
+
colored << "#{::ANSICode.send(effect)}"
|
9
|
+
end
|
10
|
+
elsif color.is_a? Symbol
|
11
|
+
colored << "#{::ANSICode.send(color)}"
|
12
|
+
else
|
13
|
+
return colorful(color.to_s, string)
|
14
|
+
end
|
15
|
+
colored << (string || "") << "#{::ANSICode.clear}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Arson
|
2
|
+
class << self
|
3
|
+
# +package+ is expected to be a Hash, matching the structure the AUR
|
4
|
+
# RPC returns.
|
5
|
+
# TODO: Add automatic dependency tracking (gleaned parsing the PKGBUILD)
|
6
|
+
def download(package, depends=false)
|
7
|
+
begin
|
8
|
+
real_download("http://aur.archlinux.org"+package['URLPath'])
|
9
|
+
rescue Errno::EEXIST => e
|
10
|
+
warn e.message
|
11
|
+
exit 2
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
# The real downloading code, the parameter is expected to be a valid
|
18
|
+
# URL. No error checking is done.
|
19
|
+
#
|
20
|
+
# After the file is downloaded, it is attempted to be unpacked using
|
21
|
+
# tar and gunzip formats.
|
22
|
+
def real_download(url)
|
23
|
+
open(url) do |tar|
|
24
|
+
# Write the stream to a file, b is JIC
|
25
|
+
File.open(File.basename(url), "wb") do |file|
|
26
|
+
file.write(tar.read)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
tgz = Zlib::GzipReader.new(File.open(File.basename(url), 'rb'))
|
30
|
+
# Extract pkg.tar.gz to `pwd`, instead of `pwd`/pkg
|
31
|
+
Archive::Tar::Minitar.unpack(tgz, Dir.pwd)
|
32
|
+
FileUtils.mv File.basename(url), File.join(Dir.pwd, File.basename(url)[0..-8])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/arson/search.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
class Arson
|
2
|
+
class << self
|
3
|
+
# Given an array of search parameters, return an array of hashes
|
4
|
+
# describing each package search result.
|
5
|
+
def search(*args)
|
6
|
+
keywords = args.join(' ')
|
7
|
+
json = open("http://aur.archlinux.org/rpc.php?type=search&arg=#{URI.escape(keywords)}").read
|
8
|
+
hash = JSON.parse(json)
|
9
|
+
packages = []
|
10
|
+
|
11
|
+
if hash["type"] == "search"
|
12
|
+
|
13
|
+
# Alt search orders: [pkg['CategoryID'],pkg['Name']] - ID num, then name
|
14
|
+
# [Categories[pkg['CategoryID'].to_i],pkg['Name']] - Category name, then pkg name
|
15
|
+
hash["results"].sort_by{|pkg|[pkg['Name']]}.each do |pkg|
|
16
|
+
# Dir["/var/lib/pacman/sync/community/#{pkg['Name']}-*"].first
|
17
|
+
next if File.exists? "/var/lib/pacman/sync/community/#{pkg['Name']}-#{pkg['Version']}"
|
18
|
+
packages << pkg
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
packages
|
23
|
+
end
|
24
|
+
|
25
|
+
# Attempts to find an exact matching package in AUR
|
26
|
+
def find_exact(arg)
|
27
|
+
hash = JSON.parse(open("http://aur.archlinux.org/rpc.php?type=search&arg=#{URI.escape(arg)}").read)
|
28
|
+
packages = []
|
29
|
+
|
30
|
+
if hash["type"] == "search"
|
31
|
+
|
32
|
+
# Alt search orders: [pkg['CategoryID'],pkg['Name']] - ID num, then name
|
33
|
+
# [Categories[pkg['CategoryID'].to_i],pkg['Name']] - Category name, then pkg name
|
34
|
+
hash["results"].sort_by{|pkg|[pkg['Name']]}.each do |pkg|
|
35
|
+
# Dir["/var/lib/pacman/sync/community/#{pkg['Name']}-*"].first
|
36
|
+
next if File.exists? "/var/lib/pacman/sync/community/#{pkg['Name']}-#{pkg['Version']}"
|
37
|
+
return pkg if pkg['Name'] == arg
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
return nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Arson
|
2
|
+
class << self
|
3
|
+
# Thanks for the cleaned up version, Gigamo! Here I go dirtying
|
4
|
+
# it up, however. ;)
|
5
|
+
#
|
6
|
+
# Calls `pacman -Qm', and given each line, finds upgrades for
|
7
|
+
# that package.
|
8
|
+
def check_upgrades
|
9
|
+
upgradable = Hash.new
|
10
|
+
|
11
|
+
::IO.popen('pacman -Qm', ::IO::RDONLY) {|pm| pm.read.lines}.each do |line|
|
12
|
+
name, version = line.chomp.split
|
13
|
+
result = find_exact(name)
|
14
|
+
|
15
|
+
if result
|
16
|
+
if ::VersionNumber.new(result['Version']) > ::VersionNumber.new(version)
|
17
|
+
upgradable[line] = result['Version']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
upgradable#.any? ? download(upgradable) : say('Nothing to update')
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/lib/arson.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'zlib'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'json'
|
5
|
+
require 'facets/ansicode'
|
6
|
+
require 'facets/minitar'
|
7
|
+
require 'facets/version'
|
8
|
+
|
9
|
+
require 'arson/version'
|
10
|
+
require 'arson/search'
|
11
|
+
require 'arson/download'
|
12
|
+
require 'arson/upgrade'
|
13
|
+
|
14
|
+
class Arson
|
15
|
+
# I wish the AUR had an RPC for these, or replaced CategoryID with the name
|
16
|
+
# instead. The first 'nil' is padding, since the categories start at index
|
17
|
+
# 1, going through 18, instead of being sensible and starting from 0.
|
18
|
+
Categories = %w{nil nil daemons devel editors emulators games gnome
|
19
|
+
i18n kde lib modules multimedia network office
|
20
|
+
science system x11 xfce kernels}
|
21
|
+
# Defaults from pacman-color
|
22
|
+
Colors = {"Magenta" => [:bold, :magenta],
|
23
|
+
"White" => [:bold],
|
24
|
+
"Cyan" => [:bold, :cyan],
|
25
|
+
"Blue" => [:bold, :blue],
|
26
|
+
"Yellow" => [:bold, :yellow],
|
27
|
+
"Red" => [:bold, :red],
|
28
|
+
"Green" => [:bold, :green]}
|
29
|
+
# And support for user modifications. Note that inline comments (ie
|
30
|
+
# "White = gray # blah blah") aren't supported and cause this to crash
|
31
|
+
Colors.merge!( Hash[ open("/etc/pacman.d/color.conf").readlines.map(&:strip).reject do |line|
|
32
|
+
line=~ /^#/||line=~ /^$/
|
33
|
+
end.map do |line|
|
34
|
+
a=line.split("=").map(&:strip); [a[0], a[1].sub(/intensive/, "bold").split.map(&:to_sym)]
|
35
|
+
end ] ) if File.exists? "/etc/pacman.d/color.conf"
|
36
|
+
|
37
|
+
PROGRAM = File.basename($0)
|
38
|
+
|
39
|
+
# These will possibly be redefined later.
|
40
|
+
ASCII_X = '✘'
|
41
|
+
ASCII_CHECK = '✔'
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: evaryont-arson
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Colin 'Evaryont' Shea
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-04-28 00:00:00 -07:00
|
13
|
+
default_executable: arson
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.1.3
|
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: 2.5.1
|
34
|
+
version:
|
35
|
+
description: The HOT AUR search helper
|
36
|
+
email: evaryont@saphrix.com
|
37
|
+
executables:
|
38
|
+
- arson
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- README.mkd
|
45
|
+
- Rakefile
|
46
|
+
- VERSION.yml
|
47
|
+
- arson.gemspec
|
48
|
+
- bin/arson
|
49
|
+
- lib/arson.rb
|
50
|
+
- lib/arson/colorful.rb
|
51
|
+
- lib/arson/download.rb
|
52
|
+
- lib/arson/search.rb
|
53
|
+
- lib/arson/upgrade.rb
|
54
|
+
- lib/arson/version.rb
|
55
|
+
has_rdoc: true
|
56
|
+
homepage: http://evaryont.github.com/arson/
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options:
|
59
|
+
- --inline-source
|
60
|
+
- --charset=UTF-8
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
version:
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.2.0
|
79
|
+
signing_key:
|
80
|
+
specification_version: 2
|
81
|
+
summary: The HOT AUR search helper
|
82
|
+
test_files: []
|
83
|
+
|