-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathextract.sh
executable file
·73 lines (59 loc) · 2.2 KB
/
extract.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
#!/bin/sh
#
# Extract the necessary files from Lotus 1-2-3 UNIX
#
BASE="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
IMG="${BASE}"
ROOT="${BASE}/share"
ORIG="${BASE}/orig"
ETC="${ROOT}/lotus/etc"
LOTUS="${ROOT}/lotus/123.v10"
CPIO="$(command -v cpio)"
TAR="$(command -v tar)"
if [ "$1" = 'clean' ]; then
rm -rfv "${ROOT}" "${ORIG}" "${ETC}"
exit
fi
# Use any tools placed in this directory first.
export PATH="${BASE}:$PATH"
if ! test -f "${IMG}/123UNIX1.IMG" \
-a -f "${IMG}/123UNIX2.IMG" \
-a -f "${IMG}/123UNIX3.IMG" \
-a -f "${IMG}/123UNIX4.IMG" \
-a -f "${IMG}/123UNIX5.IMG"; then
echo >&2 'You need to download the original 1-2-3 UNIX IMG files.'
echo >&2 'They are available here: https://archive.org/download/123-unix'
exit 1
fi
mkdir "${ROOT}"
mkdir "${ORIG}"
cd "${ROOT}"
echo '==> Extracting 123UNIX1.IMG tar archive'
"${TAR}" xvf "${IMG}/123UNIX1.IMG"
echo '==> Extracting 123UNIX2.IMG cpio archive'
"${CPIO}" -idv < "${IMG}/123UNIX2.IMG"
echo '==> Extracting 123UNIX3.IMG cpio archive'
"${CPIO}" -idv < "${IMG}/123UNIX3.IMG"
echo '==> Seeking into 123UNIX4.IMG to extract cpio archive'
dd if="${IMG}/123UNIX4.IMG" skip=1 bs=550536 | "${CPIO}" -idv
echo '==> Extracting 123UNIX5.IMG cpio archive'
"${CPIO}" -idv < "${IMG}/123UNIX5.IMG"
cd - > /dev/null
echo '==> Reconstructing object file'
if ! cat "${LOTUS}"/sysV386/lib/123.o.z_1 "${LOTUS}"/sysV386/lib/123.o.z_2 | zcat > "${ORIG}/123.o"; then
echo >&2 'Failed to decompress object files.'
echo >&2 'If you see the message "code out of range", gzip is too old.'
echo >&2 'You can try running ./gzip.sh to build a recent gzip that is known to work.'
rm -f "${ORIG}/123.o"
exit 1
fi
echo '==> Uncompressing .z files'
find "${ROOT}" -iname '*.z' -exec gunzip --force {} \;
echo '==> Uncompressing and copying remaining object files'
cp "${LOTUS}"/sysV386/lib/*.o "${ORIG}/"
echo '==> Copying the banner template over'
install -vDm644 "${ROOT}/usr/tmp/lotus_install/123/banner" "${LOTUS}/ri/USA-English/123ban.ri"
echo '==> Copying default config file'
install -vDm644 l123set.cf "${ETC}/l123set.cf"
echo '==> Copying man page'
install -vDm644 "${ROOT}/lotus/man/man1/123.1" "${ROOT}/man/man1/123.1"