upm 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c5ec80be1569a58c23402685f57f02f46cebd10ae87b2684eb2aa8d132aa7cf
4
- data.tar.gz: d2fee9bb7b69d36df657e749a109dd29cdc3bbabef9b83b7a1731f83afa504f4
3
+ metadata.gz: 5643e0647bd7382b413354291acc5fa62ca282b21ea09a6ec7e714993fb0559c
4
+ data.tar.gz: 1370ad6461b00a72e138aaf0bed8d98e868372416c19b62cf8081db3a582467f
5
5
  SHA512:
6
- metadata.gz: e1c9ea83290760c4fc2c7ea7cab2580ea50ef5053751d49e7414f6d57b7b2e84b35064ec5ae4dbece2c5f00b5c7456ff80d72caf084d4c43a9668834937e25e8
7
- data.tar.gz: 51dbea8086d5162b4f5b90b83028e924195f34a293c2481c05cc3e4e573752f1291f7bb73d2ecf0941ee6fbd351c6294f347c6f2ee0b4250065fc99cb7fdb6ce
6
+ metadata.gz: 9674e0839137df4b9efd4dc4730930df426c79b449b1b999ecd894bc48b00ab2df4ded3cbc915f2b333ed21aebc0f6eb7128eb6f36a5837e3c916a074e6f49e7
7
+ data.tar.gz: 996b34e98a0654a72fa3814d10101942fab1580448d9a34778baa95f3a93a6f551eee5b2b9803325f022377119c913fc827d57fca0275372646f69a04b27c44d
data/README.md CHANGED
@@ -8,12 +8,20 @@ Wraps all known package managers to provide a consistent and pretty interface, a
8
8
  - pinning
9
9
  - fuzzy search
10
10
  - containerization/sandboxing
11
- - learning (community statistics and user choices)
11
+ - learning what packages are cool (community statistics, user favorites)
12
12
 
13
- All tools will give you modern, pretty, colourful, piped-to-less output, and you'll only have to remember one consistent set of commands. It'll also prompt you with a text UI whenever faced with ambiguity.
13
+ No matter what package manager you're using, you'll get a modern, pretty, colourful, output that's piped-to-less, and you only have to remember one consistent set of commands. It'll also prompt you with a text UI whenever faced with ambiguity.
14
14
 
15
15
  You can maintain lists of your favorite packages (and sync them to some remote server), so that you can automatically install them whenever you setup a new machine. (This can include git repos full of dotfiles/scripts, to give you a comfortable home environment, regardless of which OS you're using.)
16
16
 
17
+ ## Reality:
18
+
19
+ Currently, `upm` provides a consistent interface to a number of tools: apk (Alpine), apt (Debian/Ubuntu), guix, opkg (OpenWRT), pacman (Arch), pkg (FreeBSD), pkg_add (OpenBSD), pkgin (Solaris/NetBSD), xbps (Void), and yum (Fedora).
20
+
21
+ All the tools support the basic operations (installing, searching, listing, removing), and some support more advanced features, like grabbing search results from the web and showing the installation logs, and the output is always paged to `less`.
22
+
23
+ The more advanced features, like consistent output, colorization, fuzzy filtering, etc. are not yet implemented.
24
+
17
25
  ## Installation:
18
26
 
19
27
  First, install Ruby. Then:
@@ -51,6 +59,7 @@ u <command> <pkg>
51
59
  * `monitor` - ad-hoc package manager for custom installations (like instmon)
52
60
  * `keys` - keyrings and package authentication
53
61
  * `default` - configure the action to take when no arguments are passed to "upm" (defaults to "os:update")
62
+ * `switch` - set a default tool (eg: if you're on a system with both `apt-get` and `nix`, you can switch to `nix` so that you don't need to prefix every package with `nix:`)
54
63
 
55
64
  ### Any command that takes a package name can be prefixed with the package tool's namespace:
56
65
 
@@ -127,6 +136,19 @@ Rollback:
127
136
  * Context-dependent operation
128
137
  * eg: if you're in a ruby project's directory, set the 'ruby' namespace to highest priority
129
138
 
139
+ ## Dotfiles
140
+
141
+ * Manage and version-control dotfiles
142
+ * Sync sqlite databases
143
+ * sqlitesync tool?
144
+
145
+ ## Themes
146
+
147
+ * Font packs
148
+ * Theme browser/downloader for GTK{2,3}, Qt, XFCE4, and Compiz
149
+ * Populate `~/.themes` and set ENVIRONMENT variables
150
+ * Store/load from favorites
151
+
130
152
  ## Containers, VMs, and Virtual Environments:
131
153
 
132
154
  Containers, VMs, and Virtual Environments are another pile of tools which do roughly the same thing: they gather together the dependencies for a specific program, or small set of programs, into a bundle, and create an isolated environment in which it can run.
@@ -149,7 +171,7 @@ In the future, these could be wrapped by `ucm` (Universal Container Manager), if
149
171
  * podman
150
172
  * nanobox
151
173
  * SmartOS zones
152
- * BSD jails
174
+ * BSD jails (iocage)
153
175
  * Wine environments:
154
176
  * wine prefixes
155
177
  * playonlinuxs
@@ -169,4 +191,5 @@ In the future, these could be wrapped by `ucm` (Universal Container Manager), if
169
191
 
170
192
  * [PackageKit](https://en.wikipedia.org/wiki/PackageKit)
171
193
  * [libraries.io](https://libraries.io)
194
+ * [pkgs.org](https://pkgs.org)
172
195
  * [Repology](https://repology.org)
data/TODO.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # TODO
2
2
 
3
3
  ## UI
4
- * fzf
5
- * search
4
+ * fzf/pick
5
+ * scrapers for web-based search engines (especially for "files in packages")
6
6
 
7
7
  ## Options
8
8
  * Proper option/command parser
@@ -11,9 +11,15 @@
11
11
  ## DSL
12
12
  * Call commands from within other commands, or specify dependencies (eg: command "install", "pkg install", depends: "update" )
13
13
  * DSL setting defaults (eg: cache_dir "~/.cache/upm")
14
+ * Some commands require special packages (eg: "command 'locate', depends: 'pkgfile'") which have their own syncable databases
15
+ |_ offer to install these dependencies (and sync them (periodically))
16
+ |_ web-based search is even nicer
17
+ * Page multi-commands (eg: 'args.each { run ..., paged: true }' should all output to the same pager)
18
+ |_ 'run ..., pager: IO'? will that break grep?
14
19
 
15
20
  ## Performance
16
21
  * RPi2 is very clunky
22
+ |_ rewrite in... C? rust? go? lua?
17
23
 
18
24
  ## Custom help for command
19
25
  eg: command "something", help: "does stuff", root: true do ... end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.17
1
+ 0.1.18
data/lib/upm/tool.rb CHANGED
@@ -25,42 +25,50 @@ module UPM
25
25
  "search-sources" => "search package source (for use with 'build' command)",
26
26
  "build" => "build a package from source and install it",
27
27
  "list" => "list installed packages (or search their names if extra arguments are supplied)",
28
+ "selection/manual" => "list manually installed packages", # this should probably be a `list` option ("upm list --manually-added" or smth (would be nice: rewrite in go and use ipfs' arg parsing library))
28
29
  "files" => "list files in a package",
29
- "info" => "show metadata about a package",
30
+ "rdeps/depends" => "reverse dependencies (which packages depend on this package?)",
31
+ "locate" => "search contents of packages (local or remote)",
32
+ "info/show" => "show metadata about a package",
30
33
  "update/sync" => "retrieve the latest package list or manifest",
31
34
  "upgrade" => "update package list and install updates",
35
+ "selfupdate" => "update the package manager",
32
36
  "download" => "download package list and updates, but don't insatall them",
33
37
  "pin" => "pinning a package means it won't be automatically upgraded",
34
38
  "rollback" => "revert to an earlier version of a package (including its dependencies)",
35
39
  "verify/check" => "verify the integrity of packages' files on the filesystem",
36
- "audit/vuln" => "show known vulnerabilities in installed packages",
40
+ "repair" => "fix corrupted packages",
41
+ "audit/vulns" => "show known vulnerabilities in installed packages",
37
42
  "log" => "show history of package installs",
38
43
  "packagers" => "detect installed package managers, and pick which ones upm should wrap",
39
- "mirrors/sources" => "manage remote repositories and mirrors",
40
44
  "clean" => "clear out the local package cache",
41
45
  "monitor" => "ad-hoc package manager for custom installations (like instmon)",
42
46
  "keys" => "keyrings and package authentication",
43
47
  "default" => "configure the action to take when no arguments are passed to 'upm' (defaults to 'os:update')",
44
48
  "stats" => "show statistics about package database(s)",
49
+ "repos/mirrors/sources/channels" => "manage subscriptions to remote repositories/mirrors/channels",
45
50
  }
46
51
 
47
52
  ALIASES = {
48
- "file" => "files",
49
- "sync" => "update",
50
- "sources" => "mirrors",
51
- "show" => "info",
52
- "vuln" => "audit",
53
- "vulns" => "audit",
54
- "check" => "verify",
55
- "u" => "upgrade",
56
- "i" => "install",
57
- "d" => "download",
58
- "s" => "search",
59
- "f" => "files",
60
- "r" => "remove",
53
+ "u" => "upgrade",
54
+ "i" => "install",
55
+ "d" => "download",
56
+ "s" => "search",
57
+ "f" => "files",
58
+ "r" => "remove",
59
+ "m" => "mirrors",
60
+ "file" => "files",
61
+ "vuln" => "audit",
61
62
  "source-search" => "search-sources",
62
63
  }
63
64
 
65
+ COMMAND_HELP.keys.each do |key|
66
+ cmd, *alts = key.split("/")
67
+ alts.each do |alt|
68
+ ALIASES[alt] = cmd
69
+ end
70
+ end
71
+
64
72
  def initialize(name, &block)
65
73
  @name = name
66
74
 
@@ -2,6 +2,11 @@ module UPM
2
2
  class Tool
3
3
  class << self
4
4
 
5
+ def error(message)
6
+ $stderr.puts message
7
+ exit 1
8
+ end
9
+
5
10
  def tools; @@tools; end
6
11
 
7
12
  def register_tools!
@@ -15,7 +20,7 @@ module UPM
15
20
  end
16
21
  Hash[pairs]
17
22
  rescue Errno::ENOENT
18
- {}
23
+ nil
19
24
  end
20
25
  end
21
26
 
@@ -26,13 +31,18 @@ module UPM
26
31
  else
27
32
  # `uname -s` => Darwin|FreeBSD|OpenBSD
28
33
  # `uname -o` => Android|Cygwin
29
- [`uname -s`, `uname -o`].map(&:chomp).uniq
34
+ names = [`uname -s`]
35
+ names << `uname -o` unless names.first =~ /OpenBSD/
36
+ names.map(&:chomp).uniq
30
37
  end
31
38
  end
32
39
 
33
40
  def nice_os_name
34
- os_release.values_at("PRETTY_NAME", "NAME", "ID", "ID_LIKE").first ||
35
- (`uname -o`.chomp rescue nil)
41
+ if os_release
42
+ os_release.values_at("PRETTY_NAME", "NAME", "ID", "ID_LIKE").first
43
+ else
44
+ (`uname -o 2> /dev/null`.chomp rescue nil)
45
+ end
36
46
  end
37
47
 
38
48
  def installed
@@ -45,14 +55,14 @@ module UPM
45
55
  tool = nil
46
56
 
47
57
  if os_names.any?
48
- tool = @@tools.find { |name, tool| os_names.any? { |name| tool.os.include? name } }
58
+ tool = @@tools.find { |name, tool| os_names.any? { |name| tool.os&.include? name } }
49
59
  end
50
60
 
51
61
  if tool.nil?
52
62
  tool = @@tools.find { |name, tool| File.which(tool.identifying_binary) }
53
63
  end
54
64
 
55
- tool.last
65
+ tool&.last
56
66
  end
57
67
 
58
68
  end
@@ -0,0 +1,60 @@
1
+ class GUIXPackage < Struct.new(:name, :version, :out, :path)
2
+ def self.from_line(line)
3
+ new(*line.chomp.split)
4
+ end
5
+
6
+ def self.installed
7
+ @installed_packages ||= IO.popen(["guix", "package", "--list-installed"]) { |io| io.each_line.map { |line| GUIXPackage.from_line(line) } }
8
+ end
9
+
10
+ def self.avaialble
11
+ @available_packages ||= IO.popen(["guix", "package", "--list-available"]) { |io| io.each_line.map { |line| GUIXPackage.from_line(line) } }
12
+ end
13
+
14
+ def installed?
15
+ !!path[%r{^/gnu/store/}]
16
+ end
17
+ end
18
+
19
+
20
+ UPM::Tool.new "guix" do
21
+
22
+ identifying_binary "guix"
23
+
24
+ command "install", "guix install"
25
+ command "remove", "guix remove"
26
+ command "info", "guix show"
27
+ command "rollback", "guix package –roll-back"
28
+ command "selfupdate", "guix pull"
29
+ command "upgrade", "guix package --upgrade"
30
+
31
+ command "files", paged: true do |args|
32
+ error "Ope, you forgot the package name!" if args.empty?
33
+
34
+ args.each do |arg|
35
+ if pkg = GUIXPackage.installed.find { |pkg| pkg.name == arg }
36
+ run "find", pkg.path, paged: true
37
+ else
38
+ error "#{arg.inspect} not found"
39
+ end
40
+ end
41
+ end
42
+
43
+ command "search" do |args|
44
+ query = args.join(" ")
45
+ highlight_query = args.join(".+")
46
+ grep_query = args.join(".+")
47
+ run "guix", "package", "--list-available", sort: true, grep: grep_query, paged: true, highlight: highlight_query
48
+ end
49
+
50
+ command "list" do |args|
51
+ if args.any?
52
+ highlight_query = args.join(".+")
53
+ grep_query = /#{highlight_query}/
54
+ run "guix", "package", "--list-installed", grep: grep_query, highlight: highlight_query, paged: true
55
+ else
56
+ run "guix", "package", "--list-installed", paged: true
57
+ end
58
+ end
59
+
60
+ end
@@ -1,5 +1,4 @@
1
1
  UPM::Tool.new "pacman" do
2
-
3
2
  os "arch"
4
3
 
5
4
  bin = ["pacman", "--color=always"]
@@ -17,6 +16,7 @@ UPM::Tool.new "pacman" do
17
16
  command "audit", "arch-audit", paged: true
18
17
  command "files", [*bin, "-Ql"], paged: true
19
18
  command "search", [*bin, "-Ss"], paged: true, highlight: true
19
+ command "locate", ["pkgfile", "-r"], paged: true
20
20
 
21
21
  command "info" do |args|
22
22
  run(*bin, "-Qi", *args, paged: true) || run(*bin, "-Si", *args, paged: true)
@@ -106,4 +106,39 @@ UPM::Tool.new "pacman" do
106
106
 
107
107
  end
108
108
 
109
+ command "rdeps" do |args|
110
+ packages_that_depend_on = proc do |package|
111
+ result = []
112
+
113
+ # [`pacman -Sii #{package}`, `pacman -Qi #{package}`].each do |output|
114
+ [`pacman -Sii #{package}`].each do |output|
115
+ output.each_line do |l|
116
+ if l =~ /Required By\s+: (.+)/
117
+ result += $1.strip.split unless $1["None"]
118
+ break
119
+ end
120
+ end
121
+ end
122
+
123
+ result
124
+ end
125
+
126
+ args.each do |package|
127
+ puts "<8>=== <14>#{package} <8>============".colorize
128
+ puts
129
+
130
+ packages = packages_that_depend_on.call package
131
+
132
+ if packages.empty?
133
+ puts " <12>None".colorize
134
+ else
135
+ run "pacman", "-Ss", "^(#{packages.join '|'})$" # upstream packages
136
+ run "pacman", "-Qs", "^(#{packages.join '|'})$" # packages that are only installed locally
137
+ end
138
+
139
+ puts
140
+ end
141
+ end
109
142
  end
143
+
144
+
@@ -0,0 +1,24 @@
1
+ UPM::Tool.new "pkg_add" do
2
+
3
+ os "OpenBSD"
4
+
5
+ command "install", "pkg_add", root: true
6
+ command "remove", "pkg_delete", root: true
7
+ command "upgrade", "pkg_add -u", root: true
8
+ command "clean", "yum clean", root: true
9
+ command "info", "pkg_info", paged: true
10
+ command "files", "pkg_info -L", paged: true
11
+ command "search", "pkg_info -Q", paged: true
12
+ command "verify", "pkg_check"
13
+
14
+ command "list" do |args|
15
+ if args.any?
16
+ highlight_query = args.join(".+")
17
+ grep_query = /#{highlight_query}/
18
+ run "pkg_info", grep: grep_query, highlight: highlight_query, paged: true
19
+ else
20
+ run "pkg_info", paged: true
21
+ end
22
+ end
23
+
24
+ end
@@ -4,12 +4,28 @@ UPM::Tool.new "xbps" do
4
4
 
5
5
  identifying_binary "xbps-install"
6
6
 
7
- command "install", "xbps-install", root: true
8
- command "update", "xbps-install -S", root: true
9
- command "upgrade", "xbps-install -Su", root: true
7
+ command "install", "xbps-install", root: true
8
+ command "remove", "xbps-remove", root: true
9
+ command "update", "xbps-install -S", root: true
10
+ command "upgrade", "xbps-install -Su", root: true
11
+ command "files", "xbps-query -f", paged: true
12
+ command "locate", "xlocate", paged: true
13
+ command "selection", "xbps-query -m", paged: true
14
+ command "rdeps", "xbps-query -X", paged: true
10
15
 
11
- command "files", "xbps-query -f", paged: true
12
- command "search", "xbps-query --regex -Rs", paged: true
16
+ command "info" do |args|
17
+ args.each do |arg|
18
+ unless run("xbps-query", "-S", arg)
19
+ run("xbps-query", "-R", "-S", arg)
20
+ end
21
+ puts
22
+ end
23
+ end
24
+
25
+ command "search" do |args|
26
+ query = args.join(".*")
27
+ run "xbps-query", "--regex", "-Rs", query, highlight: /(#{ args.join("|") })/i, paged: true
28
+ end
13
29
 
14
30
  command "list" do |args|
15
31
  if args.any?
@@ -20,4 +36,49 @@ UPM::Tool.new "xbps" do
20
36
  end
21
37
  end
22
38
 
39
+
40
+
41
+ class XBPSPackage < Struct.new(:name, :version, :date)
42
+ def self.from_line(line)
43
+ # zd1211-firmware-1.5_3: 2021-09-01 15:22 UTC
44
+ if line =~ /^([\w\-]+)-([\d\.]+_\d+): (.+)$/
45
+ name, version, date = $1, $2, $3
46
+ date = DateTime.parse($3)
47
+ new(name, version, date)
48
+ else
49
+ nil
50
+ end
51
+ end
52
+
53
+ def to_s
54
+ "[#{date.strftime("%Y-%m-%d %H:%M:%S")}] #{name} #{version}"
55
+ end
56
+ end
57
+
58
+ command "log" do |args|
59
+ fakedata = %{
60
+ xset-1.2.4_1: 2021-11-05 15:03 UTC
61
+ xsetroot-1.1.2_1: 2021-11-05 15:03 UTC
62
+ xtools-0.63_1: 2021-11-05 16:36 UTC
63
+ xtrans-1.4.0_2: 2021-11-05 15:26 UTC
64
+ xvidcore-1.3.7_1: 2021-11-05 16:45 UTC
65
+ xvinfo-1.1.4_2: 2021-11-05 15:03 UTC
66
+ xwd-1.0.8_1: 2021-11-05 15:03 UTC
67
+ xwininfo-1.1.5_1: 2021-11-05 15:03 UTC
68
+ xwud-1.0.5_1: 2021-11-05 15:03 UTC
69
+ xz-5.2.5_2: 2021-11-05 15:12 UTC
70
+ zd1211-firmware-1.5_3: 2021-09-01 15:22 UTC
71
+ zip-3.0_6: 2021-11-05 17:45 UTC
72
+ zlib-1.2.11_4: 2021-09-01 14:14 UTC
73
+ zlib-devel-1.2.11_4: 2021-11-05 15:26 UTC
74
+ }
75
+
76
+ data = IO.popen(["xbps-query", "-p", "install-date", "-s", ""], &:read)
77
+ packages = data.each_line.map do |line|
78
+ XBPSPackage.from_line(line.strip)
79
+ end.compact
80
+ packages.sort_by!(&:date)
81
+ packages.each { |pkg| puts pkg }
82
+ end
23
83
  end
84
+
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.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - epitron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-14 00:00:00.000000000 Z
11
+ date: 2021-11-08 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.
@@ -44,9 +44,11 @@ files:
44
44
  - lib/upm/tool_dsl.rb
45
45
  - lib/upm/tools/apk.rb
46
46
  - lib/upm/tools/apt.rb
47
+ - lib/upm/tools/guix.rb
47
48
  - lib/upm/tools/opkg.rb
48
49
  - lib/upm/tools/pacman.rb
49
50
  - lib/upm/tools/pkg.rb
51
+ - lib/upm/tools/pkg_add.rb
50
52
  - lib/upm/tools/pkgin.rb
51
53
  - lib/upm/tools/xbps.rb
52
54
  - lib/upm/tools/yum.rb
@@ -71,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
73
  - !ruby/object:Gem::Version
72
74
  version: '0'
73
75
  requirements: []
74
- rubygems_version: 3.1.4
76
+ rubygems_version: 3.2.22
75
77
  signing_key:
76
78
  specification_version: 4
77
79
  summary: Universal Package Manager