Upgrade shells/
[dragora.git] / recipes / shells / mksh / recipe
blob181d6989bffd3224c67bdd9649523f092823aac5
1 # Build recipe for mksh (and lksh).
3 # Copyright (c) 2017-2021 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 #    http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Exit immediately on any error
18 set -e
20 program=mksh
21 version=R59c
22 release=1
24 # Define a category for the output of the package name
25 pkgcategory=shells
27 tarname=${program}-${version}.tgz
29 # Remote source(s)
30 fetch=http://www.mirbsd.org/MirOS/dist/mir/mksh/$tarname
32 description="
33 The MirBSD Korn Shell.
35 mksh is the MirBSD enhanced version of the Public Domain Korn shell
36 (pdksh), a Bourne-compatible shell which is largely similar to the
37 original AT&T Korn shell; mksh is the only pdksh derivate currently
38 being actively developed.  It includes bug fixes and feature
39 improvements, in order to produce a modern, robust shell good for
40 interactive and especially script use.
43 homepage=http://www.mirbsd.org/mksh.htm
44 license="The MirOS Licence, ISC, special terms for use the BSD daemon mascot"
46 # Limit package name to the program name
47 full_pkgname=$program
49 # Source documentation
50 docsdir="${docdir}/${program}"
52 # Source directory name
53 srcdir=mksh
55 build()
57     # Create package structure
58     mkdir -p "${destdir}/etc/skel" \
59              "${destdir}/usr/bin"  \
60              "${destdir}/${mandir}/man1"
62     unpack "${tardir}/$tarname"
64     cd "$srcdir"
66     # Set sane permissions
67     chmod -R u+w,go-w,a+rX-s .
69     # Create a separate build directory
70     mkdir mksh-build lksh-build
72     # Build and install mksh
74     cd mksh-build
75     (
76         # Build and ignore tests for now in this version of mksh-r57
77         # (../mksh/check.t:xxx-stat-1 needs further work)
78         #sh ../Build.sh -r && ./test.sh
80         env CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" LDSTATIC=-static \
81         sh ../Build.sh -r
82     )
84     cp -p mksh "${destdir}/usr/bin/"
85     chmod 755 "${destdir}/usr/bin/mksh"
87     #cp -p ../${srcdir}/dot.mkshrc "${destdir}/etc/skel/.mkshrc"
88     cp -p "${archive}/etc/skel/.mkshrc" "${destdir}/etc/skel/"
89     chmod 644 "${destdir}/etc/skel/.mkshrc"
91     # To manage (dot new) config file
92     touch "${destdir}/etc/skel/.graft-config"
94     cd ..
96     cp -p mksh.1 "${destdir}/${mandir}/man1/"
97     chmod 644 "${destdir}/${mandir}/man1/mksh.1"
99     # Build and install lksh (legacy)
101     cd lksh-build
102     (
103         # Build and ignore tests for now in this version of mksh-r57
104         # (../mksh/check.t:xxx-stat-1 needs further work)
105         #sh ../Build.sh -L -r && ./test.sh
107         env CPPFLAGS="$CPPFLAGS -DMKSH_BINSHPOSIX" \
108             CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" LDSTATIC=-static \
109         sh ../Build.sh -L -r
110     )
112     cp -p lksh "${destdir}/usr/bin/"
113     chmod 755 "${destdir}/usr/bin/lksh"
115     cd ..
117     cp -p lksh.1 "${destdir}/${mandir}/man1/"
118     chmod 644 "${destdir}/${mandir}/man1/lksh.1"
120     # Make symlink to compose the default shell
121     ( cd "${destdir}/usr/bin" && ln -sf lksh sh )
123     # Compress manual pages
124     if test -d "${destdir}/$mandir"
125     then
126         lzip -9 "${destdir}/${mandir}"/man?/*
127     fi
129     # Build and copy documentation
130     sh FAQ2HTML.sh
131     mkdir -p "${destdir}${docsdir}"
132     cp -p FAQ.htm "${destdir}${docsdir}"