-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
tlmgr
) packages
Allow tlmgr packages to be installed, dumped, checked, updated and cleaned up.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bundle | ||
module Checker | ||
class TlmgrPackageChecker < Bundle::Checker::Base | ||
PACKAGE_TYPE = :tlmgr | ||
PACKAGE_TYPE_NAME = "TeX Live Package" | ||
|
||
def failure_reason(package, no_upgrade:) | ||
"#{PACKAGE_TYPE_NAME} #{package} needs to be installed." | ||
end | ||
|
||
def installed_and_up_to_date?(package, no_upgrade: false) | ||
Bundle::TlmgrPackageInstaller.package_installed?(package) | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# 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) | ||
Check failure on line 14 in lib/bundle/tlmgr_package_dumper.rb
|
||
else | ||
[] | ||
end | ||
end | ||
|
||
# TODO See how we can get around the sudo requirement because of the way e.g. basictex installs itself | ||
Check failure on line 20 in lib/bundle/tlmgr_package_dumper.rb
|
||
# 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 { |l| l.empty? }.map(&:downcase) | ||
Check failure on line 24 in lib/bundle/tlmgr_package_dumper.rb
|
||
else | ||
[] | ||
end | ||
end | ||
|
||
def dump | ||
packages.map { |name| "tlmgr \"#{name}\"" }.join("\n") | ||
end | ||
end | ||
end |