forked from well-typed/libedsign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.nix
270 lines (223 loc) · 8.99 KB
/
release.nix
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
{ edsign ? { outPath = ./.; revCount = 0; shortRev = "abcdef"; rev = "HEAD"; }
, officialRelease ? false
, coverityUpload ? false
}:
let
nixcfg = { allowUnfree = true; };
pkgs = import <nixpkgs> { config=nixcfg; };
systems = [ "i686-linux" "x86_64-linux"
#"x86_64-darwin"
];
version = builtins.readFile ./VERSION +
(pkgs.lib.optionalString (!officialRelease)
"-r${toString edsign.revCount}-g${edsign.shortRev}");
ifNotCoverity = x: if coverityUpload == true then {} else x;
ifCoverity = x: if coverityUpload == false then {} else x;
jobs = rec {
## -- Tarballs -------------------------------------------------------------
tarball = pkgs.releaseTools.sourceTarball {
name = "edsign-tarball";
src = edsign;
inherit version;
buildInputs = with pkgs; [ git xz perl ];
meta.maintainers = [ "[email protected]" ];
distPhase = ''
relname=edsign-${version}
mkdir ../$relname
cp -prd . ../$relname
rm -rf ../$relname/.git ../$relname/svn-revision
echo -n ${version} > ../$relname/VERSION
mkdir $out/tarballs
tar cvfJ $out/tarballs/$relname.tar.xz -C .. $relname
'';
};
amalgamation = ifNotCoverity (pkgs.releaseTools.sourceTarball {
name = "edsign-amalgamation";
src = edsign;
inherit version;
buildInputs = with pkgs; [ git xz perl perlPackages.ListMoreUtils ];
meta.maintainers = [ "[email protected]" ];
distPhase = ''
relname=edsign-${version}-amalg
mkdir ../$relname-orig ../$relname
cp -prd . ../$relname-orig
rm -rf ../$relname-orig/.git ../$relname-orig/svn-revision
echo -n ${version} > ../$relname-orig/VERSION
make -C ../$relname-orig distclean # Clean up files
make -C ../$relname-orig sdistprep # Generate amalgamation
cp ../$relname-orig/lib/edsign-amalg.c ../$relname/edsign.c
cp ../$relname-orig/etc/amalg/Makefile.in ../$relname/Makefile
for x in LICENSE.txt README.md VERSION CHANGELOG.md lib/edsign.h; do
cp ../$relname-orig/$x ../$relname
done
mkdir $out/tarballs
tar cvfJ $out/tarballs/$relname.tar.xz -C .. $relname
'';
});
## -- Build ----------------------------------------------------------------
build = ifNotCoverity (pkgs.lib.genAttrs systems (system:
with import <nixpkgs> { inherit system; config=nixcfg; };
releaseTools.nixBuild {
name = "edsign";
inherit version;
src = tarball;
meta.maintainers = [ "[email protected]" ];
enableParallelBuilding = true;
doCheck = false;
installPhase = "make install PREFIX=$out";
}
));
build-amalgamation = ifNotCoverity (pkgs.lib.genAttrs systems (system:
with import <nixpkgs> { inherit system; config=nixcfg; };
releaseTools.nixBuild {
name = "edsign";
inherit version;
src = amalgamation;
meta.maintainers = [ "[email protected]" ];
doCheck = false;
dontInstall = true;
}
));
## -- Tests ----------------------------------------------------------------
tests = ifNotCoverity (pkgs.lib.genAttrs systems (system:
with import <nixpkgs> { inherit system; config=nixcfg; };
releaseTools.nixBuild {
name = "edsign-test";
inherit version;
src = tarball;
buildInputs = with pkgs; [ perl perlPackages.ListMoreUtils ];
meta.maintainers = [ "[email protected]" ];
enableParallelBuilding = true;
doCheck = true;
checkFlags = [ "DEBUG=1" ];
dontInstall = true;
}
));
## -- Coverity -------------------------------------------------------------
coverity = ifCoverity (
with import <nixpkgs> { system = "x86_64-linux"; config=nixcfg; };
releaseTools.coverityAnalysis {
name = "edsign-coverity";
inherit version;
src = tarball;
buildInputs = with pkgs; [ perl perlPackages.ListMoreUtils ];
meta.maintainers = [ "[email protected]" ];
buildPhase = "make all check DEBUG=1";
doCheck = false;
}
);
## -- Clang analyzer -------------------------------------------------------
clang-analyzer = ifNotCoverity (
with import <nixpkgs> { system = "x86_64-linux"; config=nixcfg; };
releaseTools.clangAnalysis {
name = "edsign-clang-analyzer";
inherit version;
src = tarball;
buildInputs = with pkgs; [ perl perlPackages.ListMoreUtils ];
meta.maintainers = [ "[email protected]" ];
buildPhase = "make all check DEBUG=1";
doCheck = false;
}
);
## -- Frama-C --------------------------------------------------------------
# frama-c = ifNotCoverity (
# with import <nixpkgs> { system = "x86_64-linux"; config=nixcfg; };
#
# releaseTools.nixBuild {
# name = "edsign-frama-c";
# inherit version;
# src = tarball;
# buildInputs = with pkgs; [ framac perl perlPackages.ListMoreUtils ];
# meta.maintainers = [ "[email protected]" ];
#
# buildPhase = "make framalyze DEBUG=1";
# doCheck = false;
# dontInstall = true;
# }
# );
## -- Coverage -------------------------------------------------------------
coverage = ifNotCoverity (
with import <nixpkgs> { system = "x86_64-linux"; config=nixcfg; };
releaseTools.coverageAnalysis {
name = "edsign-coverage";
inherit version;
src = tarball;
buildInputs = with pkgs; [ perl perlPackages.ListMoreUtils ];
meta.maintainers = [ "[email protected]" ];
enableParallelBuilding = true;
makeFlags = [ "DEBUG=1" ];
}
);
## -- Debian build ---------------------------------------------------------
#deb_debian7i386 = ifNotCoverity
# (makeDeb_i686 (diskImageFuns: diskImageFuns.debian7i386) 60);
#deb_debian7x86_64 = ifNotCoverity
# (makeDeb_x86_64 (diskImageFunsFun: diskImageFunsFun.debian7x86_64) 60);
## -- Ubuntu builds --------------------------------------------------------
#deb_ubuntu1004i386 = ifNotCoverity
# (makeDeb_i686 (diskImageFuns: diskImageFuns.ubuntu1004i386) 50);
#deb_ubuntu1004x86_64 = ifNotCoverity
# (makeDeb_x86_64 (diskImageFuns: diskImageFuns.ubuntu1004x86_64) 50);
#deb_ubuntu1204i386 = ifNotCoverity
# (makeDeb_i686 (diskImageFuns: diskImageFuns.ubuntu1204i386) 60);
#deb_ubuntu1204x86_64 = ifNotCoverity
# (makeDeb_x86_64 (diskImageFuns: diskImageFuns.ubuntu1204x86_64) 60);
#deb_ubuntu1404i386 = ifNotCoverity
# (makeDeb_i686 (diskImageFuns: diskImageFuns.ubuntu1404i386) 60);
#deb_ubuntu1404x86_64 = ifNotCoverity
# (makeDeb_x86_64 (diskImageFuns: diskImageFuns.ubuntu1404x86_64) 60);
## -- Fedora builds --------------------------------------------------------
#rpm_fedora20i386 = ifNotCoverity
# (makeRPM_i686 (diskImageFuns: diskImageFuns.fedora20i386) 70);
#rpm_fedora20x86_64 = ifNotCoverity
# (makeRPM_x86_64 (diskImageFunsFun: diskImageFunsFun.fedora20x86_64) 70);
## -- Release build --------------------------------------------------------
release = ifNotCoverity (pkgs.releaseTools.aggregate
{ name = "edsign-${version}";
constituents =
[ tarball amalgamation
build-amalgamation.i686-linux build-amalgamation.x86_64-linux # build-amalgamation.x86_64-darwin
build.i686-linux build.x86_64-linux # build.x86_64-darwin
tests.i686-linux tests.x86_64-linux # tests.x864_64-darwin
#deb_debian7i386 deb_debian7x86_64
#deb_ubuntu1004i386 deb_ubuntu1004x86_64
#deb_ubuntu1204i386 deb_ubuntu1204x86_64
#deb_ubuntu1404i386 deb_ubuntu1404x86_64
#rpm_fedora20i386 rpm_fedora20x86_64
coverage
];
meta.description = "Release-critical builds";
meta.maintainers = [ "[email protected]" ];
}
);
};
## -- RPM/Deb utilities ----------------------------------------------------
makeDeb_i686 = makeDeb "i686-linux";
makeDeb_x86_64 = makeDeb "x86_64-linux";
makeDeb =
system: diskImageFun: prio:
with import <nixpkgs> { inherit system; };
releaseTools.debBuild {
name = "edsign-deb";
src = jobs.tarball;
diskImage = (diskImageFun vmTools.diskImageFuns) {};
memSize = 1024;
meta.schedulingPriority = prio;
debMaintainer = "Austin Seipp <[email protected]>";
doInstallCheck = false;
preInstall = "export INSTALLPREFIX=/usr";
};
makeRPM_i686 = makeRPM "i686-linux";
makeRPM_x86_64 = makeRPM "x86_64-linux";
makeRPM =
system: diskImageFun: prio:
with import <nixpkgs> { inherit system; };
releaseTools.rpmBuild rec {
name = "edsign-rpm";
src = jobs.tarball;
diskImage = (diskImageFun vmTools.diskImageFuns) {};
memSize = 1024;
meta.schedulingPriority = prio;
preInstall = "export INSTALLPREFIX=/usr";
};
in jobs