From 20594d61833e71d4ddbc3b449e05c504f8ad07de Mon Sep 17 00:00:00 2001 From: Ivan Vandot Date: Wed, 18 Nov 2020 13:55:14 +0100 Subject: [PATCH] add debconf-templates cookbook (#1907) * add debconf-templates cookbook * chore: typo Co-authored-by: Carlos Alexandro Becker --- www/docs/cookbooks/debconf-templates.md | 56 +++++++++++++++++++++++++ www/docs/customization/nfpm.md | 3 +- www/mkdocs.yml | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 www/docs/cookbooks/debconf-templates.md diff --git a/www/docs/cookbooks/debconf-templates.md b/www/docs/cookbooks/debconf-templates.md new file mode 100644 index 00000000000..2a5142f04d6 --- /dev/null +++ b/www/docs/cookbooks/debconf-templates.md @@ -0,0 +1,56 @@ +# Use debconf and templates + +Deb installation format has a support for user input during installation using [debconf](https://manpages.debian.org/testing/debconf-doc/debconf-devel.7.en.html). + +To enable it inside `goreleaser` you need: + +`templates` file, what to ask (all templates go into single file): + +```none +Template: foo/like_debian +Type: boolean +Description: Do you like Debian? + We'd like to know if you like the Debian GNU/Linux system. + +Template: foo/why_debian_is_great +Type: note +Description: Poor misguided one. Why are you installing this package? + Debian is great. As you continue using Debian, we hope you will + discover the error in your ways. +``` + +Maintainer script file that will trigger questions, usually its `postinst` because all package files are already installed: + +```sh +#!/bin/sh -e + +# Source debconf library. +. /usr/share/debconf/confmodule + +# Do you like debian? +db_input high foo/like_debian || true +db_go || true + +# Check their answer. +# with db_get you load value into $RET env variable. +db_get foo/like_debian +if [ "$RET" = "false" ]; then + # Poor misguided one... + db_input high foo/why_debian_is_great || true + db_go || true +fi +``` + +Include `templates` and `postinst` in `.goreleaser.yml`: + +```yaml + overrides: + deb: + scripts: + postinstall: ./deb/postinst + deb: + scripts: + templates: ./deb/templates +``` + +Useful tutorial: [Debconf Programmer's Tutorial](http://www.fifi.org/doc/debconf-doc/tutorial.html) diff --git a/www/docs/customization/nfpm.md b/www/docs/customization/nfpm.md index cf1083da377..adbc6841b07 100644 --- a/www/docs/customization/nfpm.md +++ b/www/docs/customization/nfpm.md @@ -207,8 +207,9 @@ nfpms: # Custom configuration applied only to the Deb packager. deb: - # Custom deb rules script. + # Custom deb special files. scripts: + # Deb rules script. rules: foo.sh # Deb templates file, when using debconf. templates: templates diff --git a/www/mkdocs.yml b/www/mkdocs.yml index 9c14d604fcc..7f4e844746d 100644 --- a/www/mkdocs.yml +++ b/www/mkdocs.yml @@ -89,6 +89,7 @@ nav: - cookbooks/release-a-library.md - cookbooks/publish-to-nexus.md - cookbooks/cgo-and-crosscompiling.md + - cookbooks/debconf-templates.md - tutorials.md - links.md