Config packaging with nfpm - #13
Merged
Merged
Conversation
This is the final configuration and scripts from this blogpost: https://keith.gaughan.ie/creating-a-signed-rpm-with-nfpm-and-gnupg.html
Contributor
Reviewer's GuideAdds an nfpm-based RPM packaging workflow, including a packaging script and nfpm configuration for the socketmap-sql Python script, with GPG signing support and versioning derived from git metadata. Sequence diagram for nfpm-based RPM packaging workflowsequenceDiagram
actor Maintainer
participant package_sh
participant Git
participant nfpm
participant GPG
Maintainer->>package_sh: ./package.sh [-P]
alt passphrase_prompt_requested
package_sh->>package_sh: [NFPM_PASSPHRASE is empty]
package_sh->>Maintainer: read passphrase
Maintainer-->>package_sh: NFPM_PASSPHRASE
package_sh->>package_sh: export NFPM_PASSPHRASE
end
package_sh->>Git: git describe --tags --abbrev=0
Git-->>package_sh: VERSION
package_sh->>Git: git log -1 --pretty=%ct
Git-->>package_sh: SOURCE_DATE_EPOCH
package_sh->>package_sh: export VERSION, SOURCE_DATE_EPOCH
package_sh->>nfpm: nfpm package --packager rpm
nfpm->>nfpm: read nfpm.yaml
nfpm->>GPG: use signing.gpg to sign RPM
GPG-->>nfpm: signature
nfpm-->>Maintainer: signed RPM package
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- In
package.sh,read -pis a bashism andtest ... -a ...is non‑portable; consider using POSIX‑compliant constructs (e.g.printfbeforereadand[with&&in the conditional) to ensure the script works with/bin/shon more systems. - The
usagefunction currently always writes to stdout; for error cases (e.g. the*branch ingetopts), it would be clearer to direct the usage text to stderr instead of usingusage 2>&1.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `package.sh`, `read -p` is a bashism and `test ... -a ...` is non‑portable; consider using POSIX‑compliant constructs (e.g. `printf` before `read` and `[` with `&&` in the conditional) to ensure the script works with `/bin/sh` on more systems.
- The `usage` function currently always writes to stdout; for error cases (e.g. the `*` branch in `getopts`), it would be clearer to direct the usage text to stderr instead of using `usage 2>&1`.
## Individual Comments
### Comment 1
<location path="package.sh" line_range="35-37" />
<code_context>
+done
+
+if test "${prompt:-}" = "1" -a -z "${NFPM_PASSPHRASE:-}"; then
+ stty -echo
+ read -p "passphrase> " NFPM_PASSPHRASE
+ stty echo
+ echo
+ export NFPM_PASSPHRASE
</code_context>
<issue_to_address>
**issue (bug_risk):** Echo may remain disabled if the script is interrupted while prompting.
If the script is interrupted (e.g., Ctrl-C) between `stty -echo` and `stty echo`, the terminal can be left with echo disabled. Consider saving and restoring the original tty state with a trap, e.g.:
```sh
orig_stty=$(stty -g)
trap 'stty "$orig_stty"' INT TERM EXIT
stty -echo
read -p "passphrase> " NFPM_PASSPHRASE
stty "$orig_stty"
trap - INT TERM EXIT
```
This ensures the terminal is restored even on errors or interrupts.
</issue_to_address>
### Comment 2
<location path="nfpm.yaml" line_range="3" />
<code_context>
+name: socketmap-sql
+arch: all
+version: $VERSION
+depends:
+ - python3
</code_context>
<issue_to_address>
**issue (bug_risk):** Environment variable interpolation syntax may not match nfpm’s templating expectations.
Using `version: $VERSION` only works if nfpm is run through a shell that expands env vars first; nfpm itself usually expects Go-style templates (e.g. `{{ .Env.VERSION }}`). Please confirm nfpm’s config syntax and switch to the supported mechanism so the version is actually read from the environment rather than ending up as the literal `$VERSION`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
kgaughan
added a commit
to kgaughan/blog
that referenced
this pull request
Jun 25, 2026
kgaughan
added a commit
to kgaughan/blog
that referenced
this pull request
Jun 25, 2026
kgaughan
added a commit
to kgaughan/blog
that referenced
this pull request
Jun 25, 2026
kgaughan
added a commit
to kgaughan/blog
that referenced
this pull request
Jun 25, 2026
kgaughan
added a commit
to kgaughan/blog
that referenced
this pull request
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the final configuration and scripts from this blogpost:
https://keith.gaughan.ie/creating-a-signed-rpm-with-nfpm-and-gnupg.html
Summary by Sourcery
Add packaging configuration and script to build a signed RPM using nfpm.
Build: