Allow tlmgr to run in Linux (fix #406)
This commit is contained in:
committed by
GitHub
parent
89578a7fd9
commit
98657edb60
@@ -58,3 +58,4 @@
|
|||||||
# Arguments to pass yay when updating packages
|
# Arguments to pass yay when updating packages
|
||||||
#yay_arguments = "--nodevel"
|
#yay_arguments = "--nodevel"
|
||||||
#trizen_arguments = "--devel"
|
#trizen_arguments = "--devel"
|
||||||
|
#enable_tlmgr = true
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ pub struct Linux {
|
|||||||
yay_arguments: Option<String>,
|
yay_arguments: Option<String>,
|
||||||
trizen_arguments: Option<String>,
|
trizen_arguments: Option<String>,
|
||||||
dnf_arguments: Option<String>,
|
dnf_arguments: Option<String>,
|
||||||
|
enable_tlmgr: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug)]
|
#[derive(Deserialize, Default, Debug)]
|
||||||
@@ -439,6 +440,16 @@ impl Config {
|
|||||||
.and_then(|linux| linux.dnf_arguments.as_deref())
|
.and_then(|linux| linux.dnf_arguments.as_deref())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Extra yay arguments
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn enable_tlmgr_linux(&self) -> bool {
|
||||||
|
self.config_file
|
||||||
|
.linux
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|linux| linux.enable_tlmgr)
|
||||||
|
.unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn use_predefined_git_repos(&self) -> bool {
|
pub fn use_predefined_git_repos(&self) -> bool {
|
||||||
!self.opt.disable_predefined_git_repos && self.config_file.predefined_git_repos.unwrap_or(true)
|
!self.opt.disable_predefined_git_repos && self.config_file.predefined_git_repos.unwrap_or(true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,10 @@ use crate::config::Config;
|
|||||||
use crate::executor::RunType;
|
use crate::executor::RunType;
|
||||||
use crate::git::Git;
|
use crate::git::Git;
|
||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
#[cfg(unix)]
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub struct ExecutionContext<'a> {
|
pub struct ExecutionContext<'a> {
|
||||||
run_type: RunType,
|
run_type: RunType,
|
||||||
#[cfg(unix)]
|
|
||||||
sudo: &'a Option<PathBuf>,
|
sudo: &'a Option<PathBuf>,
|
||||||
git: &'a Git,
|
git: &'a Git,
|
||||||
config: &'a Config,
|
config: &'a Config,
|
||||||
@@ -37,6 +35,7 @@ impl<'a> ExecutionContext<'a> {
|
|||||||
pub fn new(run_type: RunType, git: &'a Git, config: &'a Config, base_dirs: &'a BaseDirs) -> ExecutionContext<'a> {
|
pub fn new(run_type: RunType, git: &'a Git, config: &'a Config, base_dirs: &'a BaseDirs) -> ExecutionContext<'a> {
|
||||||
ExecutionContext {
|
ExecutionContext {
|
||||||
run_type,
|
run_type,
|
||||||
|
sudo: &None,
|
||||||
config,
|
config,
|
||||||
git,
|
git,
|
||||||
base_dirs,
|
base_dirs,
|
||||||
@@ -51,7 +50,6 @@ impl<'a> ExecutionContext<'a> {
|
|||||||
&self.git
|
&self.git
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
pub fn sudo(&self) -> &Option<PathBuf> {
|
pub fn sudo(&self) -> &Option<PathBuf> {
|
||||||
&self.sudo
|
&self.sudo
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@@ -280,16 +280,7 @@ fn run() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if config.should_run(Step::Tlmgr) {
|
if config.should_run(Step::Tlmgr) {
|
||||||
#[cfg(not(target_os = "linux"))]
|
runner.execute("tlmgr", || generic::run_tlmgr_update(&ctx))?;
|
||||||
runner.execute("tlmgr", || {
|
|
||||||
generic::run_tlmgr_update(
|
|
||||||
#[cfg(unix)]
|
|
||||||
&sudo,
|
|
||||||
#[cfg(windows)]
|
|
||||||
&None,
|
|
||||||
run_type,
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.should_run(Step::Myrepos) {
|
if config.should_run(Step::Myrepos) {
|
||||||
|
|||||||
@@ -117,8 +117,15 @@ pub fn run_stack_update(run_type: RunType) -> Result<()> {
|
|||||||
run_type.execute(&stack).arg("upgrade").check_run()
|
run_type.execute(&stack).arg("upgrade").check_run()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
pub fn run_tlmgr_update(ctx: &ExecutionContext) -> Result<()> {
|
||||||
pub fn run_tlmgr_update(sudo: &Option<PathBuf>, run_type: RunType) -> Result<()> {
|
cfg_if::cfg_if! {
|
||||||
|
if #[cfg(target_os = "linux")] {
|
||||||
|
if !ctx.config().enable_tlmgr_linux() {
|
||||||
|
return Err(SkipStep.into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let tlmgr = utils::require("tlmgr")?;
|
let tlmgr = utils::require("tlmgr")?;
|
||||||
let kpsewhich = utils::require("kpsewhich")?;
|
let kpsewhich = utils::require("kpsewhich")?;
|
||||||
let tlmgr_directory = {
|
let tlmgr_directory = {
|
||||||
@@ -142,9 +149,11 @@ pub fn run_tlmgr_update(sudo: &Option<PathBuf>, run_type: RunType) -> Result<()>
|
|||||||
print_separator("TeX Live package manager");
|
print_separator("TeX Live package manager");
|
||||||
|
|
||||||
let mut command = if directory_writable {
|
let mut command = if directory_writable {
|
||||||
run_type.execute(&tlmgr)
|
ctx.run_type().execute(&tlmgr)
|
||||||
} else {
|
} else {
|
||||||
let mut c = run_type.execute(sudo.as_ref().ok_or(TopgradeError::SudoRequired)?);
|
let mut c = ctx
|
||||||
|
.run_type()
|
||||||
|
.execute(ctx.sudo().as_ref().ok_or(TopgradeError::SudoRequired)?);
|
||||||
c.arg(&tlmgr);
|
c.arg(&tlmgr);
|
||||||
c
|
c
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user