Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create consistent output across architectures #69

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/util/tar-create-options.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
const zlib = require('zlib')
const isPackageBin = require('./is-package-bin.js')

const tarCreateOptions = manifest => ({
cwd: manifest._resolved,
prefix: 'package/',
portable: true,
gzip: true,
gzip: {
// forcing the compression strategy to Z_RLE
// yields a bit-identical, though considerably
// larger, end result in both arm64 and x86_64.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... reproducible builds are good, but I feel like sending considerably more data over the wire is not great.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it any less bad if you add

{
  windowBits: 15,
  memLevel: 9,
  level: 9,
  strategy: 3,
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, is the dir fetcher here in pacote also what libnpmpack uses to create the tarball for upload?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those settings make no difference at all.

also, confirmed that yes this is indeed the module that packs a tarball for publishing. so, yes, you're right, this is not what we want to do by default. i can tweak this so that this setting will only take place as part of fetching and packing a remote git repository.

strategy: zlib.constants.Z_RLE
},

// ensure that package bins are always executable
// Note that npm-packlist is already filtering out
Expand Down
10 changes: 5 additions & 5 deletions tap-snapshots/test-dir.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
exports[`test/dir.js TAP basic > extract 1`] = `
Object {
"from": "file:test/fixtures/abbrev",
"integrity": "sha512-Ict4yhLfiPOkcX+yjBRSI2QUetKt+A08AXMyLeQbKGYg/OGI/1k47Hu9tWZOx1l4j+M1z07Zxt3IL41TmLkbDw==",
"integrity": "sha512-iCEu2GgFDiFk7K1qG3hdEsSf88hyxS1rFKtcc8N4aPZZFR5+IIUK5xsPkpLMHCdQttCN+eSP5qMS2ZW4XKMy2g==",
"resolved": "\${CWD}/test/fixtures/abbrev",
}
`
Expand Down Expand Up @@ -176,15 +176,15 @@ Object {
exports[`test/dir.js TAP make bins executable > results of unpack 1`] = `
Object {
"from": "file:test/fixtures/bin-object",
"integrity": "sha512-rlE32nBV7XgKCm0I7YqAewyVPbaRJWUQMZUFLlngGK3imG+som3Hin7d/zPTikWg64tHIxb8VXeeq6u0IRRfmQ==",
"integrity": "sha512-IKQYaxHY6sS/+fMP1EPUJF0+6a2Rk9Ek7QoJpY+h/NvNGHsMdVzhRFcRwUAuWt9196rWIY/pKi8aCw8jOwR4kg==",
"resolved": "\${CWD}/test/fixtures/bin-object",
}
`

exports[`test/dir.js TAP responds to foregroundScripts: true > extract 1`] = `
Object {
"from": "file:test/fixtures/prepare-script",
"integrity": "sha512-HTzPAt8wmXNchUdisnGDSCuUgrFee5v8F6GsLc5mQd29VXiNzv4PGz71jjLSIF1wWQSB+UjLTmSJSGznF/s/Lw==",
"integrity": "sha512-WVTDu5aN+EdeoftNUCvhrDZUg+JVdIs2nkoskE8ijueo/w4Z0198tY5Ow0GFpzBhpf3PRsy67N2wvVzDRLDJNw==",
"resolved": "\${CWD}/test/fixtures/prepare-script",
}
`
Expand Down Expand Up @@ -250,7 +250,7 @@ Object {
exports[`test/dir.js TAP responds to foregroundScripts: true and log:{level: silent} > extract 1`] = `
Object {
"from": "file:test/fixtures/prepare-script",
"integrity": "sha512-HTzPAt8wmXNchUdisnGDSCuUgrFee5v8F6GsLc5mQd29VXiNzv4PGz71jjLSIF1wWQSB+UjLTmSJSGznF/s/Lw==",
"integrity": "sha512-WVTDu5aN+EdeoftNUCvhrDZUg+JVdIs2nkoskE8ijueo/w4Z0198tY5Ow0GFpzBhpf3PRsy67N2wvVzDRLDJNw==",
"resolved": "\${CWD}/test/fixtures/prepare-script",
}
`
Expand Down Expand Up @@ -316,7 +316,7 @@ Object {
exports[`test/dir.js TAP with prepare script > extract 1`] = `
Object {
"from": "file:test/fixtures/prepare-script",
"integrity": "sha512-HTzPAt8wmXNchUdisnGDSCuUgrFee5v8F6GsLc5mQd29VXiNzv4PGz71jjLSIF1wWQSB+UjLTmSJSGznF/s/Lw==",
"integrity": "sha512-WVTDu5aN+EdeoftNUCvhrDZUg+JVdIs2nkoskE8ijueo/w4Z0198tY5Ow0GFpzBhpf3PRsy67N2wvVzDRLDJNw==",
"resolved": "\${CWD}/test/fixtures/prepare-script",
}
`
Expand Down
4 changes: 3 additions & 1 deletion test/dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ t.test('exposes tarCreateOptions method', async t => {
cwd: '/home/foo',
prefix: 'package/',
portable: true,
gzip: true,
gzip: {
strategy: 3
},
mtime: new Date('1985-10-26T08:15:00.000Z'),
},
'should return standard options'
Expand Down
4 changes: 3 additions & 1 deletion test/util/tar-create-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ t.match(
cwd: '/home/foo',
prefix: 'package/',
portable: true,
gzip: true,
gzip: {
strategy: 3
},
mtime: new Date('1985-10-26T08:15:00.000Z'),
},
'should return standard options'
Expand Down