/
tlmgr_package_dumper.rb
36 lines (31 loc) 路 1.01 KB
/
tlmgr_package_dumper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true
module Bundle
module TlmgrPackageDumper
module_function
def reset!
@packages = nil
@outdated_packages = nil
end
def packages
@packages ||= if Bundle.tlmgr_installed?
`tlmgr info --only-installed 2>/dev/null`.split("\n").map { |l| l.match(/i ([^:]+).*/)[1] }.map(&:downcase)
else
[]
end
end
# TODO: See how we can get around the sudo requirement because of the way e.g. basictex installs itself
# See also https://tug.org/texlive/doc/tlmgr.html#USER-MODE
def outdated_packages
@outdated_packages ||= if Bundle.tlmgr_installed?
`sudo tlmgr update --all --dry-run 2>/dev/null`.split("\n")
.map { |l| l.match(/^update:\s+([^ ]+).*/)[1] }
.reject(&:empty?).map(&:downcase)
else
[]
end
end
def dump
packages.map { |name| "tlmgr \"#{name}\"" }.join("\n")
end
end
end