Subject: [alpine-devel] [PATCH] testing/mksh: new aport

From: Stuart Cardall <[email-masked]>
Date: Wed, 20 Aug 2014 04:58:10 +0000

MirBSD™ Korn Shell - https://www.mirbsd.org/mksh.htm

A replacement for BASH which runs around 65% lighter (on Debian it
can be used as a replacement for /bin/sh).
---
 testing/mksh/APKBUILD            | 53 ++++++++++++++++++++++++++++++++++++++++
 testing/mksh/examples.patch      | 31 +++++++++++++++++++++++
 testing/mksh/mksh.post-deinstall |  2 ++
 testing/mksh/mksh.post-install   | 14 +++++++++++
 4 files changed, 100 insertions(+)
 create mode 100644 testing/mksh/APKBUILD
 create mode 100644 testing/mksh/examples.patch
 create mode 100644 testing/mksh/mksh.post-deinstall
 create mode 100644 testing/mksh/mksh.post-install

diff --git a/testing/mksh/APKBUILD b/testing/mksh/APKBUILD
new file mode 100644
index 0000000..b939180
--- /dev/null
+++ b/testing/mksh/APKBUILD
@@ -0,0 +1,53 @@
+# Contributor: Stuart Cardall <[email-masked]>
+# Maintainer: Stuart Cardall <[email-masked]>
+pkgname=mksh
+pkgver=50
+pkgrel=0
+pkgdesc="MirBSD™ Korn Shell, free implementation of the Korn Shell"
+url="https://www.mirbsd.org/mksh.htm"
+arch="all"
+license="MirOS Licence"
+depends=""
+depends_dev="perl"
+makedepends="$depends_dev"
+install="$pkgname.post-install $pkgname.post-deinstall"
+subpackages="$pkgname-doc"
+source="https://www.mirbsd.org/MirOS/dist/mir/mksh/mksh-R$pkgver.tgz
+	examples.patch
+	"
+
+_builddir="$srcdir"/mksh
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+	chmod +x ./Build.sh
+	./Build.sh -r -c lto && ./test.sh -f 2>&1 | tee build.log || return 1
+	pkgver=R$pkgver
+}
+
+package() {
+	cd "$_builddir"
+        install -m555 -D mksh \
+                "$pkgdir"/bin/mksh || return 1
+	install -m444 -D dot.mkshrc \
+                "$pkgdir"/etc/mkshrc || return 1
+	install -m444 -D dot.examples \
+                "$pkgdir"/usr/share/doc/mksh/examples || return 1
+	install -m444 -D mksh.1 \
+                "$pkgdir"/usr/share/man/man1/mksh.1 || return 1
+}
+
+md5sums="436a448f4124d3743adb9e4a1562b77e  mksh-R50.tgz
+19383dd8fd0243085b1dbc5c069db7f4  examples.patch"
+sha256sums="3538cef97df5ba964091f68119fd90822a9589b701a832ecd471c234b6179b56  mksh-R50.tgz
+9e44d78d6223e3fa124ab471d292cd0ca13334c7a68a7d8878008001aa19c0b0  examples.patch"
+sha512sums="a1287278a15bf188c0df00fa55d3439996890d1fa4331f4c41b7995525b85f3e7bfdc75e51d06d3898d12b607eb618105199946633db58da2ecd62e7bf7b1fd9  mksh-R50.tgz
+9b3d5ca902ecad0a422b8a76ad48c42f0911ebc34d0adceee5fc032bb2de284a80e27f43c2a693741fcf9d759f6c5f0ad6c1e08347020048b1318066d8f60ba6  examples.patch"
diff --git a/testing/mksh/examples.patch b/testing/mksh/examples.patch
new file mode 100644
index 0000000..c52a915
--- /dev/null
+++ b/testing/mksh/examples.patch
@@ -0,0 +1,31 @@
+--- mksh/dot.examples
++++ mksh/dot.examples.new
+@@ -0,0 +1,28 @@
++## Alpine Linux mksh examples ##
++
++# Enable command history - (set in /etc/profile ~/.profile ~/.mkshrc) #
++export HISTFILE=$HOME/.bash_history
++export HISTSIZE=2000
++typeset -r HISTFILE
++typeset -r HISTSIZE
++
++# mksh coloured prompt - *not* ash / bash compatible (set in ~/.mkshrc) #
++# ┌─┤ root@host ├──┤ /current/dir │
++# └─┤ 09:19 ├─»
++
++if [ "$USER" = root ]; then
++        PS1=$'\a\r\a\e[1;34m\a┌─┤ \a\e[31m\a${USER:=$(ulimit -c 0; \
++        id -un 2>/dev/null || echo \?)}@$(hostname)\a\e[34m\a ├──┤ \a\e[0;33m\a$(
++        local d=${PWD:-?} p=~
++        [[ $p = ?(*/) ]] || d=${d/$p/~}
++        print -nr -- "$d"
++        )\a\e[1;34m\a │\n└─┤ \a\e[0;33m\a$(date +%H:%M)\a\e[34m\a ├─»\a\e[0m\a '
++else
++        PS1=$'\a\r\a\e[1;34m\a┌─┤ \a\e[32m\a${USER:=$(ulimit -c 0; \
++        id -un 2>/dev/null || echo \?)}@$(hostname)\a\e[34m\a ├──┤ \a\e[0;33m\a$(
++        local d=${PWD:-?} p=~
++        [[ $p = ?(*/) ]] || d=${d/$p/~}
++        print -nr -- "$d"
++        )\a\e[1;34m\a │\n└─┤ \a\e[0;33m\a$(date +%H:%M)\a\e[34m\a ├─»\a\e[0m\a '
++fi
++
diff --git a/testing/mksh/mksh.post-deinstall b/testing/mksh/mksh.post-deinstall
new file mode 100644
index 0000000..29d4f8f
--- /dev/null
+++ b/testing/mksh/mksh.post-deinstall
@@ -0,0 +1,2 @@
+#!/bin/sh
+sed -i -e '/\/bin\/mksh/d' /etc/shells
diff --git a/testing/mksh/mksh.post-install b/testing/mksh/mksh.post-install
new file mode 100644
index 0000000..40baae4
--- /dev/null
+++ b/testing/mksh/mksh.post-install
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+NORMAL="\033[1;0m"
+STRONG="\033[1;1m"
+GREEN="\033[1;32m"
+
+print_strong() {
+        local prompt="${STRONG}$1 ${GREEN}$2${NORMAL}"
+        printf "${prompt} %s\n"
+}
+
+grep -x /bin/mksh /etc/shells >/dev/null || echo /bin/mksh >>/etc/shells
+print_strong "/etc/shells updated:" "see /usr/share/doc/mksh/examples"
+exit 0
-- 
1.9.2

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---