mkdeb
mkdeb copied to clipboard
Use subcommands library + support for flags via env
This also fixes a number small bugs in the earlier main.go
The subcommands package adds some verbosity to the code but it also adds structure to the command/flag stuff.
By also adding the flagenv package this is now also a valid invocation of the build command:
DEB_CONFIG=boo.json DEB_VERSION=1.1.1.1 go run main.go build
I made a small change in behavior where the positional argument for the config file also can be specified using a -config argument.
examples
$ go run main.go
Usage: main <flags> <subcommand> <subcommand args>
Subcommands:
archs list supported CPU architectures
build build a package based on the specified config file
commands list all command names
help describe subcommands and their syntax
init create a new mkdeb config file
licence show licence information
packaging show help for packaging
validate validate config file
Use "main flags" for a list of top-level flags
exit status 2
$ go run main.go packaging
PACKAGING CONFIGURATION
Required Fields
- package: The name of your package
- version: Must adhere to debian version syntax.
- architecture: CPU arch for your binaries, or "all"
- maintainer: Your Name <[email protected]>
- description: Brief explanation of your package
Optional Fields
- depends: Other packages you depend on. E.g: "python" or "curl (>= 7.0.0)"
- preDepends: Other packages you depend on which is required to be available
to configure your package.
- conflicts: Packages your package are not compatible with
- breaks: Packages your package breaks
- replaces: Packages your package replaces
- homepage: URL to your project homepage or source repository, if you have one
For more details on how to specify various config options, refer to the
debian package specification:
- https://www.debian.org/doc/debian-policy/ch-controlfields.html
- https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html
PACKAGING LAYOUT
autoPath
mkdeb will automatically include any files deb-pkg, the default autoPath
directory. For example, the following files will be automatically included and
installed to their corresponding paths:
deb-pkg/etc/mysqld/my.conf -> /etc/mysqld/my.conf
deb-pkg/usr/bin/mysqld -> /usr/bin/mysqld
You can override this behavior by setting autoPath to - (dash character) and /
or by using the Files map to create a custom source -> dest mapping.
Control Scripts
Control scripts allow you to take action at various stages of your package's
lifecycle. These are commonly used to create users, start or stop services, or
perform cleanup.
By default mkdeb will use any of these files if they are present in deb-pkg:
- preinst
- postinst
- prerm
- postrm
You can override this behavior by setting the relevant fields in your config.
BUILD OPTIONS
The following options change how mkdeb runs when building packages.
- tempPath: Controls where intermediate files are written during the build.
This defaults to the system temp directory.
- upgradeConfigs: Indicates whether apt should replace files under /etc when
installing a new package version. By default these files are not upgraded.
- preserveSymlinks: By default contents of symlink targets are copied. This
option writes symlinks to the archive instead.
$ go run main.go archs
mkdeb supported architectures: all, amd64, arm64, armel, armhf, i386, mips, mipsel, powerpc, ppc64el, s390x
$ go run main.go build -h
build -version=1.2.0 [-config] config.json
By default the build artifact
The build command will change to the directory where the config file is
located, so paths should always be specified relative to the config file.
-config string
Config file (alternative to positional argument)
-target string
Target folder with generated filename
-version string
Package version (default "1.0")
exit status 2
$ go run main.go build mkdeb.json
Built package /home/thomasf/src/github.com/cbednarski/mkdeb/mkdeb-1.0-amd64.deb
$ go run main.go build -config mkdeb.json
Built package /home/thomasf/src/github.com/cbednarski/mkdeb/mkdeb-1.0-a.md64.deb
$ go run main.go build -config mkdeb.json -version 123123
Built package /home/thomasf/src/github.com/cbednarski/mkdeb/mkdeb-123123-amd64.deb
$ go run main.go build -config mkdeb.json mkdeb.json
error: only use one of positional or -config argument for config file
exit status 1
If you don't want these packages exposed as importable packages I can move them to a internal/ package.
I added preDepends to the mkdeb packaging help command now since that pull request was merged.
Thanks for merging the other pull requests btw.. Now I can continue to look at other issues without conflicting my own pull requests..
I have a review pending but I have not gone through all of it yet.
Could you maybe take a look at this soon?