Skip to content

Commit 13c79b1

Browse files
piterpunkrworkman
piterpunk
authored andcommitted
New exit status for different situations
To make easier to do an unattended slackpkg update/upgrade process, this commit provides different exit codes to many situations: 0 Successful slackpkg execution. 1 Something wrong happened. 20 No package found to be downloaded, installed, reinstalled, upgraded, or removed. 50 Slackpkg itself was upgraded and you need to re-run it. 100 There are pending updates. Code and the main manpage are updated accordingly. In addition, this commit also: - removes the ChangeLog.txt in doinst.sh, so the needed 'slackpkg update' after Slackpkg upgrade won't says it's all OK and don't need to redo the package lists - removes AUTHORS from manpage. Nowadays there are code from many people in Slackpkg and shows a bit unfair to have only my and Evaldo's name listed there. Signed-off-by: Robby Workman <[email protected]>
1 parent 9862db7 commit 13c79b1

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

doinst.sh

+1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ copy_mirror_file
3939
config etc/slackpkg/mirrors.new
4040
config etc/slackpkg/slackpkg.conf.new
4141
config etc/slackpkg/blacklist.new
42+
rm -f var/lib/slackpkg/ChangeLog.txt
4243
rm -f var/lib/slackpkg/pkglist
4344
rm -f var/lib/slackpkg/CHECKSUMS.md5*

files/core-functions.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# Clean-up tmp and lock files
88
#
99
function cleanup() {
10-
local retval=${PENDING_UPDATES:-0}
10+
local retval=${EXIT_CODE:-0}
1111
[ "$SPINNING" = "off" ] || tput cnorm
1212
if [ -e $TMPDIR/error.log ]; then
1313
retval=1

files/slackpkg

+11-2
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ case "$CMD" in
332332
echo "Slackpkg: No updated packages since last check."
333333
else
334334
echo "Slackpkg: Updated packages are available since last check." >&2
335-
PENDING_UPDATES=1
335+
EXIT_CODE=100
336336
fi
337337
;;
338338
show-changelog)
@@ -368,6 +368,7 @@ case "$CMD" in
368368
echo -e "No packages match the pattern for install. Try:"
369369
echo -e "\n\t$0 reinstall|upgrade $2\n"
370370
POSTINST=off
371+
EXIT_CODE=20
371372
fi
372373
;;
373374
reinstall)
@@ -379,6 +380,7 @@ case "$CMD" in
379380
echo -e "No packages match the pattern for reinstall. Try:"
380381
echo -e "\n\t$0 install|upgrade $2\n"
381382
POSTINST=off
383+
EXIT_CODE=20
382384
fi
383385
;;
384386
upgrade)
@@ -391,6 +393,7 @@ case "$CMD" in
391393
echo -e "No packages match the pattern for upgrade. Try:"
392394
echo -e "\n\t$0 install|reinstall $2\n"
393395
POSTINST=off
396+
EXIT_CODE=20
394397
fi
395398
;;
396399
download)
@@ -404,12 +407,14 @@ case "$CMD" in
404407
else
405408
echo -e "No packages match the pattern for download."
406409
POSTINST=off
410+
EXIT_CODE=20
407411
fi
408412
;;
409413
remove)
410414
makelist $INPUTLIST
411415
if [ "$LIST" = "" ]; then
412416
echo -e "The file(s) $INPUTLIST can't be removed - package not installed.\n"
417+
EXIT_CODE=20
413418
cleanup
414419
fi
415420
showlist "$LIST" $CMD
@@ -423,6 +428,7 @@ case "$CMD" in
423428
else
424429
echo -e "No packages match the pattern for clean-system\n"
425430
POSTINST=off
431+
EXIT_CODE=20
426432
fi
427433
;;
428434
upgrade-all)
@@ -432,6 +438,7 @@ case "$CMD" in
432438
echo -e "No packages match the pattern for upgrade. Try:"
433439
echo -e "\n\t$0 install|reinstall $2\n"
434440
POSTINST=off
441+
EXIT_CODE=20
435442
else
436443
showlist "$LIST" upgrade
437444
if [ "$DOWNLOAD_ALL" = "on" ]; then
@@ -447,8 +454,9 @@ case "$CMD" in
447454
if [ "$FOUND" != "" ]; then
448455
getpkg $FOUND upgradepkg Upgrading
449456
echo -e "slackpkg was upgraded - you will need start the upgrade process again...\n"
457+
EXIT_CODE=50
450458
cleanup
451-
exit 0
459+
exit ${EXIT_CODE}
452460
fi
453461
for i in pkgtools aaa_glibc-solibs glibc-solibs aaa_libraries aaa_elflibs readline sed; do
454462
FOUND=""
@@ -466,6 +474,7 @@ case "$CMD" in
466474
echo -e "No packages match the pattern for install. Try:"
467475
echo -e "\n\t$0 upgrade|reinstall $2\n"
468476
POSTINST=off
477+
EXIT_CODE=20
469478
else
470479
showlist "$LIST" install
471480
install_pkg

files/slackpkg.8

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.TH SLACKPKG 8 "March 12, 2021" slackpkg-15.0.1 ""
1+
.TH SLACKPKG 8 "Oct 8, 2021" slackpkg-15.0.8 ""
22
.SH NAME
33
.B slackpkg
44
\- Automated tool for managing Slackware Linux packages
@@ -305,6 +305,20 @@ If you happen to be looking for a filename-with-space, you are safe to use the
305305
left-most part up to the space (in that the right-most part after the space
306306
will be ignored anyway (at best) or yield noise (at worst)).
307307

308+
.SH EXIT STATUS
309+
.P
310+
.IP "\fB0\fP" 5
311+
Successful slackpkg execution.
312+
.IP "\fB1\fP" 5
313+
Something wrong happened.
314+
.IP "\fB20\fP" 5
315+
No package found to be downloaded, installed, reinstalled, upgraded, or
316+
removed.
317+
.IP "\fB50\fP" 5
318+
Slackpkg itself was upgraded and you need to re-run it.
319+
.IP "\fB100\fP" 5
320+
There are pending updates.
321+
308322
.SH FILES
309323
.TP 5
310324
.B /etc/slackpkg/mirrors
@@ -333,11 +347,3 @@ ChangeLog.txt, list of files, etcetera...
333347
.BR explodepkg (8),
334348
.BR makepkg (8),
335349
.BR pkgtool (8).
336-
337-
.SH AUTHORS
338-
.TP 5
339-
Piter PUNK aka Roberto F Batista
340-
<piterpk AT terra DOT com DOT br>
341-
.TP 5
342-
Evaldo Gardenali aka UdontKnow
343-
<evaldo AT fasternet DOT com DOT br>

0 commit comments

Comments
 (0)