Skip to content

Commit 3197cf2

Browse files
committed
Reproducible builds: reduce non-determinism in build process (WIP)
- Remove environment dependant fields from required()'d package.json files in browserify bundles using https://github.com/fanatid/browserify-package-json - Lock-down npm dependencies using npm-shrinkwrap - Lock-down bower dependencies using https://gist.github.com/shesek/029fbf279b826005095dad50697c0e27 - Monkey-patch archiver to produce deterministic zips (reset timestamps/modes and canonicalize file order), used for nwjs builds by grunt-nw-builder and grunt-contrib-compress - Switch Chrome app build process to use the now determinstic archiver instead of the zip cli - Canonincalize format for main package.json file (packed in nwjs builds)
1 parent c98860f commit 3197cf2

File tree

7 files changed

+11117
-17
lines changed

7 files changed

+11117
-17
lines changed

Gruntfile.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
require('./util/deterministic-zip')
4+
35
module.exports = function(grunt) {
46

57
require('load-grunt-tasks')(grunt);
@@ -249,6 +251,15 @@ module.exports = function(grunt) {
249251
cwd: './webkitbuilds/<%= pkg.title %>/linux64/',
250252
src: ['**/*'],
251253
dest: '<%= pkg.title %>-linux/'
254+
},
255+
chrome: {
256+
options: {
257+
archive: './chrome-app/<%= pkg.name %>-chrome-extension.zip'
258+
},
259+
expand: true,
260+
cwd: './chrome-app/build',
261+
src: ['**/*'],
262+
dest: '<%= pkg.name %>-chrome-extension'
252263
}
253264
},
254265
browserify: {
@@ -257,6 +268,11 @@ module.exports = function(grunt) {
257268
'angular-bitcore-wallet-client/angular-bitcore-wallet-client.js': ['angular-bitcore-wallet-client/index.js'],
258269
'angular-bitauth/angular-bitauth.js': ['angular-bitauth/index.js']
259270
},
271+
options: {
272+
// remove all package.json fields except for name and version
273+
// (some fields are environment dependant, include full system paths, etc)
274+
transform: [ [ 'browserify-package-json', { global: true, only: [ 'name', 'version' ] } ] ]
275+
}
260276
}
261277
}
262278
});

app-template/apply.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Object.keys(templates).forEach(function(k) {
6262
k = 'config.xml';
6363
} else if (k === 'package-template.json') {
6464
k = 'package.json';
65+
// canonical reproducible format for package.json (strip extra spaces, duplicate "//" field, etc)
66+
content = JSON.stringify(JSON.parse(content), null, 2) + '\n'
6567
}
6668

6769
if (!fs.existsSync('../' + targetDir)) {

app-template/package-template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@
7777
"grunt-nw-builder": "^2.0.3",
7878
"grunt-sass": "^1.2.0",
7979
"load-grunt-tasks": "^3.5.0",
80-
"shelljs": "^0.3.0"
80+
"shelljs": "^0.3.0",
81+
"browserify-package-json": "^1.0.1"
8182
},
8283
"scripts": {
8384
"postinstall": "bower install",

bower.json

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,45 @@
77
"bitcore"
88
],
99
"dependencies": {
10-
"angular-mocks": "1.4.10",
11-
"angular-gettext": "2.2.1",
12-
"angular-moment": "0.10.1",
13-
"angular-qrcode": "bitpay/angular-qrcode#~6.3.0",
14-
"ionic": "https://github.com/ionic-team/ionic-v1.git",
15-
"moment": "2.10.3",
16-
"ng-lodash": "0.2.3",
17-
"qrcode-decoder-js": "*",
10+
"angular-mocks": "https://github.com/angular/bower-angular-mocks.git#f5bcaf2b32c76f778704b7e92f31d661c24f3364",
11+
"angular-gettext": "https://github.com/rubenv/angular-gettext.git#df72273b60377d6991911757cc0c5bbe1107eefd",
12+
"angular-moment": "https://github.com/urish/angular-moment.git#8910240ee1872478a1b318d2d800c1c073526c37",
13+
"angular-qrcode": "https://github.com/bitpay/angular-qrcode.git#290911217db50c3411821448401945d6c4180bbf",
14+
"ionic": "https://github.com/ionic-team/ionic-v1.git#1b7414fabafc8a87252d9ec30d004bf6ac3fa5a7",
15+
"moment": "https://github.com/moment/moment.git#6fa444238494318e3c488c81d8520ad2eba8bae7",
16+
"ng-lodash": "https://github.com/rockabox/ng-lodash.git#0f144f0f9b1884a6d0ae9de5db91d8f7354e30ee",
17+
"qrcode-decoder-js": "https://github.com/colkito/qrcode-decoder-js.git#b71009466546b975014d0b7e1cf7a158c8fdc7ef",
1818
"trezor-connect": "https://github.com/trezor/connect.git#c1a00f9f0f4a13239ba13ddd589c6ca61f2e7876",
19-
"ng-csv": "~0.3.6",
20-
"ionic-toast": "^0.4.1",
21-
"angular-clipboard": "^1.4.2",
22-
"angular-md5": "^0.1.10",
23-
"ngtouch": "^1.0.1"
19+
"ng-csv": "https://github.com/asafdav/ng-csv.git#6ad5e86785cbc585824268ba065b8a37e7526458",
20+
"ionic-toast": "https://github.com/rajeshwarpatlolla/ionic-toast.git#d2e9fcab0bf0527ceecfe3fb78f8d1f47fecb436",
21+
"angular-clipboard": "https://github.com/omichelsen/angular-clipboard.git#6861d5ead55956fb01d64520546c625605366f1a",
22+
"angular-md5": "https://github.com/gdi2290/angular-md5.git#f0c5d61f92a807b4d3a0b2be98890d8948e03fe7",
23+
"ngtouch": "https://github.com/nglar/ngTouch.git#1285101327290670a9b85d900254d46f771e6421",
24+
"angular-animate": "https://github.com/angular/bower-angular-animate.git#671c738980fb0509b2b494716ccd8c004c39f368",
25+
"angular": "https://github.com/angular/bower-angular.git#5a07c5107b4d24f41744a02b07717d55bad88e70",
26+
"angular-sanitize": "https://github.com/angular/bower-angular-sanitize.git#d62a5eecedc71828f6f935fbde6c07217a95988a",
27+
"angular-ui-router": "https://github.com/angular-ui/angular-ui-router-bower.git#2e580f271defdec34f464aab0cca519e41d1ee33",
28+
"qrcode-generator": "git://github.com/monospaced/bower-qrcode-generator.git#64e898f180fbd76aa2740be41124d219aa735f0c"
2429
},
2530
"resolutions": {
26-
"angular": "1.5.3",
27-
"ionic": "1b7414faba"
31+
"angular": "5a07c5107b4d24f41744a02b07717d55bad88e70",
32+
"ionic": "1b7414fabafc8a87252d9ec30d004bf6ac3fa5a7",
33+
"angular-animate": "671c738980fb0509b2b494716ccd8c004c39f368",
34+
"angular-clipboard": "6861d5ead55956fb01d64520546c625605366f1a",
35+
"angular-gettext": "df72273b60377d6991911757cc0c5bbe1107eefd",
36+
"angular-md5": "f0c5d61f92a807b4d3a0b2be98890d8948e03fe7",
37+
"angular-mocks": "f5bcaf2b32c76f778704b7e92f31d661c24f3364",
38+
"angular-moment": "8910240ee1872478a1b318d2d800c1c073526c37",
39+
"angular-qrcode": "290911217db50c3411821448401945d6c4180bbf",
40+
"angular-sanitize": "d62a5eecedc71828f6f935fbde6c07217a95988a",
41+
"angular-ui-router": "2e580f271defdec34f464aab0cca519e41d1ee33",
42+
"ionic-toast": "d2e9fcab0bf0527ceecfe3fb78f8d1f47fecb436",
43+
"qrcode-decoder-js": "b71009466546b975014d0b7e1cf7a158c8fdc7ef",
44+
"moment": "6fa444238494318e3c488c81d8520ad2eba8bae7",
45+
"ng-csv": "6ad5e86785cbc585824268ba065b8a37e7526458",
46+
"ng-lodash": "0f144f0f9b1884a6d0ae9de5db91d8f7354e30ee",
47+
"ngtouch": "1285101327290670a9b85d900254d46f771e6421",
48+
"qrcode-generator": "64e898f180fbd76aa2740be41124d219aa735f0c",
49+
"trezor-connect": "c1a00f9f0f4a13239ba13ddd589c6ca61f2e7876"
2850
}
2951
}

chrome-app/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ files:
2323
$(ZIPFILE): dir files
2424
cd $(BUILDDIR)
2525
rm -f $(ZIPFILE)
26-
zip -qr $(ZIPFILE) "`basename $(BUILDDIR)`"
26+
# use grunt-contrib-compress, patched for reproducibility
27+
../node_modules/.bin/grunt compress:chrome
28+
2729
@echo "** The Chrome Extension is ready at cobit-chrome-extension.zip"

0 commit comments

Comments
 (0)