-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Build Debian package #379
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
Build Debian package #379
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Handles packaging Yarn into Debian and RPM packages | ||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- "scripts/actions/build-deb/" | ||
- ".github/workflows/package-workflow.yml" | ||
pull_request: | ||
paths: | ||
- "scripts/actions/build-deb/" | ||
- ".github/workflows/package-workflow.yml" | ||
|
||
name: "Release Packages" | ||
jobs: | ||
linux-packages: | ||
name: "Linux Packages" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/setup-node@master | ||
with: | ||
version: 12.x | ||
|
||
- name: 'Install Yarn 1.17.3' | ||
run: | | ||
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - | ||
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list | ||
sudo apt-get update && sudo apt-get install yarn=1.17.3-1 --no-install-recommends | ||
|
||
- name: 'Build' | ||
run: | | ||
set -ex | ||
node ./scripts/run-yarn.js build:cli | ||
./scripts/build-dist.sh | ||
|
||
- name: 'Build packages' | ||
uses: ./scripts/actions/build-deb | ||
|
||
- name: 'Upload packages' | ||
uses: actions/upload-artifact@master | ||
with: | ||
name: packages | ||
path: artifacts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM node:10 | ||
|
||
LABEL "com.github.actions.name"="build-deb" | ||
LABEL "com.github.actions.description"="Builds the Yarn Debian and RPM packages" | ||
LABEL "com.github.actions.icon"="package" | ||
LABEL "com.github.actions.color"="blue" | ||
|
||
# Debian packages | ||
RUN apt-get -y update && \ | ||
apt-get install -y --no-install-recommends \ | ||
fakeroot \ | ||
lintian \ | ||
rpm \ | ||
ruby \ | ||
ruby-dev \ | ||
&& \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Ruby packages | ||
RUN gem install fpm | ||
|
||
ADD build-deb.sh /build-deb.sh | ||
ENTRYPOINT ["/build-deb.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of this is the same as https://github.com/yarnpkg/yarn/blob/master/scripts/build-deb.sh |
||
|
||
set -ex | ||
|
||
# Ensure all the tools we need are available | ||
ensureAvailable() { | ||
command -v "$1" >/dev/null 2>&1 || (echo "You need to install $1" && exit 2) | ||
} | ||
ensureAvailable dpkg-deb | ||
ensureAvailable fpm | ||
ensureAvailable fakeroot | ||
ensureAvailable lintian | ||
ensureAvailable rpmbuild | ||
|
||
CONTENTS_DIR=./scripts/actions/build-deb/contents | ||
PACKAGE_TMPDIR=tmp/debian_pkg | ||
VERSION=`./dist/bin/yarn --version` | ||
OUTPUT_DIR=artifacts | ||
DEB_PACKAGE_NAME=yarn-next_$VERSION'_all.deb' | ||
|
||
mkdir -p $OUTPUT_DIR | ||
# Remove old packages | ||
rm -f $OUTPUT_DIR/*.deb $OUTPUT_DIR/*.rpm | ||
|
||
# Create temporary directory to start building up the package | ||
rm -rf $PACKAGE_TMPDIR | ||
mkdir -p $PACKAGE_TMPDIR/ | ||
umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files) | ||
PACKAGE_TMPDIR_ABSOLUTE=$(readlink -f $PACKAGE_TMPDIR) | ||
|
||
# Create Linux package structure | ||
mkdir -p $PACKAGE_TMPDIR/usr/share/yarn-next/ | ||
mkdir -p $PACKAGE_TMPDIR/usr/share/doc/yarn-next/ | ||
cp -r dist/* $PACKAGE_TMPDIR/usr/share/yarn-next/ | ||
cp $CONTENTS_DIR/copyright $PACKAGE_TMPDIR/usr/share/doc/yarn-next/copyright | ||
chmod 0755 $PACKAGE_TMPDIR/usr/share/yarn-next/ | ||
|
||
# The Yarn executable expects to be in the same directory as the libraries, so | ||
# we can't just copy it directly to /usr/bin. Symlink them instead. | ||
mkdir -p $PACKAGE_TMPDIR/usr/bin/ | ||
ln -s ../share/yarn-next/bin/yarn $PACKAGE_TMPDIR/usr/bin/yarn-next | ||
# Alias as "yarnpkg" too. | ||
ln -s ../share/yarn-next/bin/yarn $PACKAGE_TMPDIR/usr/bin/yarnpkg-next | ||
|
||
# Common FPM parameters for all packages we'll build using FPM | ||
FPM="fpm --input-type dir --chdir $PACKAGE_TMPDIR --name yarn-next --version $VERSION "` | ||
`"--vendor 'Yarn Contributors <[email protected]>' --maintainer 'Yarn Contributors <[email protected]>' "` | ||
`"--url https://yarnpkg.com/ --license BSD --description '$(cat $CONTENTS_DIR/description)'" | ||
|
||
##### Build RPM (CentOS, Fedora) package | ||
#./scripts/update-dist-manifest.js $PACKAGE_TMPDIR_ABSOLUTE/usr/share/yarn/package.json rpm | ||
eval "$FPM --output-type rpm --architecture noarch --category 'Development/Languages' ." | ||
mv *.rpm $OUTPUT_DIR | ||
|
||
##### Build DEB (Debian, Ubuntu) package | ||
#./scripts/update-dist-manifest.js $PACKAGE_TMPDIR_ABSOLUTE/usr/share/yarn/package.json deb | ||
mkdir -p $PACKAGE_TMPDIR/DEBIAN | ||
mkdir -p $PACKAGE_TMPDIR/usr/share/lintian/overrides/ | ||
cp $CONTENTS_DIR/lintian-overrides $PACKAGE_TMPDIR/usr/share/lintian/overrides/yarn-next | ||
|
||
# Replace variables in Debian package control file | ||
INSTALLED_SIZE=`du -sk $PACKAGE_TMPDIR | cut -f 1` | ||
sed -e "s/\$VERSION/$VERSION/;s/\$INSTALLED_SIZE/$INSTALLED_SIZE/" < $CONTENTS_DIR/control.in > $PACKAGE_TMPDIR/DEBIAN/control | ||
fakeroot dpkg-deb -b $PACKAGE_TMPDIR $DEB_PACKAGE_NAME | ||
mv $DEB_PACKAGE_NAME $OUTPUT_DIR | ||
|
||
rm -rf $PACKAGE_TMPDIR | ||
|
||
# Lint the Debian package to ensure we're not doing something silly | ||
lintian $OUTPUT_DIR/$DEB_PACKAGE_NAME |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Package: yarn-next | ||
Version: $VERSION-1 | ||
Recommends: nodejs | ||
Conflicts: nodejs (<< 4.0.0), cmdtest | ||
Section: devel | ||
Priority: optional | ||
Architecture: all | ||
Installed-Size: $INSTALLED_SIZE | ||
Maintainer: Yarn Developers <[email protected]> | ||
Homepage: https://yarnpkg.com/ | ||
Description: Fast, reliable, and secure dependency management. | ||
Yarn: Fast, reliable, and secure dependency management. | ||
. | ||
Fast: Yarn caches every package it downloads so it never needs to again. It | ||
also parallelizes operations to maximize resource utilization so install times | ||
are faster than ever. | ||
. | ||
Reliable: Using a detailed, but concise, lockfile format, and a deterministic | ||
algorithm for installs, Yarn is able to guarantee that an install that worked | ||
on one system will work exactly the same way on any other system. | ||
. | ||
Secure: Yarn uses checksums to verify the integrity of every installed package | ||
before its code is executed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
Upstream-Name: Yarn | ||
Upstream-Contact: Yarn Developers <[email protected]> | ||
Source: http://yarnpkg.com/ | ||
|
||
Files: * | ||
Copyright: 2016-present, Yarn Contributors | ||
License: BSD-2-clause |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Fast, reliable, and secure dependency management. | ||
Yarn: Fast, reliable, and secure dependency management. | ||
|
||
Fast: Yarn caches every package it downloads so it never needs to again. It also | ||
parallelizes operations to maximize resource utilization so install times are | ||
faster than ever. | ||
|
||
Reliable: Using a detailed, but concise, lockfile format, and a deterministic | ||
algorithm for installs, Yarn is able to guarantee that an install that worked | ||
on one system will work exactly the same way on any other system. | ||
|
||
Secure: Yarn uses checksums to verify the integrity of every installed package | ||
before its code is executed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# No changelog file at the moment | ||
yarn-next: debian-changelog-file-missing | ||
# No manpage... yet! | ||
yarn-next: binary-without-manpage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copied directly from yarn v1. Need to double check if all of these are still needed - A lot of them were due to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Were those tags meant to describe the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @arcanis - |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
set -Exu | ||
set -o pipefail | ||
# Builds the release tarball for Yarn. | ||
|
||
umask 0022 # Ensure permissions are correct (0755 for dirs, 0644 for files) | ||
|
||
version=$(yarn --version) | ||
|
||
rm -rf dist | ||
mkdir -p artifacts | ||
mkdir -p dist/bin | ||
|
||
cp README.md dist/ | ||
cp LICENSE.md dist/ | ||
cp packages/berry-cli/bundles/berry.js dist/bin/yarn.js | ||
cp scripts/dist-scripts/yarn dist/bin/yarn | ||
cp scripts/dist-scripts/yarn.cmd dist/bin/yarn.cmd | ||
cp scripts/dist-scripts/yarn.ps1 dist/bin/yarn.ps1 | ||
# Create yarnpkg as symlink to yarn | ||
ln -s yarn dist/bin/yarnpkg | ||
# Ensure all scripts are executable | ||
chmod +x dist/bin/* | ||
|
||
case "$(tar --version)" in | ||
*GNU*) | ||
tar -cvzf artifacts/yarn-next-v$version.tar.gz --transform="s/^dist/yarn-next-v$version/" dist/* | ||
;; | ||
bsdtar*) | ||
tar -cvzf artifacts/yarn-next-v$version.tar.gz -s "/^dist/yarn-next-v$version/" dist/* | ||
;; | ||
*) | ||
echo "Can't determine tar type (BSD/GNU)!" | ||
exit 1 | ||
;; | ||
esac |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/sh | ||
argv0=$(echo "$0" | sed -e 's,\\,/,g') | ||
basedir=$(dirname "$(readlink "$0" || echo "$argv0")") | ||
|
||
case "$(uname -s)" in | ||
Darwin) basedir="$( cd "$( dirname "$argv0" )" && pwd )";; | ||
Linux) basedir=$(dirname "$(readlink -f "$0" || echo "$argv0")");; | ||
*CYGWIN*) basedir=`cygpath -w "$basedir"`;; | ||
*MSYS*) basedir=`cygpath -w "$basedir"`;; | ||
esac | ||
|
||
command_exists() { | ||
command -v "$1" >/dev/null 2>&1; | ||
} | ||
|
||
if command_exists node; then | ||
if [ "$YARN_FORCE_WINPTY" = 1 ] || command_exists winpty && test -t 1; then | ||
winpty node "$basedir/yarn.js" "$@" | ||
else | ||
exec node "$basedir/yarn.js" "$@" | ||
fi | ||
ret=$? | ||
# Debian and Ubuntu use "nodejs" as the name of the binary, not "node", so we | ||
# search for that too. See: | ||
# https://lists.debian.org/debian-devel-announce/2012/07/msg00002.html | ||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=614907 | ||
elif command_exists nodejs; then | ||
exec nodejs "$basedir/yarn.js" "$@" | ||
ret=$? | ||
else | ||
>&2 echo 'Yarn requires Node.js 4.0 or higher to be installed.' | ||
ret=1 | ||
fi | ||
|
||
exit $ret |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@echo off | ||
node "%~dp0\yarn.js" %* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function Get-ScriptDirectory { | ||
$Invocation = (Get-Variable MyInvocation -Scope 1).Value | ||
Split-Path $Invocation.MyCommand.Path | ||
} | ||
|
||
node "$(Get-ScriptDirectory)/yarn.js" $args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly the same as https://github.com/yarnpkg/yarn/blob/master/Dockerfile.dev