From 93fe7a13bdd49f167253d4b9d425678660772c90 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 28 Sep 2025 02:52:39 -0400 Subject: [PATCH] Third round of fixes --- applications.go | 3 +-- system.go | 29 ++++++++++++++++++++++------- utilities.go | 21 +++++++++++++-------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/applications.go b/applications.go index daa5561..d1590de 100644 --- a/applications.go +++ b/applications.go @@ -10,7 +10,7 @@ import ( func applications() { for { var doAll bool - choice := front.InputMenuGen("Application to install:", []string{"back", "all", "pamac-aur (replaces octopi)", "yay-bin (replaces paru)", "htop (replaces btop)", "neovim (replaces vi+vim+nano+micro)", "virt-manager (also installs qemu-desktop+libvirt)", "librewolf-bin", "zed", "steam"}) + choice := front.InputMenuGen("Application to install:", []string{"back", "all", "pamac-aur", "yay-bin (replaces paru)", "htop (replaces btop)", "neovim (replaces vi+vim+nano+micro)", "virt-manager (also installs qemu-desktop+libvirt)", "librewolf-bin", "zed", "steam"}) switch choice { case 1: return @@ -19,7 +19,6 @@ func applications() { fallthrough case 3: managePackage("-S", "pamac-aur") - managePackage("-Rcns", "octopi") if !doAll { break diff --git a/system.go b/system.go index e3648f5..82cd258 100644 --- a/system.go +++ b/system.go @@ -21,8 +21,18 @@ func system() { doAll = true fallthrough case 3: + err := os.RemoveAll("/tmp/custom-base-devel/") + if err != nil { + other.PrintError("Failed to remove /tmp/custom-base-devel", 1) + } writeFile("/etc/doas.conf", "permit persist keepenv :wheel as root\n", "root", 0644) - writeFile("/tmp/PKGBUILD", `pkgname=base-devel + err = os.MkdirAll("/tmp/custom-base-devel", 0777) + if err != nil { + other.PrintError("Failed to create /tmp/custom-base-devel/", 1) + } + uid := getUID() + err = os.Chown("/tmp/custom-base-devel", uid, uid) + writeFile("/tmp/custom-base-devel/PKGBUILD", `pkgname=base-devel pkgver=1 pkgrel=2 pkgdesc='Basic tools to build Arch Linux packages' @@ -62,13 +72,18 @@ depends=( # vim: ts=2 sw=2 et: `, getUsername(), 0777) - cmd := exec.Command("sudo", "-u", getUsername(), "makepkg", "-si", "--dir", "/tmp") - err := cmd.Run() + cmd := exec.Command("sudo", "-u", getUsername(), "makepkg", "--dir", "/tmp/custom-base-devel") + err = cmd.Run() if err != nil { - other.PrintError("Failed to build+install custom base-devel", 1) + other.PrintError("Failed to build+install custom base-devel: "+err.Error(), 1) } + managePackage("-U", "/tmp/custom-base-devel/base-devel-1-2-any.pkg.tar.xz") managePackage("-S", "opendoas") - managePackage("-R", "sudo") + cmd = exec.Command("pacman", "-R", "sudo", "qt-sudo", "octopi") + err = cmd.Run() + if err != nil { + other.PrintError("Failed to remove sudo", 1) + } if !doAll { break @@ -82,9 +97,9 @@ depends=( var sysctlConf strings.Builder sysctlConf.WriteString("net.ipv6.conf.all.use_tempaddr = 2\nnet.ipv6.conf.default.use_tempaddr = 2") for _, nic := range nics { - sysctlConf.WriteString("\nnet.ipv6.conf." + nic.Name() + "use_tempaddr = 2\n") + sysctlConf.WriteString("\nnet.ipv6.conf." + nic.Name() + ".use_tempaddr = 2") } - writeFile("/etc/sysctl.d/40-ipv6-priv-ext.conf", sysctlConf.String(), "root", 0644) + writeFile("/etc/sysctl.d/40-ipv6-priv-ext.conf", sysctlConf.String()+"\n", "root", 0644) if !doAll { break diff --git a/utilities.go b/utilities.go index 45f746e..8ac07b7 100644 --- a/utilities.go +++ b/utilities.go @@ -37,14 +37,7 @@ func writeFile(path, data, owner string, perms os.FileMode) { other.PrintError("Failed to write to "+path+":"+err.Error(), 1) } if owner != "root" { - userInfo, err := user.Lookup(owner) - if err != nil { - other.PrintError("Failed to lookup UID for "+owner, 1) - } - uid, err := strconv.Atoi(userInfo.Uid) - if err != nil { - other.PrintError("Failed to convert UID to integer", 1) - } + uid := getUID() err = os.Chown(path, uid, uid) if err != nil { other.PrintError("Failed to set ownership of "+path, 1) @@ -59,3 +52,15 @@ func getUsername() string { localUsername := username return localUsername } + +func getUID() int { + userInfo, err := user.Lookup(getUsername()) + if err != nil { + other.PrintError("Failed to lookup UID for "+getUsername(), 1) + } + uid, err := strconv.Atoi(userInfo.Uid) + if err != nil { + other.PrintError("Failed to convert UID to integer", 1) + } + return uid +}