From 47eeacf1a51647d534bed2f8c9fb40b2dff70dc2 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Sat, 22 May 2021 17:25:36 -0700 Subject: [PATCH] Add AdvMakefile and .gitm.toml --- .gitm.toml | 4 ++++ AdvMakefile | 39 +++++++++++++++++++++++++++++++++++++++ Makefile | 4 ++-- go.sum | 4 ++++ pak.toml | 2 +- 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .gitm.toml create mode 100644 AdvMakefile diff --git a/.gitm.toml b/.gitm.toml new file mode 100644 index 0000000..7b781b7 --- /dev/null +++ b/.gitm.toml @@ -0,0 +1,4 @@ +[repos] +origin = "ssh://git@192.168.100.62:2222/Arsen6331/pak.git" +gitlab = "git@gitlab.com:moussaelianarsen/pak.git" +github = "git@github.com:Arsen6331/pak.git" diff --git a/AdvMakefile b/AdvMakefile new file mode 100644 index 0000000..f12a86a --- /dev/null +++ b/AdvMakefile @@ -0,0 +1,39 @@ +defaultName = "pak" +defaultTarget = "build" +availableManagers = [ + "apk", + "apt", + "aptitude", + "brew", + "dnf", + "yum", + "npm", + "pacman", + "yay", + "pip", + "snap", + "zypper" + ] + + +def pak_build(): + if lookPath("go") == -1: + log("Go must be installed to compile pak", level="fatal") + execute("go build") + + +def pak_install(): + mappings = {"PKGMANAGER": userChoice("Choose package manager", availableManagers)} + expandFile("pak.toml", mappings) + execute(""" + install -Dm755 pak $DESTDIR/usr/bin/pak + install -Dm644 pak.toml $DESTDIR/etc/pak.toml + """) + + +def pak_install_noninteractive(): + expandFile("pak.toml", {"PKGMANAGER": getEnv("PAK_CFG_MGR")}) + execute(""" + install -Dm755 pak $DESTDIR/usr/bin/pak + install -Dm644 pak.toml $DESTDIR/etc/pak.toml + """) diff --git a/Makefile b/Makefile index 6db8ba3..9666fb0 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ all: main.go install: PAK_CFG_MGR ?= apt install: pak.toml pak install -Dm755 pak $(DESTDIR)/usr/bin/pak - sed 's/activeManager = ""/activeManager = "$(PAK_CFG_MGR)"/' pak.toml > pak-new.toml - install -Dm644 pak-new.toml $(DESTDIR)/etc/pak.toml + sed -i 's/activeManager = "\$PKGMANAGER"/activeManager = "$(PAK_CFG_MGR)"/' pak.toml + install -Dm644 pak.toml $(DESTDIR)/etc/pak.toml installbinonly: pak install -Dm755 pak $(DESTDIR)/usr/bin/pak diff --git a/go.sum b/go.sum index 28dd079..d9569ed 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +gitea.arsenm.dev/Arsen6331/go-tuntox v0.0.0-20210122202525-119d5f454187 h1:5zN850TL+/3lHdUEGbQ29C4KPFwDLodWSaKjLFiWeJk= +gitea.arsenm.dev/Arsen6331/go-tuntox v0.0.0-20210122202525-119d5f454187/go.mod h1:88Isb/DdiGw2c82x+cjOOmqyka6Om0DbMRlshjEBG1s= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -12,6 +14,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a h1:DcqTD9SDLc+1P/r1EmRBwnVsrOwW+kk2vWf9n+1sGhs= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190828213141-aed303cbaa74/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= diff --git a/pak.toml b/pak.toml index b9d3688..06d9632 100644 --- a/pak.toml +++ b/pak.toml @@ -1,4 +1,4 @@ -activeManager = "" +activeManager = "$PKGMANAGER" rootCommand = "sudo" [managers]