summaryrefslogtreecommitdiffstats
path: root/source/ap/slackpkg/files/dialog-functions.sh
diff options
context:
space:
mode:
author Patrick J Volkerding <volkerdi@slackware.com>2016-06-30 20:26:57 +0000
committer Eric Hameleers <alien@slackware.com>2018-05-31 23:31:18 +0200
commitd31c50870d0bee042ce660e445c9294a59a3a65b (patch)
tree6bfc0de3c95267b401b620c2c67859557dc60f97 /source/ap/slackpkg/files/dialog-functions.sh
parent76fc4757ac91ac7947a01fb7b53dddf9a78a01d1 (diff)
downloadcurrent-d31c50870d0bee042ce660e445c9294a59a3a65b.tar.gz
current-d31c50870d0bee042ce660e445c9294a59a3a65b.tar.xz
Slackware 14.2slackware-14.2
Thu Jun 30 20:26:57 UTC 2016 Slackware 14.2 x86_64 stable is released! The long development cycle (the Linux community has lately been living in "interesting times", as they say) is finally behind us, and we're proud to announce the release of Slackware 14.2. The new release brings many updates and modern tools, has switched from udev to eudev (no systemd), and adds well over a hundred new packages to the system. Thanks to the team, the upstream developers, the dedicated Slackware community, and everyone else who pitched in to help make this release a reality. The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. Please consider supporting the Slackware project by picking up a copy from store.slackware.com. We're taking pre-orders now, and offer a discount if you sign up for a subscription. Have fun! :-)
Diffstat (limited to 'source/ap/slackpkg/files/dialog-functions.sh')
-rw-r--r--source/ap/slackpkg/files/dialog-functions.sh75
1 files changed, 75 insertions, 0 deletions
diff --git a/source/ap/slackpkg/files/dialog-functions.sh b/source/ap/slackpkg/files/dialog-functions.sh
new file mode 100644
index 000000000..042906c36
--- /dev/null
+++ b/source/ap/slackpkg/files/dialog-functions.sh
@@ -0,0 +1,75 @@
+# Dialog functions
+# Original functions from slackpkg modified by Marek Wodzinski (majek@mamy.to)
+#
+export DIALOG_CANCEL="1"
+export DIALOG_ERROR="126"
+export DIALOG_ESC="1"
+export DIALOG_EXTRA="3"
+export DIALOG_HELP="2"
+export DIALOG_ITEM_HELP="2"
+export DIALOG_OK="0"
+
+# Show the lists and asks if the user want to proceed with that action
+# Return accepted list in $SHOWLIST
+#
+if [ "$DIALOG" = "on" ] || [ "$DIALOG" = "ON" ]; then
+ function showlist() {
+ if [ "$ONOFF" != "off" ]; then
+ ONOFF=on
+ fi
+ rm -f $TMPDIR/dialog.tmp
+
+ if [ "$2" = "upgrade" ]; then
+ ls -1 $ROOT/var/log/packages > $TMPDIR/tmplist
+ for i in $1; do
+ BASENAME=$(cutpkg $i)
+ PKGFOUND=$(grep -m1 -e "^${BASENAME}-[^-]\+-\(noarch\|fw\|${ARCH}\)" $TMPDIR/tmplist)
+ echo "$i \"\" $ONOFF \"currently installed: $PKGFOUND\"" >>$TMPDIR/dialog.tmp
+ done
+ HINT="--item-help"
+ else
+ for i in $1; do
+ echo "$i \"\" $ONOFF" >>$TMPDIR/dialog.tmp
+ done
+ HINT=""
+ fi
+
+ # This is needed because dialog have a limit of arguments.
+ # This limit is around 20k characters in slackware 10.x
+ # Empiric tests on slackware 13.0 got a limit around 139k.
+ # If we exceed this limit, dialog got a terrible error, to
+ # avoid that, if the number of arguments is bigger than
+ # DIALOG_MAXARGS we remove the hints. If even without hints
+ # we can't got less characters than DIALOG_MAXARGS we give an
+ # error message to the user ask him to not use dialog
+ if [ $(wc -c $TMPDIR/dialog.tmp | cut -f1 -d\ ) -ge $DIALOG_MAXARGS ]; then
+ mv $TMPDIR/dialog.tmp $TMPDIR/dialog2.tmp
+ awk '{ NF=3 ; print $0 }' $TMPDIR/dialog2.tmp > $TMPDIR/dialog.tmp
+ HINT=""
+ fi
+ cat $TMPDIR/dialog.tmp|xargs dialog --title $2 --backtitle "slackpkg $VERSION" $HINT --checklist "Choose packages to $2:" 19 70 13 2>$TMPDIR/dialog.out
+ case "$?" in
+ 0|123)
+ dialog --clear
+ ;;
+ 1|124|125|126|127)
+ dialog --clear
+ echo -e "DIALOG ERROR:\n-------------" >> $TMPDIR/error.log
+ cat $TMPDIR/dialog.out >> $TMPDIR/error.log
+ echo -e "-------------
+If you want to continue using slackpkg, disable the DIALOG option in
+/etc/slackpkg/slackpkg.conf and try again.
+
+Help us to make slackpkg a better tool - report bugs to the slackpkg
+developers" >> $TMPDIR/error.log
+ cleanup
+ ;;
+ esac
+ SHOWLIST=$(cat $TMPDIR/dialog.out | tr -d \")
+ rm -f $TMPDIR/dialog.*
+ if [ -z "$SHOWLIST" ]; then
+ echo "No packages selected for $2, exiting."
+ cleanup
+ fi
+ }
+fi