feat: add build tag to enable or disable pacman cron checker

This commit is contained in:
Paulo 2023-07-27 21:40:28 -03:00
parent 0968b75fb8
commit 691f96461e
Signed by: pauloo27
GPG Key ID: F5F12B13882CBC3C
3 changed files with 36 additions and 1 deletions

View File

@ -4,6 +4,10 @@ BINARY_NAME = f
build:
CGO_ENABLED=0 go build -v -o $(BINARY_NAME) .
.PHONY: build-updates
build-updates:
CGO_ENABLED=0 go build -v -tags arch_updates -o $(BINARY_NAME) .
# (build but with a smaller binary)
.PHONY: dist
dist:

29
fetch/pkg_pacman.go Normal file
View File

@ -0,0 +1,29 @@
//go:build !arch_updates
package fetch
import (
"os"
)
const (
installedPkgsPath = "/var/lib/pacman/local/"
)
type PkgInfo struct {
Installed int
AvailableUpdates int
}
func Pkgs() (*PkgInfo, error) {
installed, err := listPkgsPacman()
if err != nil {
return nil, err
}
return &PkgInfo{installed, 0}, nil
}
func listPkgsPacman() (int, error) {
files, err := os.ReadDir(installedPkgsPath)
return len(files), err
}

View File

@ -1,3 +1,5 @@
//go:build arch_updates
package fetch
import (
@ -9,7 +11,7 @@ import (
const (
installedPkgsPath = "/var/lib/pacman/local/"
availableUpdatesPath = "/.cache/cupdates"
availableUpdatesPath = "/.cache/available_updates"
)
type PkgInfo struct {