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:
Roey Darwish Dror 2020-11-26 07:04:05 +00:00 committed by Philip Mueller
parent fdbe285855
commit 38d0085ba1
3 changed files with 12 additions and 25 deletions

View File

@ -3,6 +3,7 @@ use std::str::FromStr;
pub struct AurHelper {
pub name: String,
pub package_name: String,
pub install_command: Vec<String>,
}
@ -13,6 +14,7 @@ impl FromStr for AurHelper {
match s {
"yay" => Ok(AurHelper {
name: String::from("yay"),
package_name: String::from("yay-bin"),
install_command: vec![
String::from("yay"),
String::from("-S"),

View File

@ -10,4 +10,4 @@ SystemMaxUse=16M
pub const BASE_PACKAGES: [&str; 1] = ["base"];
// 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"];

View File

@ -225,7 +225,8 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
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)));
}
@ -276,7 +277,9 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
.run()
.context("locale-gen failed")?;
if !presets.aur_packages.is_empty() {
if use_aur {
info!("Installing AUR packages");
arch_chroot
.execute()
.arg(mount_point.path())
@ -284,16 +287,8 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
.run()
.context("Failed to create temporary user to install AUR packages")?;
arch_chroot
.execute()
.arg(mount_point.path())
.args(&[
"sed",
"-i",
"s/# %wheel ALL=(ALL) NOPASSWD: ALL/aur ALL=(ALL) NOPASSWD: ALL/g",
])
.arg("/etc/sudoers")
.run()
let aur_sudoers = mount_point.path().join("etc/sudoers.d/aur");
fs::write(&aur_sudoers, "aur ALL=(ALL) NOPASSWD: ALL")
.context("Failed to modify sudoers file for AUR packages")?;
arch_chroot
@ -304,7 +299,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
.arg("clone")
.arg(format!(
"https://aur.archlinux.org/{}.git",
&command.aur_helper.name
&command.aur_helper.package_name
))
.arg(format!("/home/aur/{}", &command.aur_helper.name))
.run()
@ -342,17 +337,7 @@ fn create(command: args::CreateCommand) -> anyhow::Result<()> {
.run()
.context("Failed to delete temporary aur user")?;
arch_chroot
.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")?;
fs::remove_file(&aur_sudoers).context("Cannot delete the AUR sudoers temporary file")?;
}
if !presets.scripts.is_empty() {
info!("Running custom scripts");