commit 036f8e4c5be059268b632ada243178e80e70cc5f Author: Amir Husayn Panahifar Date: Thu Oct 15 14:29:18 2026 +0330 chore: bootstrap Go module, build tooling and license diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69468a --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +# Build artifacts +/bin/ +/dist/ +/prx +/prx-helper + +# Test / scratch +*.out +*.test +/coverage.txt + +# Editor +.idea/ +.vscode/ +*.swp diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bf49d2f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Amir Husayn Panahifar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a38e45b --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +VERSION ?= 0.1.0 +COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none) +DATE ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ) +LDFLAGS := -s -w -X prx/internal/version.Version=$(VERSION) -X prx/internal/version.Commit=$(COMMIT) -X prx/internal/version.Date=$(DATE) +PREFIX ?= /usr +BINDIR ?= $(PREFIX)/bin +LIBDIR ?= $(PREFIX)/lib/prx +MANDIR ?= $(PREFIX)/share/man + +.PHONY: all build test vet fmt lint clean install uninstall integration man + +all: build + +build: + CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/prx ./cmd/prx + CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o bin/prx-helper ./cmd/prx-helper + +test: + go test ./... + +vet: + go vet ./... + +fmt: + gofmt -w . + +lint: vet + gofmt -l . | tee /dev/stderr | wc -l | grep -q '^0$$' + +integration: build + PRX_BIN=$(CURDIR)/bin/prx sudo -E ./scripts/integration-test.sh + +install: build + install -Dm755 bin/prx $(DESTDIR)$(BINDIR)/prx + install -Dm755 bin/prx-helper $(DESTDIR)$(LIBDIR)/prx-helper + install -Dm644 polkit/org.prx.policy $(DESTDIR)$(PREFIX)/share/polkit-1/actions/org.prx.policy + install -Dm644 systemd/prx-reapply.service $(DESTDIR)$(PREFIX)/lib/systemd/system/prx-reapply.service + install -Dm644 systemd/prx-reapply.timer $(DESTDIR)$(PREFIX)/lib/systemd/system/prx-reapply.timer + install -Dm644 man/prx.1 $(DESTDIR)$(MANDIR)/man1/prx.1 + install -Dm644 man/prx-helper.1 $(DESTDIR)$(MANDIR)/man1/prx-helper.1 + +# Validate the man pages with groff (no-op if groff is unavailable). +man: + @command -v groff >/dev/null 2>&1 && groff -man -Tutf8 -z man/prx.1 man/prx-helper.1 && echo "man: ok" || echo "man: groff not installed, skipped" + +uninstall: + rm -f $(DESTDIR)$(BINDIR)/prx + rm -f $(DESTDIR)$(LIBDIR)/prx-helper + rm -f $(DESTDIR)$(PREFIX)/share/polkit-1/actions/org.prx.policy + rm -f $(DESTDIR)$(PREFIX)/lib/systemd/system/prx-reapply.service + rm -f $(DESTDIR)$(PREFIX)/lib/systemd/system/prx-reapply.timer + rm -f $(DESTDIR)$(MANDIR)/man1/prx.1 + rm -f $(DESTDIR)$(MANDIR)/man1/prx-helper.1 + +clean: + rm -rf bin diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..75185b8 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module prx + +go 1.24 + +require github.com/spf13/cobra v1.10.2 + +require ( + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/pflag v1.0.9 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..a6ee3e0 --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=