upm 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO.md +8 -0
- data/VERSION +1 -1
- data/lib/upm/freshports_search.rb +29 -0
- data/lib/upm/tool.rb +4 -2
- data/lib/upm/tool_dsl.rb +16 -1
- data/lib/upm/tools/pacman.rb +2 -8
- data/lib/upm/tools/pkg.rb +20 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f8e2c0aca1eba8bc509f6f89582039a586d77e943ffced223e343860dfd378b
|
4
|
+
data.tar.gz: 5934a3b056109aceaa4f48e7d9403af2b9187fc4d64654596e4d99c97f1ce14a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e660590380098da3bb5faf99a8d57f7e87aaa8d310a4d9526f743a7b76a40071fd3ba83bd06b6de4bcd002bbf5ea3630cea0e12df7e1ebe3b15e964e9aaf575f
|
7
|
+
data.tar.gz: 48986e26050f65d7665092cf48458cf88ef179edc5bf09550d52c8a92026acfdb16e973e5d99c2264c7b75e00f6a2b7e31922bcaacbaa1fcbadfa61a42873732
|
data/TODO.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# TODO
|
2
2
|
|
3
|
+
## Performance
|
4
|
+
|
5
|
+
It's currently very clunky on the rpi2.
|
6
|
+
|
7
|
+
## Custom help for command
|
8
|
+
|
9
|
+
eg: command "something", help: "does stuff", root: true do ... end
|
10
|
+
|
3
11
|
## Pipes and filters
|
4
12
|
|
5
13
|
* `Tool::DSL#run` is currently somewhat awkward; it would be simpler if returned an `Enumerator`, which could then be filtered (ie: highlight/grep), or concatenated to other `Enumerator`s.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'upm/colored'
|
3
|
+
|
4
|
+
class FreshportsSearch
|
5
|
+
NUM_RESULTS = 20
|
6
|
+
SEARCH_URL = "https://www.freshports.org/search.php?query=%s&num=#{NUM_RESULTS}&stype=name&method=match&deleted=excludedeleted&start=1&casesensitivity=caseinsensitive"
|
7
|
+
SVN_URL = "svn://svn.FreeBSD.org/ports/head/%s/%s"
|
8
|
+
|
9
|
+
def print(results)
|
10
|
+
results.each do |path, desc, version|
|
11
|
+
_, category, package = path.split("/")
|
12
|
+
puts "<9>#{category}<8>/<11>#{package} <8>(<7>#{version}<8>)".colorize
|
13
|
+
puts " #{desc}"
|
14
|
+
puts " #{SVN_URL % [category, package]}".light_green
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def search!(query)
|
19
|
+
puts "<8>* <7>Searching for <15>#{query}<7>...".colorize
|
20
|
+
html = open(SEARCH_URL % query, &:read)
|
21
|
+
puts
|
22
|
+
results = html.scan(%r{<DT>\s*<BIG><B><a href="([^"]+)/">.+?</BIG>\s*<span class="[^"]+">([^<]+)</span><br>\s*<b>\s*([^<]+)\s*</b>}im)
|
23
|
+
print(results)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if __FILE__ == $0
|
28
|
+
FreshportsSearch.new.search!("silver_searcher")
|
29
|
+
end
|
data/lib/upm/tool.rb
CHANGED
@@ -19,8 +19,9 @@ module UPM
|
|
19
19
|
COMMAND_HELP = {
|
20
20
|
"install" => "install a package",
|
21
21
|
"remove/uninstall" => "remove a package",
|
22
|
-
"
|
23
|
-
"search"
|
22
|
+
"search" => "search packages",
|
23
|
+
"search-sources" => "search package source (for use with 'build' command)",
|
24
|
+
"build" => "build a package from source and install it",
|
24
25
|
"list" => "list installed packages (or search their names if extra arguments are supplied)",
|
25
26
|
"info" => "show metadata about a package",
|
26
27
|
"update/sync" => "retrieve the latest package list or manifest",
|
@@ -54,6 +55,7 @@ module UPM
|
|
54
55
|
"s" => "search",
|
55
56
|
"f" => "files",
|
56
57
|
"r" => "remove",
|
58
|
+
"source-search" => "search-sources",
|
57
59
|
}
|
58
60
|
|
59
61
|
def initialize(name, &block)
|
data/lib/upm/tool_dsl.rb
CHANGED
@@ -17,8 +17,15 @@ module UPM
|
|
17
17
|
@cmds ||= {}
|
18
18
|
|
19
19
|
if block_given?
|
20
|
-
|
20
|
+
|
21
|
+
if root and Process.uid != 0
|
22
|
+
exec("sudo", $PROGRAM_NAME, *ARGV)
|
23
|
+
else
|
24
|
+
@cmds[name] = block
|
25
|
+
end
|
26
|
+
|
21
27
|
elsif shell_command
|
28
|
+
|
22
29
|
if shell_command.is_a? String
|
23
30
|
shell_command = shell_command.split
|
24
31
|
elsif not shell_command.is_a? Array
|
@@ -29,6 +36,7 @@ module UPM
|
|
29
36
|
query = highlight && args.join(" ")
|
30
37
|
run(*shell_command, *args, paged: paged, root: root, highlight: query)
|
31
38
|
end
|
39
|
+
|
32
40
|
end
|
33
41
|
end
|
34
42
|
|
@@ -97,6 +105,13 @@ module UPM
|
|
97
105
|
end
|
98
106
|
end
|
99
107
|
|
108
|
+
def curl(url)
|
109
|
+
IO.popen(["curl", "-Ss", url], &:read)
|
110
|
+
rescue Errno::ENOENT
|
111
|
+
puts "Error: 'curl' isn't installed. You need this!"
|
112
|
+
exit 1
|
113
|
+
end
|
114
|
+
|
100
115
|
def print_files(*paths, include: nil, exclude: nil)
|
101
116
|
lesspipe do |less|
|
102
117
|
paths.each do |path|
|
data/lib/upm/tools/pacman.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
UPM::Tool.new "pacman" do
|
3
2
|
|
4
3
|
os "arch"
|
@@ -10,16 +9,14 @@ UPM::Tool.new "pacman" do
|
|
10
9
|
command "upgrade", [*bin, "-Syu"], root: true
|
11
10
|
command "remove", [*bin, "-R"], root: true
|
12
11
|
|
13
|
-
|
14
|
-
command "verify" do |args|
|
12
|
+
command "verify", root: true do |args|
|
15
13
|
require 'upm/pacman_verifier'
|
16
14
|
UPM::PacmanVerifier.new.verify!(*args)
|
17
15
|
end
|
18
16
|
|
19
17
|
command "audit", "arch-audit", paged: true
|
20
18
|
command "files", [*bin, "-Ql"], paged: true
|
21
|
-
command "search", [*bin, "-Ss"], paged: true
|
22
|
-
|
19
|
+
command "search", [*bin, "-Ss"], paged: true, highlight: true
|
23
20
|
|
24
21
|
command "info" do |args|
|
25
22
|
run(*bin, "-Qi", *args, paged: true) || run(*bin, "-Si", *args, paged: true)
|
@@ -108,7 +105,4 @@ UPM::Tool.new "pacman" do
|
|
108
105
|
|
109
106
|
end
|
110
107
|
|
111
|
-
|
112
108
|
end
|
113
|
-
|
114
|
-
|
data/lib/upm/tools/pkg.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'upm/freshports_search'
|
2
|
+
|
1
3
|
UPM::Tool.new "pkg" do
|
2
4
|
|
3
5
|
os "FreeBSD"
|
@@ -11,6 +13,24 @@ UPM::Tool.new "pkg" do
|
|
11
13
|
|
12
14
|
command "files", "pkg list", paged: true
|
13
15
|
command "search", "pkg search", paged: true, highlight: true
|
16
|
+
command "search-sources" do |*args|
|
17
|
+
query = args.join(" ")
|
18
|
+
FreshportsSearch.new.search!(query)
|
19
|
+
end
|
20
|
+
|
21
|
+
command "build" do |*args|
|
22
|
+
# svn checkout --depth empty svn://svn.freebsd.org/ports/head /usr/ports
|
23
|
+
# cd /usr/ports
|
24
|
+
# svn update --set-depth files
|
25
|
+
# svn update Mk
|
26
|
+
# svn update Templates
|
27
|
+
# svn update Tools
|
28
|
+
# svn update --set-depth files $category
|
29
|
+
# cd $category
|
30
|
+
# svn update $port
|
31
|
+
puts "Not implemented"
|
32
|
+
end
|
33
|
+
|
14
34
|
command "info", "pkg info", paged: true
|
15
35
|
|
16
36
|
command "list" do |args|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- epitron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Wrap all known command-line package tools with a consistent and pretty
|
14
14
|
interface.
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- lib/upm.rb
|
32
32
|
- lib/upm/colored.rb
|
33
33
|
- lib/upm/core_ext.rb
|
34
|
+
- lib/upm/freshports_search.rb
|
34
35
|
- lib/upm/lesspipe.rb
|
35
36
|
- lib/upm/log_parser.rb
|
36
37
|
- lib/upm/pacman_verifier.rb
|
@@ -63,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
63
64
|
version: '0'
|
64
65
|
requirements: []
|
65
66
|
rubyforge_project:
|
66
|
-
rubygems_version: 2.7.
|
67
|
+
rubygems_version: 2.7.7
|
67
68
|
signing_key:
|
68
69
|
specification_version: 4
|
69
70
|
summary: Universal Package Manager
|