/
spec-bin.sh
executable file
·170 lines (137 loc) · 3.53 KB
/
spec-bin.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash
#
# Build binaries for the spec tests.
#
# TODO:
# - coreutils
# - re2c for the OSH build
#
# Usage:
# ./spec-bin.sh <function name>
set -o nounset
set -o pipefail
set -o errexit
readonly THIS_DIR=$(cd $(dirname $0) && pwd)
readonly DIR=$THIS_DIR/../_tmp/spec-bin
download() {
mkdir -p $DIR
wget --no-clobber --directory $DIR \
https://www.oilshell.org/blob/spec-bin/bash-4.4.tar.gz \
https://www.oilshell.org/blob/spec-bin/busybox-1.22.0.tar.bz2 \
https://www.oilshell.org/blob/spec-bin/dash-0.5.8.tar.gz \
https://www.oilshell.org/blob/spec-bin/mksh-R52c.tgz \
https://www.oilshell.org/blob/spec-bin/zsh-5.1.1.tar.xz
}
extract-all() {
pushd $DIR
for archive in *.tar.* *.tgz; do
echo $archive
tar --extract --file $archive
done
mv -v mksh mksh-R52c # so it doesn't collide
popd
}
build-zsh() {
local prefix=$DIR/zsh-out
pushd $DIR/zsh-5.1.1
# This builds config.modules
./configure --disable-dynamic
# Build a static version of ZSH
# For some reason the regex module isn't included if we --disable-dynamic?
# name=zsh/regex modfile=Src/Modules/regex.mdd link=no
# ->
# name=zsh/regex modfile=Src/Modules/regex.mdd link=static
# INSTALL says I need this after editing config.modules.
sed -i 's/regex.mdd link=no/regex.mdd link=static/' config.modules
make prep
make
# This way works on a given machine, but the binaries can't be relocated!
#./configure --prefix $prefix
#make
#make install
popd
}
# bash/dash: ./configure; make
# mksh: sh Build.sh
# busybox: make defconfig (default config); make
build-bash() {
pushd $DIR/bash-4.4
./configure
make
popd
}
build-dash() {
pushd $DIR/dash-0.5.8
./configure
make
popd
}
build-mksh() {
pushd $DIR/mksh-R52c
sh Build.sh
popd
}
build-busybox() {
pushd $DIR/busybox-1.22.0
make defconfig
make
popd
}
build-all() {
build-bash
build-dash
build-mksh
build-busybox
# ZSH is a bit special
build-zsh
}
copy-all() {
pushd $DIR
cp -f -v bash-4.4/bash .
cp -f -v dash-0.5.8/src/dash .
cp -f -v mksh-R52c/mksh .
cp -f -v busybox-1.22.0/busybox .
ln -s -f -v busybox ash
# In its own tree
#ln -s -f -v zsh-out/bin/zsh .
# Static binary
cp -f -v zsh-5.1.1/Src/zsh .
popd
}
test-all() {
for sh in bash dash zsh mksh ash; do
$DIR/$sh -c 'echo "Hello from $0"'
# bash and zsh depend on libtinfo, but others don't
# ash and zsh depend on libm, but others don't
# bash and zsh depend on libdl, but others don't
ldd $DIR/$sh
done
}
#
# NOTE: This is older stuff I saved. We may want to use newer shell versions?
#
_wget() {
wget --no-clobber --directory _tmp/src "$@"
}
# As of March 2017
download-shell-source() {
mkdir -p _tmp/src
# https://tiswww.case.edu/php/chet/bash/bashtop.html - 9/2016 release
# https://ftp.gnu.org/gnu/bash/
_wget https://ftp.gnu.org/gnu/bash/bash-4.4.tar.gz
# https://www.mirbsd.org/mksh.htm - no dates given
_wget https://www.mirbsd.org/MirOS/dist/mir/mksh/mksh-R54.tgz
# https://tracker.debian.org/pkg/dash -- old versions
# http://www.linuxfromscratch.org/blfs/view/svn/postlfs/dash.html
# Site seems down now.
# _wget http://gondor.apana.org.au/~herbert/dash/files/dash-0.5.9.1.tar.gz
# http://zsh.sourceforge.net/News/ - 12/2016 release
_wget https://downloads.sourceforge.net/project/zsh/zsh/5.3.1/zsh-5.3.1.tar.xz
}
publish-tmp() {
local name=$1 # required
local dest=oilshell.org/share/2018-10-06-tmp/
ssh ${name}@${name}.org mkdir -p $dest
scp _deps/re2c-1.0.3/re2c ${name}@${name}.org:$dest
}
"$@"