feat: add build tag to enable or disable pacman cron checker
This commit is contained in:
parent
0968b75fb8
commit
691f96461e
4
Makefile
4
Makefile
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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 {
|
Loading…
Reference in New Issue