Browse Source

Merge pull request #411 from mirabilos/mksh

move mksh to github; update it
sbyx 10 years ago
parent
commit
c998eb05ad
2 changed files with 139 additions and 0 deletions
  1. 89
    0
      utils/mksh/Makefile
  2. 50
    0
      utils/mksh/patches/100-dot_mkshrc

+ 89
- 0
utils/mksh/Makefile View File

@@ -0,0 +1,89 @@
1
+#
2
+# Copyright (C) 2007-2011 OpenWrt.org
3
+# Copyright (c) 2009-2014 Thorsten Glaser <tg@mirbsd.org>
4
+#
5
+# This is free software, licensed under the GNU General Public License v2.
6
+# See /LICENSE for more information.
7
+#
8
+
9
+include $(TOPDIR)/rules.mk
10
+
11
+PKG_NAME:=mksh
12
+PKG_VERSION:=50d
13
+PKG_RELEASE:=1
14
+
15
+PKG_MAINTAINER:=Thorsten Glaser <tg@mirbsd.org>
16
+PKG_LICENSE:=MirOS
17
+
18
+PKG_SOURCE:=$(PKG_NAME)-R$(PKG_VERSION).tgz
19
+PKG_SOURCE_URL:=http://www.mirbsd.org/MirOS/dist/mir/mksh
20
+PKG_MD5SUM:=1c3882c07a760b23df1ad94ad0b4ed2e
21
+
22
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
23
+
24
+include $(INCLUDE_DIR)/package.mk
25
+
26
+define Package/mksh
27
+  SECTION:=shells
28
+  CATEGORY:=Base system
29
+  TITLE:=MirBSD Korn Shell
30
+  DEPENDS:=$(DEP)
31
+  URL:=http://mirbsd.de/mksh
32
+endef
33
+
34
+define Package/mksh/description
35
+mksh is the MirBSD enhanced version of the Public Domain Korn
36
+shell (pdksh), a Bourne-compatible shell which is largely si-
37
+milar to the original AT&T Korn shell; mksh is the only pdksh
38
+derivate currently being actively developed.  It includes bug
39
+fixes and feature improvements, in order to produce a modern,
40
+robust shell good for interactive and especially script use.
41
+mksh has UTF-8 support (in substring operations and the Emacs
42
+editing mode) and - while R50 corresponds to OpenBSD 5.5-cur-
43
+rent ksh (without GNU bash-like PS1 and fancy character clas-
44
+ses) - adheres to SUSv4 and is much more robust. The code has
45
+been cleaned up and simplified, bugs fixed, standards compli-
46
+ance added, and several enhancements (for extended compatibi-
47
+lity to other modern shells - as well as a couple of its own)
48
+are available. It has sensible defaults as usual with BSD.
49
+endef
50
+
51
+define Build/Compile
52
+	# -DMKSH_SMALL=1 ⇒ reduce functionality quite a lot
53
+	# -DMKSH_ASSUME_UTF8=0 ⇒ never automatically enable
54
+	#	UTF-8 mode, neither use setlocale/nl_langinfo
55
+	#	nor look at $LC_* and $LANG (not recommended)
56
+	# -DMKSH_BINSHPOSIX ⇒ enable POSIX mode if called as sh
57
+	#XXX maybe change to -DMKSH_ASSUME_UTF8=1 now (which
58
+	#XXX is always assume UTF-8 mode)
59
+	# HAVE_CAN_FSTACKPROTECTORALL=0 ⇒ nuke libssp dependency
60
+	# HAVE_CAN_FSTACKPROTECTORSTRONG=0 ⇒ same, for gcc 4.9+
61
+	cd $(PKG_BUILD_DIR); \
62
+		CC="$(TARGET_CC)" \
63
+		TARGET_OS="$(shell uname -s)" \
64
+		CFLAGS="$(TARGET_CFLAGS)" \
65
+		CPPFLAGS="-DMKSH_SMALL=1 -DMKSH_ASSUME_UTF8=0 -DMKSH_BINSHPOSIX" \
66
+		HAVE_CAN_FSTACKPROTECTORALL=0 \
67
+		HAVE_CAN_FSTACKPROTECTORSTRONG=0 \
68
+		LDFLAGS="$(TARGET_LDFLAGS)" \
69
+			$(BASH) Build.sh -Q -r -c lto
70
+endef
71
+
72
+define Package/mksh/postinst
73
+#!/bin/sh
74
+grep mksh $${IPKG_INSTROOT}/etc/shells || \
75
+	echo "/bin/mksh" >> $${IPKG_INSTROOT}/etc/shells
76
+endef
77
+
78
+define Package/mksh/install
79
+	$(INSTALL_DIR) $(1)/etc
80
+	$(INSTALL_DATA) $(PKG_BUILD_DIR)/dot.mkshrc $(1)/etc/mkshrc
81
+	$(INSTALL_DIR) $(1)/bin
82
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/mksh $(1)/bin/
83
+endef
84
+
85
+define Package/mksh/conffiles
86
+/etc/mkshrc
87
+endef
88
+
89
+$(eval $(call BuildPackage,mksh))

+ 50
- 0
utils/mksh/patches/100-dot_mkshrc View File

@@ -0,0 +1,50 @@
1
+From 23712cea8e2a623fd952eb781df0011c501703d0 Mon Sep 17 00:00:00 2001
2
+From: Thorsten Glaser <tg@mirbsd.org>
3
+Date: Thu, 25 Jul 2013 22:07:33 +0200
4
+Subject: [PATCH] Make default mkshrc file suitable for OpenWrt environment:
5
+
6
+* Part of the FreeWRT patches:
7
+  - no hostname(1)
8
+  - ls(1) has no -o option
9
+* OpenWrt and FreeWRT-1.0 fix:
10
+  - since this is not ~/.mkshrc make sure subshells find it
11
+---
12
+ dot.mkshrc | 10 +++++++---
13
+ 1 file changed, 7 insertions(+), 3 deletions(-)
14
+
15
+diff --git a/dot.mkshrc b/dot.mkshrc
16
+index 233a10c..caf482c 100644
17
+--- a/dot.mkshrc
18
++++ b/dot.mkshrc
19
+@@ -28,8 +28,8 @@ case $KSH_VERSION in
20
+ *) return 0 ;;
21
+ esac
22
+ 
23
+-PS1='#'; (( USER_ID )) && PS1='$'; [[ ${HOSTNAME:=$(ulimit -c 0; hostname -s \
24
+-    2>/dev/null)} = *([	 ]|localhost) ]] && HOSTNAME=$(ulimit -c 0; hostname \
25
++PS1='#'; (( USER_ID )) && PS1='$'; [[ ${HOSTNAME:=$(</proc/sys/kernel/hostname
26
++    )} = *([	 ]|localhost) ]] && HOSTNAME=$(ulimit -c 0; hostname \
27
+     2>/dev/null); : ${EDITOR:=/bin/ed} ${HOSTNAME:=nil} ${TERM:=vt100}
28
+ : ${MKSH:=$(whence -p mksh)}; PS4='[$EPOCHREALTIME] '; PS1=$'\001\r''${|
29
+ 	local e=$?
30
+@@ -50,7 +50,7 @@ unalias ls
31
+ alias l='ls -F'
32
+ alias la='l -a'
33
+ alias ll='l -l'
34
+-alias lo='l -alo'
35
++alias lo='l -al'
36
+ alias doch='sudo mksh -c "$(fc -ln -1)"'
37
+ whence -p rot13 >/dev/null || alias rot13='tr \
38
+     abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \
39
+@@ -402,4 +402,8 @@ alias cls='print -n \\033c'
40
+ 
41
+ unset p
42
+ 
43
++# we need this in OpenWrt for subshells that are not login shells
44
++: ${ENV=/etc/mkshrc}
45
++[[ -z $ENV ]] || export ENV
46
++
47
+ : place customisations above this line
48
+-- 
49
+2.1.1
50
+