https://github.com/seletskiy/go-makepkg
Generate PKGBUILD for Golang programs and run makepkg
https://github.com/seletskiy/go-makepkg
Last synced: over 1 year ago
JSON representation
Generate PKGBUILD for Golang programs and run makepkg
- Host: GitHub
- URL: https://github.com/seletskiy/go-makepkg
- Owner: seletskiy
- Created: 2014-12-17T14:07:56.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2021-01-17T16:06:20.000Z (over 5 years ago)
- Last Synced: 2025-03-25T03:35:54.275Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 63
- Watchers: 6
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-makepkg
Tool for fast packaging Golang programs under the archlinux.
It will automatically generate appropriate PKGBUILD and systemd.service files.
## How to use
0. `go get github.com/seletskiy/go-makepkg`;
1. `mkdir some-directory`;
2. `cd some-directory`;
3. `mkdir -p etc/mycoolprog/`;
4. Copy any other required files for you program, like config files:
`cp /example.conf etc/mycoolprog/main.conf`;
5. Omit `-s` flag if you do not want service file:
`go-makepkg -sB "my description" git://url-to-prog/repo.git **/*`;
6. Package is ready for install and located at `build/.tar.xz`;
## Typical invocation
```
go-makepkg -gsB "my cool package" git://github.com/seletskiy/go-makepkg *
```
Will generate .gitignore, PKGBUILD and .service file for specified repo (e.g.
go-makepkg) and include all files under current directory to the package.
If you do not want to build package automatically, omit `-B` flag.
See `go-makepkg -h` for more info.
`go-makepkg` by itself can be packaged using itself:
`go-makepkg -B "go-makepkg tool" git://github.com/seletskiy/go-makepkg.git`
### Pass package version into golang code
As you know, you can change global variables of your Golang program in the
compile time by using `go build` options, like in the following example you can
change variable `packageVersion` using `ldflags`.
```go
package main
import "fmt"
var blahme = "autogenerated"
func main() {
fmt.Println(blahme)
}
```
Value of the `blahme` can be changed:
```
go build -ldflags="-X main.blahme=testvalue" -o test .
```
Run `./test` and you will see `testvalue` instead of hardcoded `autogenerated`
string.
It's very useful opportunity, for escaping the hell of versioning your
software and shift this work to the PKGBUILD.
`go-makepkg` can do it for you, all you need is to specify a variable name
which holds version number using `-p ` flag:
```
go-makepkg -p version "go-makepkg tool" git://github.com/seletskiy/go-makepkg.git
```