Third round of fixes

This commit is contained in:
2025-09-28 02:52:39 -04:00
parent 0b398e789f
commit 93fe7a13bd
3 changed files with 36 additions and 17 deletions
+1 -2
View File
@@ -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
+22 -7
View File
@@ -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
+13 -8
View File
@@ -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
}