ruaur 0.1.9 → 0.2.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.
- checksums.yaml +4 -4
- data/bin/ruaur +36 -8
- data/lib/ruaur/aur.rb +46 -13
- data/lib/ruaur/package.rb +46 -14
- data/lib/ruaur/pacman.rb +52 -25
- data/lib/ruaur.rb +4 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7de5353a50adba1ef0574369361580209949f41e
|
4
|
+
data.tar.gz: 6766347de08b199a415d44f4581fba3ab2d17f97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12f4fa538e4fc254d9df1c8cb8e12b942fe3d85e041550631a0e3ea7f0def4f33f615b3431878ee06aa2e5b30747dbacb20a4da0bf0e28133e46e2aa80f56e44
|
7
|
+
data.tar.gz: b4021b5a7c25f20b58fdb2a505c1666df76d7f97adef509a0b586750fac27bb150f3b63d269e5f2a5109336fcecf187094719702fe2f98cbb8d119b713d04882
|
data/bin/ruaur
CHANGED
@@ -22,6 +22,7 @@ end
|
|
22
22
|
def parse(args)
|
23
23
|
options = Hash.new
|
24
24
|
options["operation"] = nil
|
25
|
+
options["verbose"] = false
|
25
26
|
|
26
27
|
# Sync options
|
27
28
|
options["clean"] = false
|
@@ -48,6 +49,14 @@ def parse(args)
|
|
48
49
|
String.disable_colorization = true
|
49
50
|
end
|
50
51
|
|
52
|
+
opts.on(
|
53
|
+
"-v",
|
54
|
+
"--verbose",
|
55
|
+
"Show backtrace when error occurs"
|
56
|
+
) do
|
57
|
+
options["verbose"] = true
|
58
|
+
end
|
59
|
+
|
51
60
|
opts.on("", "OPERATIONS")
|
52
61
|
|
53
62
|
opts.on("-R", "--remove", "Remove packages") do
|
@@ -66,7 +75,7 @@ def parse(args)
|
|
66
75
|
options["operation"] = Operation::SYNC
|
67
76
|
end
|
68
77
|
|
69
|
-
opts.on("", "
|
78
|
+
opts.on("", "SYNC_OPTIONS")
|
70
79
|
|
71
80
|
opts.on("-c", "--clean", "Remove packages from the cache") do
|
72
81
|
options["clean"] = true
|
@@ -98,7 +107,7 @@ def parse(args)
|
|
98
107
|
options["upgrade"] = true
|
99
108
|
end
|
100
109
|
|
101
|
-
opts.on("", "
|
110
|
+
opts.on("", "REMOVE_OPTIONS")
|
102
111
|
|
103
112
|
opts.on("-n", "--nosave", "Completely remove package") do
|
104
113
|
options["nosave"] = true
|
@@ -176,7 +185,7 @@ end
|
|
176
185
|
options = parse(ARGV)
|
177
186
|
|
178
187
|
begin
|
179
|
-
ruaur = RuAUR.new
|
188
|
+
ruaur = RuAUR.new(!String.disable_colorization)
|
180
189
|
|
181
190
|
case options["operation"]
|
182
191
|
when Operation::REMOVE
|
@@ -195,11 +204,30 @@ begin
|
|
195
204
|
ruaur.install(options["packages"], options["noconfirm"])
|
196
205
|
end
|
197
206
|
end
|
198
|
-
|
207
|
+
rescue Interrupt
|
208
|
+
# ^C
|
209
|
+
# Exit gracefully
|
210
|
+
rescue Errno::EPIPE
|
211
|
+
# Do nothing. This can happen if piping to another program such as
|
212
|
+
# less. Usually if less is closed before we're done with STDOUT.
|
199
213
|
rescue RuAUR::Error => e
|
200
|
-
puts e.message
|
214
|
+
puts e.message
|
215
|
+
exit RuAURExit::EXCEPTION
|
216
|
+
rescue Exception => e
|
217
|
+
$stderr.puts "Oops! Looks like an error has occured! If the " \
|
218
|
+
"error persists, file a bug at:".word_wrap
|
219
|
+
$stderr.puts
|
220
|
+
$stderr.puts " https://gitlab.com/mjwhitta/ruaur/issues"
|
221
|
+
$stderr.puts
|
222
|
+
$stderr.puts "Maybe the message below will help. If not, you " \
|
223
|
+
"can use the --verbose flag to get a backtrace.".word_wrap
|
224
|
+
|
225
|
+
$stderr.puts e.message.white.on_red
|
226
|
+
if (options["verbose"])
|
227
|
+
e.backtrace.each do |line|
|
228
|
+
$stderr.puts line.light_yellow
|
229
|
+
end
|
230
|
+
end
|
201
231
|
exit RuAURExit::EXCEPTION
|
202
|
-
rescue Interrupt => e
|
203
|
-
# ^C
|
204
|
-
puts
|
205
232
|
end
|
233
|
+
exit RuAURExit::GOOD
|
data/lib/ruaur/aur.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "archive/tar/minitar"
|
2
|
+
require "colorize"
|
2
3
|
require "fileutils"
|
3
4
|
require "io/wait"
|
4
5
|
require "json"
|
@@ -8,14 +9,38 @@ require "zlib"
|
|
8
9
|
|
9
10
|
class RuAUR::AUR
|
10
11
|
def clean
|
11
|
-
puts "Cleaning AUR cache..."
|
12
|
+
puts colorize_status("Cleaning AUR cache...")
|
12
13
|
Dir.chdir(@cache) do
|
13
14
|
FileUtils.rm_rf(Dir["*"])
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
18
|
+
def colorize_dependency(dependency)
|
19
|
+
return dependency if (!@colorize)
|
20
|
+
return dependency.light_magenta
|
21
|
+
end
|
22
|
+
private :colorize_dependency
|
23
|
+
|
24
|
+
def colorize_installed(installed)
|
25
|
+
return installed if (!@colorize)
|
26
|
+
return installed.light_yellow
|
27
|
+
end
|
28
|
+
private :colorize_installed
|
29
|
+
|
30
|
+
def colorize_status(status)
|
31
|
+
return status if (!@colorize)
|
32
|
+
return status.light_white
|
33
|
+
end
|
34
|
+
private :colorize_status
|
35
|
+
|
36
|
+
def colorize_upgrade(old, new)
|
37
|
+
return "#{old} -> #{new}" if (!@colorize)
|
38
|
+
return "#{old.light_red} -> #{new.light_green}"
|
39
|
+
end
|
40
|
+
private :colorize_upgrade
|
41
|
+
|
17
42
|
def compile(package)
|
18
|
-
puts "Compiling #{package.name}..."
|
43
|
+
puts colorize_status("Compiling #{package.name}...")
|
19
44
|
if (Process.uid == 0)
|
20
45
|
system("chown -R nobody:nobody .")
|
21
46
|
system("su -s /bin/sh nobody -c \"makepkg -sr\"")
|
@@ -35,7 +60,7 @@ class RuAUR::AUR
|
|
35
60
|
def download(package)
|
36
61
|
FileUtils.rm_f(Dir["#{package.name}.tar.gz*"])
|
37
62
|
|
38
|
-
puts "Downloading #{package.name}..."
|
63
|
+
puts colorize_status("Downloading #{package.name}...")
|
39
64
|
tarball(package.name, package.url, "#{package.name}.tar.gz")
|
40
65
|
|
41
66
|
tgz = Pathname.new("#{package.name}.tar.gz").expand_path
|
@@ -83,7 +108,7 @@ class RuAUR::AUR
|
|
83
108
|
def extract(package)
|
84
109
|
FileUtils.rm_rf(package.name)
|
85
110
|
|
86
|
-
puts "Extracting #{package.name}..."
|
111
|
+
puts colorize_status("Extracting #{package.name}...")
|
87
112
|
File.open("#{package.name}.tar.gz", "rb") do |tgz|
|
88
113
|
tar = Zlib::GzipReader.new(tgz)
|
89
114
|
Archive::Tar::Minitar.unpack(tar, ".")
|
@@ -98,7 +123,7 @@ class RuAUR::AUR
|
|
98
123
|
private :extract
|
99
124
|
|
100
125
|
def find_upgrades
|
101
|
-
puts "Checking for AUR updates..."
|
126
|
+
puts colorize_status("Checking for AUR updates...")
|
102
127
|
|
103
128
|
upgrades = Hash.new
|
104
129
|
multiinfo(@installed.keys).each do |package|
|
@@ -128,12 +153,18 @@ class RuAUR::AUR
|
|
128
153
|
end
|
129
154
|
|
130
155
|
return nil if (body["results"].empty?)
|
131
|
-
return RuAUR::Package.new(body["results"])
|
156
|
+
return RuAUR::Package.new(body["results"], "aur", @colorize)
|
132
157
|
end
|
133
158
|
|
134
|
-
def initialize(
|
159
|
+
def initialize(
|
160
|
+
pacman,
|
161
|
+
cache = "/tmp/ruaur-#{ENV["USER"]}",
|
162
|
+
colorize = false
|
163
|
+
)
|
164
|
+
cache = "/tmp/ruaur-#{ENV["USER"]}" if (cache.nil?)
|
135
165
|
@cache = Pathname.new(cache).expand_path
|
136
166
|
FileUtils.mkdir_p(@cache)
|
167
|
+
@colorize = colorize
|
137
168
|
@installed = pacman.query_aur
|
138
169
|
@pacman = pacman
|
139
170
|
@rpc_url = "https://aur.archlinux.org/rpc.php"
|
@@ -150,7 +181,7 @@ class RuAUR::AUR
|
|
150
181
|
@installed.include?(pkg_name) &&
|
151
182
|
!package.newer?(@installed[pkg_name])
|
152
183
|
)
|
153
|
-
puts "Already installed: #{pkg_name}"
|
184
|
+
puts colorize_installed("Already installed: #{pkg_name}")
|
154
185
|
return
|
155
186
|
end
|
156
187
|
|
@@ -181,7 +212,9 @@ class RuAUR::AUR
|
|
181
212
|
next if (dep.start_with?("$"))
|
182
213
|
|
183
214
|
if (!@installed.has_key?(dep))
|
184
|
-
puts
|
215
|
+
puts colorize_dependency(
|
216
|
+
"Installing dependency: #{dep}"
|
217
|
+
)
|
185
218
|
if (@pacman.exist?(dep))
|
186
219
|
@pacman.install(dep, noconfirm)
|
187
220
|
else
|
@@ -206,7 +239,7 @@ class RuAUR::AUR
|
|
206
239
|
end
|
207
240
|
|
208
241
|
body["results"].each do |result|
|
209
|
-
results.push(RuAUR::Package.new(result))
|
242
|
+
results.push(RuAUR::Package.new(result, "aur", @colorize))
|
210
243
|
end
|
211
244
|
return results.sort
|
212
245
|
end
|
@@ -223,7 +256,7 @@ class RuAUR::AUR
|
|
223
256
|
end
|
224
257
|
|
225
258
|
body["results"].each do |result|
|
226
|
-
results.push(RuAUR::Package.new(result))
|
259
|
+
results.push(RuAUR::Package.new(result, "aur", @colorize))
|
227
260
|
end
|
228
261
|
|
229
262
|
results.each do |package|
|
@@ -260,8 +293,8 @@ class RuAUR::AUR
|
|
260
293
|
find_upgrades.each do |pkg_name, versions|
|
261
294
|
old, new = versions
|
262
295
|
|
263
|
-
puts "Upgrading #{pkg_name}..."
|
264
|
-
puts
|
296
|
+
puts colorize_status("Upgrading #{pkg_name}...")
|
297
|
+
puts colorize_upgrade(old, new)
|
265
298
|
install(pkg_name, noconfirm)
|
266
299
|
end
|
267
300
|
end
|
data/lib/ruaur/package.rb
CHANGED
@@ -24,7 +24,41 @@ class RuAUR::Package
|
|
24
24
|
return (self.name.downcase <=> other.name.downcase)
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def colorize_header(repo, name, installed, version, votes)
|
28
|
+
header = Array.new
|
29
|
+
|
30
|
+
if (!@colorize)
|
31
|
+
header.push("#{repo}/#{name}")
|
32
|
+
if (installed && newer?(installed))
|
33
|
+
header.push(installed)
|
34
|
+
header.push("->")
|
35
|
+
end
|
36
|
+
header.push(version)
|
37
|
+
header.push(votes) if (votes)
|
38
|
+
header.push("[installed]") if (installed)
|
39
|
+
else
|
40
|
+
header.push(
|
41
|
+
[
|
42
|
+
repo.light_blue,
|
43
|
+
"/".light_blue,
|
44
|
+
name.light_cyan
|
45
|
+
].join
|
46
|
+
)
|
47
|
+
if (installed && newer?(installed))
|
48
|
+
header.push(installed.light_red)
|
49
|
+
header.push("->")
|
50
|
+
end
|
51
|
+
header.push(version.light_green)
|
52
|
+
header.push(votes.light_white) if (votes)
|
53
|
+
header.push("[installed]".light_magenta) if (installed)
|
54
|
+
end
|
55
|
+
|
56
|
+
return header.join(" ")
|
57
|
+
end
|
58
|
+
private :colorize_header
|
59
|
+
|
60
|
+
def initialize(json, repo = "aur", colorize = false)
|
61
|
+
@colorize = colorize
|
28
62
|
@description = json["Description"]
|
29
63
|
@description ||= ""
|
30
64
|
@installed = nil
|
@@ -76,21 +110,19 @@ class RuAUR::Package
|
|
76
110
|
|
77
111
|
def to_s
|
78
112
|
out = Array.new
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
header.push("[installed]".magenta) if (@installed)
|
89
|
-
out.push(header.join(" "))
|
113
|
+
out.push(
|
114
|
+
colorize_header(
|
115
|
+
@repo,
|
116
|
+
@name,
|
117
|
+
@installed,
|
118
|
+
@version,
|
119
|
+
@votes
|
120
|
+
)
|
121
|
+
)
|
90
122
|
|
91
123
|
# Wrap at default minus 4 spaces
|
92
|
-
@description.word_wrap(76).
|
93
|
-
out.push(" #{line.
|
124
|
+
@description.word_wrap(76).split("\n").each do |line|
|
125
|
+
out.push(" #{line.strip}")
|
94
126
|
end
|
95
127
|
|
96
128
|
return out.join("\n")
|
data/lib/ruaur/pacman.rb
CHANGED
@@ -1,32 +1,54 @@
|
|
1
|
+
require "colorize"
|
2
|
+
require "pathname"
|
3
|
+
|
1
4
|
class RuAUR::Pacman
|
2
5
|
def clean(noconfirm = false)
|
3
|
-
puts "Cleaning pacman cache..."
|
4
|
-
system("sudo #{@
|
5
|
-
system("sudo #{@
|
6
|
+
puts colorize_status("Cleaning pacman cache...")
|
7
|
+
system("sudo #{@pac_cmd} -Sc") if (!noconfirm)
|
8
|
+
system("sudo #{@pac_cmd} -Sc --noconfirm") if (noconfirm)
|
9
|
+
end
|
10
|
+
|
11
|
+
def colorize_installed(installed)
|
12
|
+
return installed if (!@colorize)
|
13
|
+
return installed.light_yellow
|
6
14
|
end
|
15
|
+
private :colorize_installed
|
16
|
+
|
17
|
+
def colorize_status(status)
|
18
|
+
return status if (!@colorize)
|
19
|
+
return status.light_white
|
20
|
+
end
|
21
|
+
private :colorize_status
|
7
22
|
|
8
23
|
def exist?(pkg_name)
|
9
|
-
return !%x(#{@
|
24
|
+
return !%x(#{@pac_nocolor} -Ss "^#{pkg_name}$").empty?
|
10
25
|
end
|
11
26
|
|
12
|
-
def initialize
|
13
|
-
|
14
|
-
|
27
|
+
def initialize(colorize = false)
|
28
|
+
if (ScoobyDoo.where_are_you("pacman").nil?)
|
29
|
+
raise RuAUR::Error::MissingDependencyError.new("pacman")
|
30
|
+
end
|
31
|
+
|
32
|
+
@colorize = colorize
|
33
|
+
@pac_nocolor = "pacman --color=never"
|
34
|
+
@pac_color = "pacman --color=always"
|
35
|
+
@pac_cmd = @pac_color
|
36
|
+
@pac_cmd = @pac_nocolor if (!@colorize)
|
15
37
|
@installed = query
|
16
38
|
end
|
17
39
|
|
18
40
|
def install(pkg_name, noconfirm = false)
|
19
41
|
if (@installed.include?(pkg_name))
|
20
|
-
puts "Already installed: #{pkg_name}"
|
42
|
+
puts colorize_installed("Already installed: #{pkg_name}")
|
21
43
|
return
|
22
44
|
end
|
23
45
|
|
24
|
-
puts "Installing #{pkg_name}..."
|
46
|
+
puts colorize_status("Installing #{pkg_name}...")
|
25
47
|
if (!noconfirm)
|
26
|
-
system("sudo #{@
|
48
|
+
system("sudo #{@pac_cmd} -S #{pkg_name} --needed")
|
27
49
|
else
|
28
50
|
system(
|
29
|
-
"sudo #{@
|
51
|
+
"sudo #{@pac_cmd} -S #{pkg_name} --needed --noconfirm"
|
30
52
|
)
|
31
53
|
end
|
32
54
|
|
@@ -34,18 +56,18 @@ class RuAUR::Pacman
|
|
34
56
|
end
|
35
57
|
|
36
58
|
def install_local(pkgs, noconfirm = false)
|
37
|
-
puts "Installing compiled packages..."
|
59
|
+
puts colorize_status("Installing compiled packages...")
|
38
60
|
xzs = pkgs.join(" ")
|
39
61
|
if (!noconfirm)
|
40
|
-
system("sudo #{@
|
62
|
+
system("sudo #{@pac_cmd} -U #{xzs}")
|
41
63
|
else
|
42
|
-
system("sudo #{@
|
64
|
+
system("sudo #{@pac_cmd} -U #{xzs} --noconfirm")
|
43
65
|
end
|
44
66
|
end
|
45
67
|
|
46
68
|
def query(pkg_name = "")
|
47
69
|
results = Hash.new
|
48
|
-
%x(#{@
|
70
|
+
%x(#{@pac_nocolor} -Q #{pkg_name}).split("\n").each do |line|
|
49
71
|
line = line.split
|
50
72
|
results[line[0]] = line[1]
|
51
73
|
end
|
@@ -58,10 +80,12 @@ class RuAUR::Pacman
|
|
58
80
|
).expand_path
|
59
81
|
|
60
82
|
results = Hash.new
|
61
|
-
%x(
|
83
|
+
%x(
|
84
|
+
#{@pac_nocolor} -Qm #{pkg_name}
|
85
|
+
).split("\n").delete_if do |p|
|
62
86
|
# Skip packages in community
|
63
87
|
Dir["#{community}/#{p.split.join("-")}"].any?
|
64
|
-
end.
|
88
|
+
end.each do |line|
|
65
89
|
line = line.split
|
66
90
|
results[line[0]] = line[1]
|
67
91
|
end
|
@@ -69,11 +93,11 @@ class RuAUR::Pacman
|
|
69
93
|
end
|
70
94
|
|
71
95
|
def remove(pkg_names, nosave = false)
|
72
|
-
puts "Removing #{pkg_names.join(" ")}..."
|
96
|
+
puts colorize_status("Removing #{pkg_names.join(" ")}...")
|
73
97
|
if (!nosave)
|
74
|
-
system("sudo #{@
|
98
|
+
system("sudo #{@pac_cmd} -R #{pkg_names.join(" ")}")
|
75
99
|
else
|
76
|
-
system("sudo #{@
|
100
|
+
system("sudo #{@pac_cmd} -Rn #{pkg_names.join(" ")}")
|
77
101
|
end
|
78
102
|
end
|
79
103
|
|
@@ -81,7 +105,9 @@ class RuAUR::Pacman
|
|
81
105
|
results = Array.new
|
82
106
|
return results if (pkg_names.nil? || pkg_names.empty?)
|
83
107
|
|
84
|
-
%x(
|
108
|
+
%x(
|
109
|
+
#{@pac_nocolor} -Ss #{pkg_names}
|
110
|
+
).split("\n").each do |line|
|
85
111
|
reg = "^([^\/ ]+)\/([^ ]+) ([^ ]+)( .*)?$"
|
86
112
|
match = line.match(/#{reg}/)
|
87
113
|
if (match)
|
@@ -101,7 +127,8 @@ class RuAUR::Pacman
|
|
101
127
|
"URLPath" => nil,
|
102
128
|
"Version" => version
|
103
129
|
},
|
104
|
-
repo
|
130
|
+
repo,
|
131
|
+
@colorize
|
105
132
|
)
|
106
133
|
)
|
107
134
|
if (trailing.include?("[installed]"))
|
@@ -116,8 +143,8 @@ class RuAUR::Pacman
|
|
116
143
|
end
|
117
144
|
|
118
145
|
def upgrade(noconfirm = false)
|
119
|
-
puts "Updating..."
|
120
|
-
system("sudo #{@
|
121
|
-
system("sudo #{@
|
146
|
+
puts colorize_status("Updating...")
|
147
|
+
system("sudo #{@pac_cmd} -Syyu") if (!noconfirm)
|
148
|
+
system("sudo #{@pac_cmd} -Syyu --noconfirm") if (noconfirm)
|
122
149
|
end
|
123
150
|
end
|
data/lib/ruaur.rb
CHANGED
@@ -16,7 +16,7 @@ class RuAUR
|
|
16
16
|
@aur.clean
|
17
17
|
end
|
18
18
|
|
19
|
-
def initialize
|
19
|
+
def initialize(colorize = false)
|
20
20
|
[
|
21
21
|
"makepkg",
|
22
22
|
"pacman",
|
@@ -28,8 +28,9 @@ class RuAUR
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
@
|
32
|
-
@
|
31
|
+
@colorize = colorize
|
32
|
+
@pacman = RuAUR::Pacman.new(@colorize)
|
33
|
+
@aur = RuAUR::AUR.new(@pacman, nil, @colorize)
|
33
34
|
@lock = Pathname.new("/tmp/ruaur.lock").expand_path
|
34
35
|
end
|
35
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruaur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Whittaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: archive-tar-minitar
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.5.1
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Can search and install packages for Arch Linux
|