chore(gonf): fix errcheck and shadow errors
This commit is contained in:
parent
72be13c3e9
commit
8b9195e3e3
15 changed files with 65 additions and 80 deletions
|
@ -14,10 +14,10 @@ import (
|
|||
var packages map[string]string
|
||||
|
||||
func init() {
|
||||
packages_list()
|
||||
packagesList()
|
||||
}
|
||||
|
||||
func packages_install(names []string) (gonf.Status, []string) {
|
||||
func packagesInstall(names []string) (gonf.Status, []string) {
|
||||
gonf.FilterSlice(&names, func(n string) bool {
|
||||
_, ok := packages[n]
|
||||
return !ok
|
||||
|
@ -28,11 +28,11 @@ func packages_install(names []string) (gonf.Status, []string) {
|
|||
args := append([]string{"install", "-y", "--no-install-recommends"}, names...)
|
||||
cmd := gonf.CommandWithEnv([]string{"DEBIAN_FRONTEND=noninteractive", "LC_ALL=C"}, "apt-get", args...)
|
||||
cmd.Resolve()
|
||||
packages_list()
|
||||
packagesList()
|
||||
return cmd.Status(), names
|
||||
}
|
||||
|
||||
func packages_list() {
|
||||
func packagesList() {
|
||||
packages = make(map[string]string)
|
||||
ecmd := exec.Command("dpkg-query", "-W")
|
||||
out, err := ecmd.CombinedOutput()
|
||||
|
|
|
@ -2,21 +2,22 @@ package debian
|
|||
|
||||
import (
|
||||
_ "embed"
|
||||
"git.adyxax.org/adyxax/gonf/v2/pkg"
|
||||
|
||||
gonf "git.adyxax.org/adyxax/gonf/v2/pkg"
|
||||
"git.adyxax.org/adyxax/gonf/v2/stdlib/os/linux"
|
||||
"git.adyxax.org/adyxax/gonf/v2/stdlib/os/systemd"
|
||||
)
|
||||
|
||||
//go:embed apt-norecommends
|
||||
var apt_norecommends []byte
|
||||
var aptNoRecommends []byte
|
||||
|
||||
//go:embed sources.list
|
||||
var sources_list []byte
|
||||
var sourcesList []byte
|
||||
|
||||
func Promise() {
|
||||
// ----- gonf --------------------------------------------------------------
|
||||
apt_update := gonf.Command("apt-get", "update", "-qq")
|
||||
gonf.SetPackagesConfiguration(packages_install, apt_update)
|
||||
aptUpdate := gonf.Command("apt-get", "update", "-qq")
|
||||
gonf.SetPackagesConfiguration(packagesInstall, aptUpdate)
|
||||
gonf.SetUsersConfiguration(linux.Useradd)
|
||||
// ----- systemd -----------------------------------------------------------
|
||||
systemd.Promise()
|
||||
|
@ -27,12 +28,12 @@ func Promise() {
|
|||
gonf.AppendVariable("debian-extra-sources", "# Extra sources")
|
||||
gonf.File("/etc/apt/sources.list").
|
||||
Permissions(rootRO).
|
||||
Template(sources_list).
|
||||
Template(sourcesList).
|
||||
Promise().
|
||||
IfRepaired(apt_update)
|
||||
IfRepaired(aptUpdate)
|
||||
gonf.File("/etc/apt/apt.conf.d/99_norecommends").
|
||||
DirectoriesPermissions(rootDir).
|
||||
Permissions(rootRO).
|
||||
Contents(apt_norecommends).
|
||||
Contents(aptNoRecommends).
|
||||
Promise()
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
)
|
||||
|
||||
func Promise() {
|
||||
gonf.SetServiceFunction(systemd_service)
|
||||
gonf.SetServiceFunction(systemdService)
|
||||
}
|
||||
|
||||
func isEnabled(name string) bool {
|
||||
|
@ -33,7 +33,7 @@ func systemctlShow(name, field string) string {
|
|||
return string(out[:len(out)-1]) // remove trailing '\n' and convert to string
|
||||
}
|
||||
|
||||
func systemd_service(name, state string) (gonf.Status, error) {
|
||||
func systemdService(name, state string) (gonf.Status, error) {
|
||||
switch state {
|
||||
case "disabled":
|
||||
if isEnabled(name) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue