4
4
5
5
# Ensure all the tools we need are available
6
6
ensureAvailable () {
7
- eval $1 --version > /dev/null || (echo " You need to install $1 " && exit 2)
7
+ command -v " $1 " > /dev/null 2>&1 || (echo " You need to install $1 " && exit 2)
8
8
}
9
9
ensureAvailable dpkg-deb
10
10
ensureAvailable fpm
@@ -13,7 +13,7 @@ ensureAvailable lintian
13
13
ensureAvailable rpmbuild
14
14
15
15
PACKAGE_TMPDIR=tmp/debian_pkg
16
- VERSION=` node dist/bin/yarn --version`
16
+ VERSION=` dist/bin/yarn --version`
17
17
TARBALL_NAME=dist/yarn-v$VERSION .tar.gz
18
18
DEB_PACKAGE_NAME=yarn_$VERSION ' _all.deb'
19
19
OUTPUT_DIR=artifacts
@@ -50,11 +50,16 @@ find $PACKAGE_TMPDIR/usr/share/yarn \( -name '*.md' -o -name '*.md~' -o -name '
50
50
# Assume everything else is junk we don't need
51
51
rm -rf $PACKAGE_TMPDIR /dist
52
52
53
- # Currently the "binaries" are JavaScript files that expect to be in the same
54
- # directory as the libraries, so we can't just copy them directly to /usr/bin.
55
- # Symlink them instead.
53
+ # Swap out the basedir calculation code with a hard-coded path, as the default
54
+ # way we do this doesn't follow symlinks.
55
+ sed -i ' s/basedir\=\$.*/basedir=\/usr\/share\/yarn\/bin/' $PACKAGE_TMPDIR /usr/share/yarn/bin/yarn
56
+
57
+ # The Yarn executable expects to be in the same directory as the libraries, so
58
+ # we can't just copy it directly to /usr/bin. Symlink them instead.
56
59
mkdir -p $PACKAGE_TMPDIR /usr/bin/
57
- ln -s ../share/yarn/bin/yarn.js $PACKAGE_TMPDIR /usr/bin/yarn
60
+ ln -s ../share/yarn/bin/yarn $PACKAGE_TMPDIR /usr/bin/yarn
61
+ # Alias as "yarnpkg" too.
62
+ ln -s ../share/yarn/bin/yarn $PACKAGE_TMPDIR /usr/bin/yarnpkg
58
63
59
64
# Common FPM parameters for all packages we'll build using FPM
60
65
FPM=" fpm --input-type dir --chdir $PACKAGE_TMPDIR --name yarn --version $VERSION " `
@@ -70,9 +75,6 @@ mkdir -p $PACKAGE_TMPDIR/DEBIAN
70
75
mkdir -p $PACKAGE_TMPDIR /usr/share/lintian/overrides/
71
76
cp resources/debian/lintian-overrides $PACKAGE_TMPDIR /usr/share/lintian/overrides/yarn
72
77
73
- # Debian/Ubuntu call the Node.js binary "nodejs", not "node".
74
- sed -i ' s/env node/env nodejs/' $PACKAGE_TMPDIR /usr/share/yarn/bin/yarn.js
75
-
76
78
# Replace variables in Debian package control file
77
79
INSTALLED_SIZE=` du -sk $PACKAGE_TMPDIR | cut -f 1`
78
80
sed -e " s/\$ VERSION/$VERSION /;s/\$ INSTALLED_SIZE/$INSTALLED_SIZE /" < resources/debian/control.in > $PACKAGE_TMPDIR /DEBIAN/control
0 commit comments