mirror of
https://github.com/philmmanjaro/alma.git
synced 2025-07-26 06:59:28 +02:00
AUR fixes
The commit switches to using yay-bin instead of yay, avoiding the need to install Go. In addition, it fixes a bug where aur packages aren't build when specified only in the command line
This commit is contained in:
parent
fdbe285855
commit
38d0085ba1
@ -3,6 +3,7 @@ use std::str::FromStr;
|
|||||||
|
|
||||||
pub struct AurHelper {
|
pub struct AurHelper {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub package_name: String,
|
||||||
pub install_command: Vec<String>,
|
pub install_command: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ impl FromStr for AurHelper {
|
|||||||
match s {
|
match s {
|
||||||
"yay" => Ok(AurHelper {
|
"yay" => Ok(AurHelper {
|
||||||
name: String::from("yay"),
|
name: String::from("yay"),
|
||||||
|
package_name: String::from("yay-bin"),
|
||||||
install_command: vec![
|
install_command: vec![
|
||||||
String::from("yay"),
|
String::from("yay"),
|
||||||
String::from("-S"),
|
String::from("-S"),
|
||||||
|
@ -10,4 +10,4 @@ SystemMaxUse=16M
|
|||||||
pub const BASE_PACKAGES: [&str; 1] = ["base"];
|
pub const BASE_PACKAGES: [&str; 1] = ["base"];
|
||||||
|
|
||||||
// we add go so that it is cached when installing yay
|
// we add go so that it is cached when installing yay
|
||||||
pub const AUR_DEPENDENCIES: [&str; 4] = ["base-devel", "git", "sudo", "go"];
|
pub const AUR_DEPENDENCIES: [&str; 3] = ["base-devel", "git", "sudo"];
|
||||||
|
33
src/main.rs
33
src/main.rs
@ -225,7 +225,8 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
|||||||
|
|
||||||
packages.extend(presets.packages);
|
packages.extend(presets.packages);
|
||||||
|
|
||||||
if !presets.aur_packages.is_empty() {
|
let use_aur = !(presets.aur_packages.is_empty() && command.aur_packages.is_empty());
|
||||||
|
if use_aur {
|
||||||
packages.extend(constants::AUR_DEPENDENCIES.iter().map(|s| String::from(*s)));
|
packages.extend(constants::AUR_DEPENDENCIES.iter().map(|s| String::from(*s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +277,9 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
|||||||
.run()
|
.run()
|
||||||
.context("locale-gen failed")?;
|
.context("locale-gen failed")?;
|
||||||
|
|
||||||
if !presets.aur_packages.is_empty() {
|
if use_aur {
|
||||||
|
info!("Installing AUR packages");
|
||||||
|
|
||||||
arch_chroot
|
arch_chroot
|
||||||
.execute()
|
.execute()
|
||||||
.arg(mount_point.path())
|
.arg(mount_point.path())
|
||||||
@ -284,16 +287,8 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
|||||||
.run()
|
.run()
|
||||||
.context("Failed to create temporary user to install AUR packages")?;
|
.context("Failed to create temporary user to install AUR packages")?;
|
||||||
|
|
||||||
arch_chroot
|
let aur_sudoers = mount_point.path().join("etc/sudoers.d/aur");
|
||||||
.execute()
|
fs::write(&aur_sudoers, "aur ALL=(ALL) NOPASSWD: ALL")
|
||||||
.arg(mount_point.path())
|
|
||||||
.args(&[
|
|
||||||
"sed",
|
|
||||||
"-i",
|
|
||||||
"s/# %wheel ALL=(ALL) NOPASSWD: ALL/aur ALL=(ALL) NOPASSWD: ALL/g",
|
|
||||||
])
|
|
||||||
.arg("/etc/sudoers")
|
|
||||||
.run()
|
|
||||||
.context("Failed to modify sudoers file for AUR packages")?;
|
.context("Failed to modify sudoers file for AUR packages")?;
|
||||||
|
|
||||||
arch_chroot
|
arch_chroot
|
||||||
@ -304,7 +299,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
|||||||
.arg("clone")
|
.arg("clone")
|
||||||
.arg(format!(
|
.arg(format!(
|
||||||
"https://aur.archlinux.org/{}.git",
|
"https://aur.archlinux.org/{}.git",
|
||||||
&command.aur_helper.name
|
&command.aur_helper.package_name
|
||||||
))
|
))
|
||||||
.arg(format!("/home/aur/{}", &command.aur_helper.name))
|
.arg(format!("/home/aur/{}", &command.aur_helper.name))
|
||||||
.run()
|
.run()
|
||||||
@ -342,17 +337,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
|
|||||||
.run()
|
.run()
|
||||||
.context("Failed to delete temporary aur user")?;
|
.context("Failed to delete temporary aur user")?;
|
||||||
|
|
||||||
arch_chroot
|
fs::remove_file(&aur_sudoers).context("Cannot delete the AUR sudoers temporary file")?;
|
||||||
.execute()
|
|
||||||
.arg(mount_point.path())
|
|
||||||
.args(&[
|
|
||||||
"sed",
|
|
||||||
"-i",
|
|
||||||
"s/aur ALL=(ALL) NOPASSWD: ALL/# %wheel ALL=(ALL) NOPASSWD: ALL/g",
|
|
||||||
])
|
|
||||||
.arg("/etc/sudoers")
|
|
||||||
.run()
|
|
||||||
.context("Failed to undo sudoers changes")?;
|
|
||||||
}
|
}
|
||||||
if !presets.scripts.is_empty() {
|
if !presets.scripts.is_empty() {
|
||||||
info!("Running custom scripts");
|
info!("Running custom scripts");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user