seletskiy / go-makepkg

Generate PKGBUILD for Golang programs and run makepkg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-makepkg

Tool for fast packaging Golang programs under the archlinux.

It will automatically generate appropriate PKGBUILD and systemd.service files.

How to use

  1. go get github.com/seletskiy/go-makepkg;
  2. mkdir some-directory;
  3. cd some-directory;
  4. mkdir -p etc/mycoolprog/;
  5. Copy any other required files for you program, like config files:
    cp <somepath>/example.conf etc/mycoolprog/main.conf;
  6. Omit -s flag if you do not want service file:
    go-makepkg -sB "my description" git://url-to-prog/repo.git **/*;
  7. Package is ready for install and located at build/<blah>.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.

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 <var> flag:

go-makepkg -p version "go-makepkg tool" git://github.com/seletskiy/go-makepkg.git

About

Generate PKGBUILD for Golang programs and run makepkg


Languages

Language:Go 100.0%