pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


ksh93.cygport prototype
Posted by Anonymous on Mon 5th Feb 2024 14:32
raw | new post
modification of post by Anonymous (view diff)

  1. #
  2. # ksh93.cygport
  3. #
  4. # Copyright (C) 2024 Roland Mainz <roland.mainz@nrubsig.org>
  5. #
  6. # This file is free software; I give unlimited permission to copy and/or
  7. # distribute it, with or without modifications, as long as this notice is
  8. # preserved.
  9. #
  10.  
  11. NAME=astksh
  12. LICENSE="Eclipse Public License - v 2.0"
  13. HOMEPAGE="https://github.com/ksh93/ksh"
  14. VERSION=1.0.8
  15. RELEASE=0
  16.  
  17. PKG_NAMES="astksh astksh_devel"
  18.  
  19. astksh_SUMMARY="The AT&T Korn Shell"
  20. astksh_DESCRIPTION="Original version of the AT&T AST Korn Shell 93."
  21. astksh_CATEGORY="Base Shells"
  22. astksh_CONTENTS=" \
  23.         bin/ksh.exe \
  24.         bin/ksh93.exe \
  25.         bin/rksh.exe \
  26.         bin/rksh93.exe \
  27.         etc/ksh.kshrc \
  28.         usr/share/doc/astksh \
  29.         usr/share/man/man1 \
  30. "
  31.  
  32. astksh_devel_SUMMARY="Development files for AT&T ksh"
  33. astksh_devel_DESCRIPTION="This package contains development tools and scripts for AT&T ksh"
  34. astksh_devel_CATEGORY="Devel"
  35. astksh_devel_CONTENTS="usr/share/ksh \
  36.         bin/shcomp.exe \
  37. "
  38.  
  39. SRC_URI="https://github.com/ksh93/ksh/archive/refs/tags/v1.0.8.zip"
  40. SRC_DIR='./ksh-1.0.8/'
  41. PATCH_URI_BASE=""
  42.  
  43. BUILD_REQUIRES=" \
  44.    bash \
  45.    coreutils \
  46.    bison \
  47.    gcc-g++ \
  48.    libiconv-devel \
  49.    libintl-devel \
  50.    libncurses-devel \
  51.    make \
  52.    sed \
  53.    texinfo \
  54. "
  55.  
  56. CPPFLAGS=
  57. CYGCONF_ARGS=
  58. DIFF_EXCLUDES=
  59. DOCS=
  60.  
  61. function print_gnulinux_builtin_header
  62. {
  63. # Make sure to use \\ instead of \ for continuations
  64. cat <<ENDOFTEXT
  65.  
  66. #ifndef _GNULINUX_KSH_CMDLIST_H
  67. #define        _GNULINUX_KSH_CMDLIST_H
  68.  
  69. #ifdef __cplusplus
  70. extern "C" {
  71. #endif
  72.  
  73. /*
  74.  * List builtins for Linux.
  75.  * The list here is partially autogenerated and partially hand-picked
  76.  * based on compatibility with the native GNU coreutils versions of
  77.  * these tools
  78.  */
  79.  
  80. /* GNU coreutils compatible commands.
  81.  * Be careful, some are in /bin while others are in /usr/bin
  82.  */
  83. #define ASTCMDLIST(f) \
  84.         { "/usr/ast/bin/"       #f,     NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
  85. #define BINCMDLIST(f)   \
  86.         { "/bin/"               #f,     NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) }, \
  87.         { "/usr/bin/"           #f,     NV_BLTIN|NV_BLTINOPT|NV_NOFREE, bltin(f) },
  88. /* undo ast_map.h #defines to avoid collision */
  89. #undef basename
  90. #undef chmod
  91. #undef chown
  92. #undef dirname
  93. #undef mkdir
  94. #undef mkfifo
  95. #undef mktemp
  96. #undef readlink
  97. #undef realpath
  98. #undef rmdir
  99.  
  100.  
  101. /* Generated data, do not edit. */
  102. BINCMDLIST(basename)
  103. BINCMDLIST(cksum)
  104. BINCMDLIST(comm)
  105. BINCMDLIST(cut)
  106. BINCMDLIST(dirname)
  107. BINCMDLIST(expr)
  108. BINCMDLIST(fold)
  109. BINCMDLIST(join)
  110. BINCMDLIST(logname)
  111. BINCMDLIST(mkdir)
  112. BINCMDLIST(mkfifo)
  113. BINCMDLIST(mktemp)
  114. BINCMDLIST(paste)
  115. BINCMDLIST(pathchk)
  116. BINCMDLIST(rev)
  117. BINCMDLIST(rmdir)
  118. BINCMDLIST(sleep)
  119. BINCMDLIST(sync)
  120. BINCMDLIST(tee)
  121. BINCMDLIST(tty)
  122. BINCMDLIST(uniq)
  123. BINCMDLIST(wc)
  124.  
  125. /* Mandatory for ksh93 test suite and AST scripts */
  126. BINCMDLIST(getconf)
  127.  
  128. ASTCMDLIST(basename)
  129. ASTCMDLIST(cat)
  130. ASTCMDLIST(chgrp)
  131. ASTCMDLIST(chmod)
  132. ASTCMDLIST(chown)
  133. ASTCMDLIST(cksum)
  134. ASTCMDLIST(cmp)
  135. ASTCMDLIST(comm)
  136. ASTCMDLIST(cp)
  137. ASTCMDLIST(cut)
  138. ASTCMDLIST(date)
  139. ASTCMDLIST(dirname)
  140. //BINCMDLIST(egrep)
  141. //ASTCMDLIST(egrep)
  142. ASTCMDLIST(expr)
  143. ASTCMDLIST(fds)
  144. //BINCMDLIST(fgrep)
  145. //ASTCMDLIST(fgrep)
  146. ASTCMDLIST(fmt)
  147. ASTCMDLIST(fold)
  148. //BINCMDLIST(grep)
  149. //ASTCMDLIST(grep)
  150. ASTCMDLIST(head)
  151. ASTCMDLIST(id)
  152. //BINCMDLIST(iconv)
  153. //ASTCMDLIST(iconv)
  154. ASTCMDLIST(join)
  155. ASTCMDLIST(ln)
  156. ASTCMDLIST(logname)
  157. //ASTCMDLIST(ls)
  158. ASTCMDLIST(md5sum)
  159. BINCMDLIST(md5sum)
  160. ASTCMDLIST(mkdir)
  161. ASTCMDLIST(mkfifo)
  162. ASTCMDLIST(mktemp)
  163. ASTCMDLIST(mv)
  164. ASTCMDLIST(paste)
  165. ASTCMDLIST(pathchk)
  166. ASTCMDLIST(pids)
  167. //BINCMDLIST(od)
  168. //ASTCMDLIST(od)
  169. //BINCMDLIST(readlink)
  170. //ASTCMDLIST(readlink)
  171. //BINCMDLIST(realpath)
  172. //ASTCMDLIST(realpath)
  173. ASTCMDLIST(rev)
  174. ASTCMDLIST(rm)
  175. ASTCMDLIST(rmdir)
  176. ASTCMDLIST(stty)
  177. //ASTCMDLIST(sha1sum)
  178. //BINCMDLIST(sha1sum)
  179. //ASTCMDLIST(sha256sum)
  180. //BINCMDLIST(sha256sum)
  181. //ASTCMDLIST(sha384sum)
  182. //BINCMDLIST(sha384sum)
  183. //ASTCMDLIST(sha512sum)
  184. //BINCMDLIST(sha512sum)
  185. ASTCMDLIST(sum)
  186. ASTCMDLIST(sync)
  187. ASTCMDLIST(tail)
  188. ASTCMDLIST(tee)
  189. //BINCMDLIST(tr)
  190. //ASTCMDLIST(tr)
  191. ASTCMDLIST(tty)
  192. ASTCMDLIST(uname)
  193. ASTCMDLIST(uniq)
  194. //ASTCMDLIST(vmstate)
  195. ASTCMDLIST(wc)
  196. // ASTCMDLIST(xgrep)
  197. //BINCMDLIST(xargs)
  198. //ASTCMDLIST(xargs)
  199.  
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203.  
  204. #endif /* !_GNULINUX_KSH_CMDLIST_H */
  205. ENDOFTEXT
  206.         return 0
  207. }
  208.  
  209. src_compile()
  210. {
  211.         cd ${S}
  212.  
  213.         #
  214.         # prepare build
  215.         #
  216.  
  217.         # translate cygport ARCH to AST hosttype
  218.         if [[ "$ARCH" == 'i686' ]] ; then
  219.                 ast_hosttype='cygwin.i386'
  220.         elif [[ "$ARCH" == 'x86_64' ]] ; then
  221.                 ast_hosttype='cygwin.i386-64'
  222.         else
  223.                 false
  224.         fi
  225.  
  226.         gnulinux_builtin_header="${PWD}/tmp_gnulinux_builtin_header.h"
  227.         print_gnulinux_builtin_header >"${gnulinux_builtin_header}"
  228.  
  229.         # ksh93+AST config flags
  230.         bast_flags="-DSHOPT_CMDLIB_BLTIN=0 -DSH_CMDLIB_DIR=\\\"/usr/ast/bin\\\" -DSHOPT_CMDLIB_HDR=\\\"${gnulinux_builtin_header}\\\" -DSHOPT_SYSRC"
  231.  
  232.         # build debug
  233.         #export IFFEFLAGS=-d1
  234.  
  235.         # fix build issues with mkfifo
  236.         sed -i -r 's/mkfifo.+?(-m [[:digit:]]+)/mkfifo /g' ./src/cmd/INIT/package.sh ./bin/package
  237.        
  238.        
  239.         #      
  240.         # build AT&T AST ksh
  241.         #
  242.         if [[ "$ARCH" == 'i686' ]] ; then
  243.                      export SHELL=/bin/bash HOSTTYPE="${ast_hosttype}"; \
  244.                         /bin/bash ./bin/package make \
  245.                                 CC="/usr/bin/gcc -m32 -std=gnu17" CCFLAGS="-Os -g ${bast_flags}" SHELL="$SHELL" HOSTTYPE="$HOSTTYPE"
  246.         elif [[ "$ARCH" == 'x86_64' ]] ; then
  247.                 export SHELL=/bin/bash HOSTTYPE="${ast_hosttype}"; \
  248.                         /bin/bash ./bin/package make \
  249.                                 CC="/usr/bin/gcc -m64 -std=gnu17" CCFLAGS="-Os -g ${bast_flags}" SHELL="$SHELL" HOSTTYPE="$HOSTTYPE"
  250.         else
  251.                 # unsupported arch!
  252.                 false
  253.         fi
  254.  
  255.  
  256.         #
  257.         # create ksh.kshrc
  258.         #
  259.         {
  260.                 printf '#\n# /etc/ksh.kshrc+~/.kshrc are sourced only for interactive shells\n#\n\n'
  261.                 printf '# default prompt\n'
  262.                 printf 'PS1=%q\n' $'\E[32m$(/usr/bin/logname)@$(/usr/bin/hostname) \E[33m${PWD/~(Sl-r)$HOME/"~"}\E[0m\n$ '
  263.                 printf '# default editor mode\n'
  264.                 printf 'set -o gmacs\n'
  265.         } >${S}/etc_ksh_kshrc
  266. }
  267.  
  268. #
  269. # install ksh, rksh, shcomp
  270. #
  271. src_install()
  272. {
  273.         if [[ "$ARCH" == 'i686' ]] ; then
  274.                 ast_hosttype='cygwin.i386'
  275.         elif [[ "$ARCH" == 'x86_64' ]] ; then
  276.                 ast_hosttype='cygwin.i386-64'
  277.         else
  278.                 false
  279.         fi
  280.  
  281.         /usr/bin/install -D -m0755 ${S}/arch/${ast_hosttype}/bin/ksh.exe ${D}/bin/ksh.exe
  282.         ln ${D}/bin/ksh.exe ${D}/bin/rksh.exe
  283.         ln ${D}/bin/ksh.exe ${D}/bin/ksh93.exe
  284.         ln ${D}/bin/ksh.exe ${D}/bin/rksh93.exe
  285.         /usr/bin/install -D -m0755 ${S}/arch/${ast_hosttype}/bin/ksh.exe ${D}/bin/shcomp.exe
  286.         /usr/bin/install -D -m0644 ${S}/arch/${ast_hosttype}/man/man1/sh.1 ${D}/usr/share/man/man1/ksh.1
  287.         /usr/bin/install -D -m0644 ${S}/etc_ksh_kshrc ${D}/etc/ksh.kshrc
  288.  
  289.         for i in ${S}/src/cmd/ksh93/tests/* ; do
  290.                 /usr/bin/install -D -m0644 $i ${D}/usr/share/ksh/tests/$(basename "$i")
  291.         done
  292. }
  293.  
  294. CYGWIN_MAINTAINER=Roland%20Mainz
  295. CYGWIN_MAINTAINER_EMAIL=roland.mainz@nrubsig.org
  296.  
  297. CYGWIN_CO_MAINTAINER=Cedric%20Blancher
  298. CYGWIN_CO_MAINTAINER_EMAIL=cedric.blancher@gmail.com
  299.  
  300. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at