Skip to content

Commit 5cfb241

Browse files
authored
Update: use a named version folder in NPM tarballs (#4094)
**Summary** Fixes #3758. Makes the top-level folder in the tar archives have a name like `yarn-vX.Y.Z` instead of `dist` using the `--transform` and `-s` options in `tar` (they are different in GNU and BSD `tar`). **Test plan** Run `yarn build-dist` and then `tar -ztvf artifacts/yarn-v1.0.0.tar.gz`. Make sure the output lists all the files under `yarn-v1.0.0` directory.
1 parent 6798df4 commit 5cfb241

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

scripts/build-deb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ensureAvailable lintian
1313
ensureAvailable rpmbuild
1414

1515
PACKAGE_TMPDIR=tmp/debian_pkg
16-
VERSION=`dist/bin/yarn --version`
16+
VERSION=`./artifacts/yarn-legacy-* --version`
1717
OUTPUT_DIR=artifacts
1818
TARBALL_NAME=$OUTPUT_DIR/yarn-v$VERSION.tar.gz
1919
DEB_PACKAGE_NAME=yarn_$VERSION'_all.deb'

scripts/build-dist.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files)
88
# Workaround for https://github.com/yarnpkg/yarn/issues/2591
99
case "$(uname -s)" in
1010
*CYGWIN*|MSYS*|MINGW*)
11-
dist_yarn=dist/bin/yarn.cmd
1211
system_yarn=yarn.cmd
1312
;;
1413
*)
15-
dist_yarn=dist/bin/yarn
1614
system_yarn=yarn
1715
;;
1816
esac
@@ -49,5 +47,17 @@ cp node_modules/v8-compile-cache/v8-compile-cache.js dist/lib/v8-compile-cache.j
4947
# Verify that it works as expected
5048
[[ "$version" == "$(./dist/bin/yarn --version)" ]] || exit 1;
5149

52-
./scripts/update-dist-manifest.js $(readlink -f dist/package.json) tar
53-
tar -cvzf artifacts/yarn-v$version.tar.gz dist/*
50+
./scripts/update-dist-manifest.js $(node -p -e "require('fs').realpathSync('dist/package.json')") tar
51+
52+
case "$(tar --version)" in
53+
*GNU*)
54+
tar -cvzf artifacts/yarn-v$version.tar.gz --transform="s/^dist/yarn-v$version/" dist/*
55+
;;
56+
bsdtar*)
57+
tar -cvzf artifacts/yarn-v$version.tar.gz -s "/^dist/yarn-v$version/" dist/*
58+
;;
59+
*)
60+
echo "Can't determine tar type (BSD/GNU)!"
61+
exit 1
62+
;;
63+
esac

scripts/update-dist-manifest.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
*/
1010

1111
const fs = require('fs');
12-
1312
const packageManifestFilename = process.argv[2];
1413
const packageManifest = require(packageManifestFilename);
1514

1615
packageManifest.installationMethod = process.argv[3];
16+
17+
if (!packageManifest.installationMethod) {
18+
throw new Error('You need to specify an installation method.');
19+
}
20+
1721
delete packageManifest.dependencies;
1822
delete packageManifest.devDependencies;
1923
delete packageManifest.scripts;

0 commit comments

Comments
 (0)