-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
package_binaries.sh
executable file
·103 lines (86 loc) · 3.72 KB
/
package_binaries.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#! /usr/bin/env bash
# Builds the keybase binary and packages it into two ".deb" files, one for i386
# and one for amd64. The argument to this script is the output directory of a
# build_binaries.sh build. The package files are created there, in their
# respective architecture folders.
#
# Usage:
# ./package_binaries.sh <build_root>
set -e -u -o pipefail
here="$(dirname "${BASH_SOURCE[0]}")"
build_root="${1:-}"
if [ -z "$build_root" ] ; then
echo 'Usage: ./package_binaries.sh <build_root>'
exit 1
fi
# S3 mishandles + characters in the version. See
# https://github.com/keybase/keybase-issues/issues/2116.
version="$(cat "$build_root/VERSION" | sed 's/+/./g')"
mode="$(cat "$build_root/MODE")"
name="$("$here/../../binary_name.sh" "$mode")"
dependencies=""
if [ "$mode" = "production" ] ; then
repo_url="http://dist.keybase.io/linux/deb/repo"
elif [ "$mode" = "prerelease" ] ; then
repo_url="http://prerelease.keybase.io/deb"
# debian bullseye removed libappindicator1 in favor of libayatana-appindicator1, so allow both.
# "psmisc" provides "killall", which is used in run_keybase and
# post_install.sh.
# lsof used in post_install.sh
# systemd-container provides machinectl, which is used in post_install.sh
# 'libasound2, libnss3, libxss1, libxtst6' is required by the GUI (issue #9872 and #17365)
dependencies="Depends: libappindicator1 | libayatana-appindicator1, fuse, libgconf-2-4, psmisc, lsof, procps, libasound2, libnss3, libxss1, libxtst6, libgtk-3-0"
elif [ "$mode" = "staging" ] ; then
# Note: This doesn't exist yet. But we need to be distinct from the
# production URL, because we're moving to a model where we build a clean repo
# every time, rather than adding to an existing one. (For S3 compatibility.)
repo_url="http://dist.keybase.io/linux/deb_staging/repo"
else
# We don't actually publish devel builds. This URL is a dream within a dream.
repo_url="http://dist.keybase.io/linux/deb_devel/repo"
fi
repo_ssl_url="$(echo "$repo_url" | sed 's|http|https|')"
build_one_architecture() {
echo "Making .deb package for $debian_arch."
dest="$build_root/deb/$debian_arch"
mkdir -p "$dest/build/DEBIAN"
# Copy the entire filesystem layout, binaries and all, into the debian build
# folder. TODO: Something less wasteful of disk space?
# Preserve permissions of the chrome-sandbox setuid
cp -rp "$build_root"/binaries/"$debian_arch"/* "$dest/build"
# Copy changelog directly in, since this is a binary package.
doc_dir="$dest/build/usr/share/doc/keybase"
mkdir -p "$doc_dir"
gzip -cn "$here/changelog" > "$doc_dir/changelog.Debian.gz"
# Installed-Size is a required field in the control file. Without it Ubuntu
# users will see warnings.
size="$(du --summarize --block-size=1024 "$dest" | awk '{print $1}')"
# Debian control file
cat "$here/control.template" \
| sed "s/@@NAME@@/$name/" \
| sed "s/@@VERSION@@/$version/" \
| sed "s/@@ARCHITECTURE@@/$debian_arch/" \
| sed "s/@@SIZE@@/$size/" \
| sed "s/@@DEPENDENCIES@@/$dependencies/" \
> "$dest/build/DEBIAN/control"
# Debian postinst script
postinst_file="$dest/build/DEBIAN/postinst"
cat "$here/postinst.template" \
| sed "s/@@NAME@@/$name/g" \
> "$postinst_file"
chmod 755 "$postinst_file"
# distro-upgrade-handling cron job (sigh...see comments within)
cron_file="$dest/build/etc/cron.daily/$name"
mkdir -p "$(dirname "$cron_file")"
cat "$here/cron.template" \
| sed "s/@@NAME@@/$name/g" \
| sed "s|@@REPO_URL@@|$repo_url|g" \
| sed "s|@@REPO_SSL_URL@@|$repo_ssl_url|g" \
> "$cron_file"
chmod 755 "$cron_file"
fakeroot dpkg-deb --build "$dest/build" "$dest/$name-$version-$debian_arch.deb"
}
export debian_arch=amd64
build_one_architecture
export debian_arch=i386
build_one_architecture