upm 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Rakefile +7 -3
- data/TODO.md +8 -3
- data/VERSION +1 -1
- data/lib/upm/core_ext.rb +19 -0
- data/lib/upm/tool.rb +42 -23
- data/lib/upm/tools/xbps.rb +5 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34ab54fc955906c85199e43735991d297f7db20e2f78a53c49ae22ce08ddd30f
|
4
|
+
data.tar.gz: 123c3e08566179a36f32ed0cb4e304a72eb75f785ce128bd1b8959c3d7ca78c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 723b556018ce78091e5a9bf6b6132a3a730707b40bbc6db98377441e0c7ef7cfd4e164a841b750379805a136c4477e5059377af81da5c3402edf7290d31f11c1
|
7
|
+
data.tar.gz: ea06d30b45f4624637cd515dc400d909462b7022e92bf961c7191fda601f272a80bdfa1589370d3118a1ca5f039e879773be25b964cfef0d07182225e78247b9
|
data/.gitignore
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
pkg/
|
data/Rakefile
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
-
gem_version = File.read("VERSION").strip
|
2
1
|
pkgname = "upm"
|
2
|
+
gem_version = File.read("VERSION").strip
|
3
|
+
|
4
|
+
gemfile = "#{pkgname}-#{gem_version}.gem"
|
3
5
|
|
4
6
|
task :build do
|
5
7
|
system "gem build .gemspec"
|
8
|
+
system "mkdir pkg/" unless File.directory? "pkg"
|
9
|
+
system "mv #{gemfile} pkg/"
|
6
10
|
end
|
7
11
|
|
8
12
|
task :release => :build do
|
9
|
-
system "gem push
|
13
|
+
system "gem push pkg/#{gemfile}"
|
10
14
|
end
|
11
15
|
|
12
16
|
task :gem => :build
|
13
17
|
|
14
18
|
task :install => :build do
|
15
|
-
system "gem install
|
19
|
+
system "gem install pkg/#{gemfile}"
|
16
20
|
end
|
data/TODO.md
CHANGED
@@ -30,11 +30,14 @@ Related tool: intoli/exodus
|
|
30
30
|
|
31
31
|
Use fzf for "list" output (or other commands that require selecting, like "remove")
|
32
32
|
|
33
|
-
##
|
33
|
+
## Commandline argument parser
|
34
34
|
|
35
|
-
*
|
35
|
+
* Add options to commands:
|
36
|
+
* upm upgrade --download-only
|
37
|
+
* upm install --help
|
38
|
+
* upm help install
|
36
39
|
|
37
|
-
## Streaming pipes
|
40
|
+
## Streaming pipes with colours
|
38
41
|
|
39
42
|
* Make the `run` command able to grep the output while streaming the results to the screen.
|
40
43
|
* Make run pretend to be a tty, so I don't need `--color=always`.
|
@@ -78,4 +81,6 @@ Why not!
|
|
78
81
|
|
79
82
|
Do a ping test on available mirrors, and use fzf to select.
|
80
83
|
|
84
|
+
## Interrupt catcher
|
81
85
|
|
86
|
+
Don't print backtrace when ^C is pressed.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/upm/core_ext.rb
CHANGED
@@ -4,6 +4,25 @@ class DateTime
|
|
4
4
|
def to_i; to_time.to_i; end
|
5
5
|
end
|
6
6
|
|
7
|
+
class File
|
8
|
+
def self.which(bin)
|
9
|
+
ENV["PATH"].split(":").each do |dir|
|
10
|
+
full_path = File.join(dir, bin)
|
11
|
+
return full_path if File.exists? full_path
|
12
|
+
end
|
13
|
+
nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.which_is_best?(*bins)
|
17
|
+
bins.flatten.each do |bin|
|
18
|
+
if location = which(bin)
|
19
|
+
return location
|
20
|
+
end
|
21
|
+
end
|
22
|
+
nil
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
7
26
|
module Enumerable
|
8
27
|
#
|
9
28
|
# Split this enumerable into chunks, given some boundary condition. (Returns an array of arrays.)
|
data/lib/upm/tool.rb
CHANGED
@@ -39,21 +39,26 @@ module UPM
|
|
39
39
|
}
|
40
40
|
|
41
41
|
@@tools = {}
|
42
|
+
def self.tools; @@tools; end
|
42
43
|
|
43
44
|
def self.register_tools!
|
44
45
|
Dir["#{__dir__}/tools/*.rb"].each { |lib| require_relative(lib) }
|
45
46
|
end
|
46
47
|
|
47
48
|
def self.os_release
|
48
|
-
@os_release ||=
|
49
|
-
|
50
|
-
|
49
|
+
@os_release ||= begin
|
50
|
+
open("/etc/os-release") do |io|
|
51
|
+
io.read.scan(/^(\w+)="?(.+?)"?$/)
|
52
|
+
end.to_h
|
53
|
+
rescue Errno::ENOENT
|
54
|
+
{}
|
55
|
+
end
|
51
56
|
end
|
52
57
|
|
53
58
|
def self.current_os_names
|
54
59
|
# ID=ubuntu
|
55
60
|
# ID_LIKE=debian
|
56
|
-
os_release.values_at("ID", "ID_LIKE")
|
61
|
+
os_release.values_at("ID", "ID_LIKE").compact
|
57
62
|
end
|
58
63
|
|
59
64
|
def self.nice_os_name
|
@@ -62,13 +67,16 @@ module UPM
|
|
62
67
|
|
63
68
|
def self.for_os(os_names=nil)
|
64
69
|
os_names = os_names ? [os_names].flatten : current_os_names
|
65
|
-
@@tools.find { |name, tool| os_names.any? { |name| tool.os.include? name } }.last
|
66
|
-
end
|
67
70
|
|
68
|
-
|
69
|
-
|
71
|
+
if os_names.any?
|
72
|
+
@@tools.find { |name, tool| os_names.any? { |name| tool.os.include? name } }.last
|
73
|
+
else
|
74
|
+
@@tools.find { |name, tool| File.which(tool.identifying_binary) }.last
|
75
|
+
end
|
70
76
|
end
|
71
77
|
|
78
|
+
###################################################################
|
79
|
+
|
72
80
|
def initialize(name, &block)
|
73
81
|
@name = name
|
74
82
|
instance_eval(&block)
|
@@ -85,7 +93,10 @@ module UPM
|
|
85
93
|
end
|
86
94
|
|
87
95
|
def help
|
88
|
-
|
96
|
+
if osname = Tool.nice_os_name
|
97
|
+
puts " Detected OS: #{osname}"
|
98
|
+
end
|
99
|
+
|
89
100
|
puts "Package manager: #{@name}"
|
90
101
|
puts
|
91
102
|
puts "Available commands:"
|
@@ -100,23 +111,16 @@ module UPM
|
|
100
111
|
end
|
101
112
|
end
|
102
113
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
enum = enum.reject { |line| line[exclude] } if exclude
|
111
|
-
enum.each { |line| less.puts line }
|
112
|
-
end
|
113
|
-
less.puts
|
114
|
-
end
|
114
|
+
## DSL methods
|
115
|
+
|
116
|
+
def identifying_binary(id_bin=nil)
|
117
|
+
if id_bin
|
118
|
+
@id_bin = id_bin
|
119
|
+
else
|
120
|
+
@id_bin || @name
|
115
121
|
end
|
116
122
|
end
|
117
123
|
|
118
|
-
## DSL methods
|
119
|
-
|
120
124
|
def prefix(name)
|
121
125
|
@prefix = name
|
122
126
|
end
|
@@ -174,6 +178,21 @@ module UPM
|
|
174
178
|
end
|
175
179
|
end
|
176
180
|
|
181
|
+
def print_files(*paths, include: nil, exclude: nil)
|
182
|
+
lesspipe do |less|
|
183
|
+
paths.each do |path|
|
184
|
+
less.puts "<8>=== <11>#{path} <8>========".colorize
|
185
|
+
open(path) do |io|
|
186
|
+
enum = io.each_line
|
187
|
+
enum = enum.grep(include) if include
|
188
|
+
enum = enum.reject { |line| line[exclude] } if exclude
|
189
|
+
enum.each { |line| less.puts line }
|
190
|
+
end
|
191
|
+
less.puts
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
177
196
|
end # class Tool
|
178
197
|
|
179
198
|
end # module UPM
|
data/lib/upm/tools/xbps.rb
CHANGED
@@ -2,11 +2,13 @@ UPM::Tool.new "xbps" do
|
|
2
2
|
|
3
3
|
os "void"
|
4
4
|
|
5
|
+
identifying_binary "xbps-install"
|
6
|
+
|
5
7
|
command "install", "xbps-install", root: true
|
6
|
-
command "update",
|
8
|
+
command "update", "xbps-install -S", root: true
|
7
9
|
command "upgrade", "xbps-install -Su", root: true
|
8
|
-
command "files",
|
9
|
-
command "search",
|
10
|
+
command "files", "xbps-query -f"
|
11
|
+
command "search", "xbps-query --regex -Rs"
|
10
12
|
# command "info", ""
|
11
13
|
|
12
14
|
command "list" do |args|
|