[pacman-dev] [PATCH] Return 17 if a package/group has been built.
A specific exit code to distinguish failed builds and refusal to build because the package/group has already been built. Useful in autobuild scripts. Signed-off-by: Jack L. Frost <fbt@fleshless.org> --- scripts/makepkg.sh.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c74e84a..72cf714 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1613,7 +1613,7 @@ check_build_status() { exit 0 else error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 17 fi fi else @@ -1636,12 +1636,12 @@ check_build_status() { exit 0 else error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 17 fi fi if (( somepkgbuilt && ! PKGVERFUNC )); then error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 17 fi fi unset allpkgbuilt somepkgbuilt -- 2.4.1
On May 22, 2015 8:07 AM, "fbt" <fbt@fleshless.org> wrote:
A specific exit code to distinguish failed builds and refusal to build because the package/group has already been built. Useful in autobuild scripts.
Why 17? Where's the documentation? What about other error-exit conditions?
Signed-off-by: Jack L. Frost <fbt@fleshless.org> --- scripts/makepkg.sh.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c74e84a..72cf714 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1613,7 +1613,7 @@ check_build_status() { exit 0 else error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 17 fi fi else @@ -1636,12 +1636,12 @@ check_build_status() { exit 0 else error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 17 fi fi if (( somepkgbuilt && ! PKGVERFUNC )); then error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 17 fi fi unset allpkgbuilt somepkgbuilt -- 2.4.1
Why 17? An arbitrary choice
Where's the documentation? What about other error-exit conditions? Will adding an Exit Codes sectipn with 0, 1 and 17 be enough or will you only accept a patch with a full fixup of makepkg's exit codes?
On 22/05/15 22:18, Jack L. Frost wrote:
Why 17? An arbitrary choice
Where's the documentation? What about other error-exit conditions? Will adding an Exit Codes sectipn with 0, 1 and 17 be enough or will you only accept a patch with a full fixup of makepkg's exit codes?
I'll accept just the documentation for 0, 1 and the addition. Is there exit code standards?
On Fri, May 22, 2015 at 10:23:10PM +1000, Allan McRae wrote:
I'll accept just the documentation for 0, 1 and the addition. Should I resubmit the patch or answer into this thread?
Is there exit code standards? There's sysexits.h that could probably be consulted with in this matter. But nothing even close to the purpose of indicating something this specific. AFAIK exit codes are usually arbitrarily chosen except for maybe 1, which is usually just “generic error dunno lol”.
On 22/05, Jack L. Frost wrote:
Why 17? An arbitrary choice
If it's an arbitrary choice, why not 2 to follow 1? -- Sincerely, Johannes Löthberg PGP Key ID: 0x50FB9B273A9D0BB5 https://theos.kyriasis.com/~kyrias/
On 05/22/15 at 03:07pm, fbt wrote:
A specific exit code to distinguish failed builds and refusal to build because the package/group has already been built. Useful in autobuild scripts.
Signed-off-by: Jack L. Frost <fbt@fleshless.org>
Would it not make more sense to just return 0 for this? Presumably if a user or script is running makepkg without --force they don't care whether the package is newly built or already existed. Is there actually a use case where a user would care if the package had already been built but would not run with --force to begin with? apg
On Fri, May 22, 2015 at 08:38:22AM -0400, Andrew Gregory wrote:
Would it not make more sense to just return 0 for this? Presumably if a user or script is running makepkg without --force they don't care whether the package is newly built or already existed. Is there actually a use case where a user would care if the package had already been built but would not run with --force to begin with?
apg
The reason I use it in this way is for automated build scripts to be able to rely on makepkg to figure out if a package of this specific version has already been built or not and give me the appropriate message in the log. Otherwise I would have to parse makepkg's output to know that the package didn't fail te build, it refused to. And checking outside of makepkg would require duplicating some code.
A specific exit code to distinguish failed builds and refusal to build because the package/group has already been built. Useful in autobuild scripts. Signed-off-by: Jack L. Frost <fbt@fleshless.org> --- doc/makepkg.8.txt | 11 +++++++++++ scripts/makepkg.sh.in | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt index 41df30e..2f9415c 100644 --- a/doc/makepkg.8.txt +++ b/doc/makepkg.8.txt @@ -267,6 +267,17 @@ Environment Variables in linkman:makepkg.conf[5] +Exit codes +---------- +**0** + Success. + +**1** + Some error has occured. + +**2** + A package or (part of) group has already been built. + Configuration ------------- See linkman:makepkg.conf[5] for more details on configuring makepkg using the diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c74e84a..7025161 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1613,7 +1613,7 @@ check_build_status() { exit 0 else error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 2 fi fi else @@ -1636,12 +1636,12 @@ check_build_status() { exit 0 else error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 2 fi fi if (( somepkgbuilt && ! PKGVERFUNC )); then error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 2 fi fi unset allpkgbuilt somepkgbuilt -- 2.4.1
On Fri, May 22, 2015 at 04:48:12PM +0300, fbt wrote:
A specific exit code to distinguish failed builds and refusal to build because the package/group has already been built. Useful in autobuild scripts.
Now with a mention in the man and a different exit code.
Actually, exit 2 is currently used by makepkg to indicate that a build failed. I've not noticed when that happened, it didn't do that when I originally started patching my local copy of makepkg. So it should be 3 then: Signed-off-by: Jack L. Frost <fbt@fleshless.org> --- doc/makepkg.8.txt | 11 +++++++++++ scripts/makepkg.sh.in | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/doc/makepkg.8.txt b/doc/makepkg.8.txt index 41df30e..2f9415c 100644 --- a/doc/makepkg.8.txt +++ b/doc/makepkg.8.txt @@ -267,6 +267,17 @@ Environment Variables in linkman:makepkg.conf[5] +Exit codes +---------- +**0** + Success. + +**1** + Some error has occured. + +**2** + A failure occured while building the package. + +**3** + A package or (part of) group has already been built. + Configuration ------------- See linkman:makepkg.conf[5] for more details on configuring makepkg using the diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c74e84a..7025161 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1613,7 +1613,7 @@ check_build_status() { exit 0 else error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 3 fi fi else @@ -1636,12 +1636,12 @@ check_build_status() { exit 0 else error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 3 fi fi if (( somepkgbuilt && ! PKGVERFUNC )); then error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f" - exit 1 + exit 3 fi fi unset allpkgbuilt somepkgbuilt -- 2.4.1
On 24/06/15 00:07, fbt wrote:
Actually, exit 2 is currently used by makepkg to indicate that a build failed. I've not noticed when that happened, it didn't do that when I originally started patching my local copy of makepkg.
You have been working on this since 2009! :P I have put off this patch until I have time to catalogue all the return states and deal with this globally. I thnk this is needed to ensure some sensible order to the error codes. The patch is in our patchwork tracker so it will not be lost! Allan
You have been working on this since 2009! :P
Well yeah, the original patch has appeared in 2008 :D
The patch is in our patchwork tracker so it will not be lost!
Oh, I'm not rushing you, just noticed that I've made a mistake and amended it.
participants (6)
-
Allan McRae
-
Andrew Gregory
-
Dave Reisner
-
fbt
-
Jack L. Frost
-
Johannes Löthberg