Bug 252560

Summary: ports-mgmt/pkg chef regression: exit code is 1 instead of 70 for info when package does not exist
Product: Ports & Packages Reporter: Pavel Merdin <fbug>
Component: Individual Port(s)Assignee: freebsd-pkg (Nobody) <pkg>
Status: Closed Works As Intended    
Severity: Affects Only Me CC: fbug, jamie
Priority: --- Flags: bugzilla: maintainer-feedback? (pkg)
Version: Latest   
Hardware: Any   
OS: Any   

Description Pavel Merdin 2021-01-10 17:42:18 UTC
It looks like pkg started returning exit code 1 for 'info package' when the package does not exists. Previous versions used to return 70 in the same situation.
This seems to break chef automation as chef code expects either 0 or 70:

https://github.com/chef/chef/blob/master/lib/chef/provider/package/freebsd/pkgng.rb#L45

It looks like there is a bug #252125 which reports a similar issue with exit code, but in a different case.
I wonder if exit codes were somehow broken in the last release
Comment 1 Pavel Merdin 2021-01-10 17:53:52 UTC
a# pkg --version; pkg info pyjamas; echo $?
1.16.1
pkg: No package(s) matching pyjamas
1

b# pkg --version; pkg info pyjamas; echo $?
1.15.10
pkg: No package(s) matching pyjamas
70
Comment 2 Pavel Merdin 2021-01-10 18:26:07 UTC
  * freebsd_package[mc] action remove

    ================================================================================
    Error executing action `remove` on resource 'freebsd_package[mc]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    Expected process to exit with [0, 70], but received '1'
    ---- Begin output of ["pkg", "info", "mc"] ----
    STDOUT:
    STDERR: pkg: No package(s) matching mc
    ---- End output of ["pkg", "info", "mc"] ----
    Ran ["pkg", "info", "mc"] returned 1
Comment 3 Baptiste Daroussin freebsd_committer freebsd_triage 2021-08-17 15:18:36 UTC
I missed that ticket, exit code have been changed, to saner model on purpose. It was part of the release note.