blob: 182e515c2f1b27644d4b5b58a1454799775516ba (
plain) (
blame)
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
|
{ lib
, fetchurl
, bash
, tinycc
, gnumake
, gnupatch
, heirloom-devtools
, heirloom
}:
let
pname = "heirloom";
version = "070715";
src = fetchurl {
url = "mirror://sourceforge/heirloom/heirloom/${version}/heirloom-${version}.tar.bz2";
sha256 = "sha256-6zP3C8wBmx0OCkHx11UtRcV6FicuThxIY07D5ESWow8=";
};
patches = [
# we pre-generate nawk's proctab.c as meslibc is not capable of running maketab
# during build time (insufficient sscanf support)
./proctab.patch
# disable utilities that don't build successfully
./disable-programs.patch
# "tcc -ar" doesn't support creating empty archives
./tcc-empty-ar.patch
# meslibc doesn't have seperate libm
./dont-link-lm.patch
# meslibc's vprintf doesn't support %ll
./vprintf.patch
# meslibc doesn't support sysconf()
./sysconf.patch
# meslibc doesn't support locale
./strcoll.patch
# meslibc doesn't support termios.h
./termios.patch
# meslibc doesn't support utime.h
./utime.patch
# meslibc doesn't support langinfo.h
./langinfo.patch
# support building with meslibc
./meslibc-support.patch
# remove socket functionality as unsupported by meslibc
./cp-no-socket.patch
];
makeFlags = [
# mk.config build options
"CC='tcc -B ${tinycc.libs}/lib -include ${./stubs.h} -include ${./musl.h}'"
"AR='tcc -ar'"
"RANLIB=true"
"STRIP=true"
"SHELL=${bash}/bin/sh"
"POSIX_SHELL=${bash}/bin/sh"
"DEFBIN=/bin"
"SV3BIN=/5bin"
"S42BIN=/5bin/s42"
"SUSBIN=/bin"
"SU3BIN=/5bin/posix2001"
"UCBBIN=/ucb"
"CCSBIN=/ccs/bin"
"DEFLIB=/lib"
"DEFSBIN=/bin"
"MANDIR=/share/man"
"LCURS=" # disable ncurses
"USE_ZLIB=0" # disable zlib
"IWCHAR='-I../libwchar'"
"LWCHAR='-L../libwchar -lwchar'"
];
in
bash.runCommand "${pname}-${version}" {
inherit pname version;
nativeBuildInputs = [
tinycc.compiler
gnumake
gnupatch
heirloom-devtools
];
passthru.sed =
bash.runCommand "${pname}-sed-${version}" {} ''
install -D ${heirloom}/bin/sed $out/bin/sed
'';
passthru.tests.get-version = result:
bash.runCommand "${pname}-get-version-${version}" {} ''
${result}/bin/banner Hello Heirloom
mkdir $out
'';
meta = with lib; {
description = "The Heirloom Toolchest is a collection of standard Unix utilities";
homepage = "https://heirloom.sourceforge.net/tools.html";
license = with licenses; [
# All licenses according to LICENSE/
zlib
caldera
bsdOriginalUC
cddl
bsd3
gpl2Plus
lgpl21Plus
lpl-102
info-zip
];
maintainers = teams.minimal-bootstrap.members;
platforms = platforms.unix;
};
} ''
# Unpack
unbz2 --file ${src} --output heirloom.tar
untar --file heirloom.tar
rm heirloom.tar
cd heirloom-${version}
# Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches}
cp ${./proctab.c} nawk/proctab.c
# Build
# These tools are required during later build steps
export PATH="$PATH:$PWD/ed:$PWD/nawk:$PWD/sed"
make ${lib.concatStringsSep " " makeFlags}
# Install
make install ROOT=$out ${lib.concatStringsSep " " makeFlags}
''
|