Free as in Freedom: Codeberg.org. Create your repos and join us!
Join Donate
Some Go helpers to create distribution dir trees for software packages
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Marcus 5d8a72e379 Merge branch 'master' into pub/codeberg 6 days ago
versioner Fixed incomplete migration of versioner to qbsllm 6 days ago
.gitignore migrate to codeberg 3 weeks ago
.travis.yml generate timestamp attribute with time now() 3 weeks ago
LICENSE generate timestamp attribute with time now() 3 weeks ago
Makefile migrate to codeberg 3 weeks ago
README.md versioner check for SemVer conventions 3 weeks ago
VERSION Fixed incomplete migration of versioner to qbsllm 6 days ago
arch.go generate timestamp attribute with time now() 3 weeks ago
autocover.sh migrate to codeberg 3 weeks ago
coverage.html migrate to codeberg 3 weeks ago
doc.go ICI 6 months ago
files.go API change in sllm 2 weeks ago
logging.go use qbsllm 3 weeks ago
version.go Fixed incomplete migration of versioner to qbsllm 6 days ago

README.md

pack

Test Coverage Go Report Card GoDoc

import "git.fractalqb.de/fractalqb/pack"


Intro

For Go packages it is common and good style to have packages installabel with a simple go get... command. This is supported in a great way by having so many good tools being part of the Go distribution. However sometimes applications might require to be distributed as a binary package with a crafted distribution file-tree – especially when users are not expected to compile the application themselves.

To have a portable way to pack such a distribution one would need a portable runtime for the program that does the packing. So why not write the packing program in Go? Most of the batteries are already included in Go but IMHO they could use a little polishing, i.e. lifting the API abstraction, to make the packing code even more simple. And exactly that’s what this package is provided for!

By the way…

There is just a little tool included to create a source file with constants defining the current version of the package. The idea is extraordinary simple: Write down the version parameters in a separate text file, e.g. VERSION, from which not only the Go code can be generated but that also can likely be processed by a lot of other programs too, e.g. shell, makefiles, Python and many others:

major=0
minor=2
patch=3
quality=a

With such a simple file and one go generate directive, e.g. in an application’s main.go

package main
…
//go:generate versioner ./VERSION ./version.go
…

a simple go generate will create the file version.go from the file VERSION:

package main

const (
	Major = 0
	Minor = 2
	Patch = 3
	Quality = `a`
)

and with this its trivial to let myfancyprogram show you its version like this

myfancyprogram v0.2.3-a
Usage: [flags] input output
…

There are also some flags to define a common prefix for the constants, to have automatically increasing build numbers and to generate a timestamp from time.Now(). Since version 0.4.0 versioner checks some convetions for semantic versioning by default:

  • Are major, minor and patch defined as valid version numbers

  • Do other values comply with SemVer character set, i.e. [0-9a-zA-Z-]

For backward compatibility this can be switched off.

Install

To get the library for writing your packing program:

go get -u git.fractalqb.de/fractalqb/pack

To get the versioner binary:

go install -u git.fractalqb.de/fractalqb/pack/versioner