Skip to content

Commit 30ed911

Browse files
matzfjuagargi
authored andcommitted
dist: build debian packages for multiple platforms (scionproto#4448)
Build debian packages for amd64, arm64, i386 and armel. - There are separate packages for router, control, daemon, dispatcher, gateway and tools (scion and scion-pki). - The packages include systemd unit files to run the services. For the daemon, dispatcher and gateway one instance per host is supported by the systemd service, and a default configuration file is included. For router and control, multiple instances per host are supported, and as a consequence of this, no default configuration file is provided. - Currently, there is no man page contained in the packages. We should be able to build these from our existing manuals, but it seems to require a significant amount of fiddling to get something useful. Building the .deb packages uses bazel with `rules_pkg`. The target `//dist:deb_all` cross-builds packages for the default set of target platforms. Alternatively, the target `//dist:deb` allows to build (all) packages for the current target platform. This current platform can be set with the `--platforms` bazel option (see https://github.com/bazelbuild/rules_go#how-do-i-cross-compile for more details). - To increase reuse of build results while cross-building, some internal targets related to openapi forcibly ignore the target platform - The package version is based on the current git tag. `rules_pkg` can include this version _in_ the package metadata, but bazel _cannot_ spit out appropriately named package files. This is addressed by copying and renaming the package files after build in a make target `make dist-deb`. Add installation documentation for the packages and the systemd units. As a side effect, slightly reorganize the build documentation also, trying to make give a simpler path to just build the binaries without installing the entire development setup.
1 parent 8ed74fa commit 30ed911

29 files changed

+1024
-74
lines changed

.buildkite/hooks/pre-command

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ rm -f $HOME/.bazelrc
3030
# --nostamp is required for better caching (only on non-release jobs).
3131
if [ "$BUILDKITE_PIPELINE_SLUG" == "scion" ]; then
3232
echo "build --nostamp" > $HOME/.bazelrc
33-
# Also set a fixed GIT_VERSION so that the workspace_status_command always
34-
# returns the same value on CI to improve cache reuse.
35-
export GIT_VERSION="ci-fixed"
33+
# Shorten the git version to omit commit information, improving cache reuse.
34+
# The format of git-version is "<tag>-<number-of-commits-since-the-tag>-<commit-short-hash>"
35+
# This will be shortened to "<tag>-modified-ci"
36+
export GIT_VERSION=$(tools/git-version | sed 's/-.*/-modified-ci/')
3637
else
3738
echo "build --stamp" > $HOME/.bazelrc
3839
fi

.buildkite/pipeline.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ steps:
1212
plugins:
1313
- scionproto/metahook#v0.3.0:
1414
post-artifact: |
15-
cat << EOF | buildkite-agent annotate --style "info"
15+
cat << EOF | buildkite-agent annotate --style "info" --context "binaries"
1616
#### Build outputs
1717
- <a href="artifact://bazel-bin/scion.tar">SCION binaries</a>
1818
- <a href="artifact://bazel-bin/scion-ci.tar">SCION test tools and utilities</a>
@@ -23,6 +23,28 @@ steps:
2323
- exit_status: 255 # Forced agent shutdown
2424
timeout_in_minutes: 10
2525
- wait
26+
- label: "Package :debian:"
27+
command:
28+
- make dist-deb
29+
- cd deb;
30+
- tar -chaf scion-deb-amd64.tar.gz *_amd64.deb
31+
- tar -chaf scion-deb-arm64.tar.gz *_arm64.deb
32+
- tar -chaf scion-deb-i386.tar.gz *_i386.deb
33+
- tar -chaf scion-deb-armel.tar.gz *_armel.deb
34+
artifact_paths:
35+
- "deb/*.tar.gz"
36+
plugins:
37+
- scionproto/metahook#v0.3.0:
38+
post-artifact: |
39+
cat << EOF | buildkite-agent annotate --style "info" --context "packages"
40+
#### Packages :debian:
41+
- <a href="artifact://deb/scion-deb-amd64.tar.gz">amd64</a>
42+
- <a href="artifact://deb/scion-deb-arm64.tar.gz">arm64</a>
43+
- <a href="artifact://deb/scion-deb-i386.tar.gz">i386</a>
44+
- <a href="artifact://deb/scion-deb-armel.tar.gz">armel</a>
45+
EOF
46+
key: dist-deb
47+
retry: *automatic-retry
2648
- label: "Unit Tests :bazel:"
2749
command:
2850
- bazel test --config=race --config=unit_all
@@ -70,6 +92,7 @@ steps:
7092
timeout_in_minutes: 20
7193
key: check_generated
7294
retry: *automatic-retry
95+
- wait
7396
- group: "End to End"
7497
key: e2e
7598
steps:

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ doc/venv/
6666
/bin/*
6767
!/bin/.keepme
6868

69+
# Generated package files
70+
##########################
71+
/deb/
72+
6973
# CTags
7074
##########################
7175
tags

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all build build-dev antlr clean docker-images gazelle go.mod licenses mocks protobuf scion-topo test test-integration write_all_source_files
1+
.PHONY: all build build-dev dist-deb antlr clean docker-images gazelle go.mod licenses mocks protobuf scion-topo test test-integration write_all_source_files
22

33
build-dev:
44
rm -f bin/*
@@ -11,6 +11,21 @@ build:
1111
bazel build //:scion
1212
tar -kxf bazel-bin/scion.tar -C bin
1313

14+
dist-deb:
15+
bazel build //dist:deb_all
16+
mkdir -p deb; rm -f deb/*;
17+
@ # Bazel cannot include the version in the filename, if we want to set it automatically from the git tag.
18+
@ # Extract the version from the .deb "control" manifest and expand the "__" in the filename to "_<version>_".
19+
@ # See e.g. https://en.wikipedia.org/wiki/Deb_(file_format)#Control_archive
20+
@for f in `bazel cquery //dist:deb_all --output=files 2>/dev/null`; do \
21+
if [ -f "$$f" ]; then \
22+
bf=`basename $$f`; \
23+
v="$$(ar p $$f control.tar.gz | tar -xz --to-stdout ./control | sed -n 's/Version: //p')"; \
24+
bfv=$${bf%%__*}_$${v}_$${bf#*__}; \
25+
cp -v "$$f" deb/$$bfv; \
26+
fi \
27+
done
28+
1429
# all: performs the code-generation steps and then builds; the generated code
1530
# is git controlled, and therefore this is only necessary when changing the
1631
# sources for the code generation.

README.md

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,53 @@
11
# SCION
22

33
[![Slack chat](https://img.shields.io/badge/chat%20on-slack-blue?logo=slack)](https://scionproto.slack.com)
4+
[![Matrix chat](https://img.shields.io/badge/chat%20on-matrix-blue?logo=matrix)](https://matrix.to/#/#dev:matrix.scion.org)
5+
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/scionproto/awesome-scion)
46
[![ReadTheDocs](https://img.shields.io/badge/doc-reference-blue?version=latest&style=flat&label=docs&logo=read-the-docs&logoColor=white)](https://docs.scion.org/en/latest)
5-
[![Documentation](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/github.com/scionproto/scion)
7+
[![Go Docs](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/github.com/scionproto/scion)
68
[![Nightly Build](https://badge.buildkite.com/b70b65b38a75eb8724f41a6f1203c9327cfb767f07a0c1934e.svg)](https://buildkite.com/scionproto/scion-nightly/builds/latest)
79
[![Go Report Card](https://goreportcard.com/badge/github.com/scionproto/scion)](https://goreportcard.com/report/github.com/scionproto/scion)
810
[![GitHub issues](https://img.shields.io/github/issues/scionproto/scion/help%20wanted.svg?label=help%20wanted&color=purple)](https://github.com/scionproto/scion/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
911
[![GitHub issues](https://img.shields.io/github/issues/scionproto/scion/good%20first%20issue.svg?label=good%20first%20issue&color=purple)](https://github.com/scionproto/scion/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
1012
[![Release](https://img.shields.io/github/release-pre/scionproto/scion.svg)](https://github.com/scionproto/scion/releases)
1113
[![License](https://img.shields.io/github/license/scionproto/scion.svg?maxAge=2592000)](https://github.com/scionproto/scion/blob/master/LICENSE)
1214

13-
Welcome to the open-source implementation of
14-
[SCION](http://www.scion-architecture.net) (Scalability, Control and Isolation
15-
On next-generation Networks), a future Internet architecture. SCION is the first
16-
clean-slate Internet architecture designed to provide route control, failure
17-
isolation, and explicit trust information for end-to-end communication. To find
18-
out more about the project, please visit our [documentation
19-
site](https://docs.scion.org/en/latest/).
15+
Welcome to the open-source implementation of [SCION](http://www.scion-architecture.net)
16+
(Scalability, Control and Isolation On next-generation Networks), a future Internet architecture.
17+
SCION provides route control, failure isolation, and explicit trust information for end-to-end communication.
18+
To find out more about the project, please visit our [documentation site](https://docs.scion.org/en/latest/).
2019

21-
## Connecting to the SCION Test Network
20+
## Installation
2221

23-
Join [SCIONLab](https://www.scionlab.org) if you're interested in playing with
24-
SCION in an operational global test deployment of SCION. As part of the SCIONLab
25-
project, we support [pre-built binaries as Debian
26-
packages](https://docs.scionlab.org/content/install/).
22+
Installation packages for Debian and derivatives are available for x86-64, arm64, x86-32 and arm.
23+
These packages can be found in the [latest release](https://github.com/scionproto/scion/releases/latest).
24+
Packages for in-development versions can be found from the [latest nightly build](https://buildkite.com/scionproto/scion-nightly/builds/latest).
2725

28-
## Building
26+
Alternatively, "naked" pre-built binaries are available for Linux x86-64 and
27+
can be downloaded from the [latest release](https://github.com/scionproto/scion/releases/latest) or the
28+
[latest nightly build](https://buildkite.com/scionproto/scion-nightly/builds/latest).
2929

30-
To find out how to work with SCION, please visit our [documentation
31-
site](https://docs.scion.org/en/latest/dev/setup.html)
32-
for instructions on how to install build dependencies, build and run SCION.
30+
### Build from sources
3331

34-
Pre-built binaries for x86-64 Linux are available from the [latest nightly build](https://buildkite.com/scionproto/scion-nightly/builds/latest).
32+
SCION can be built with `go build`. To build all binaries used in a SCION deployment (i.e.
33+
excluding the testing and development tools), run
34+
35+
```sh
36+
CGO_ENABLED=0 go build -o bin ./router/... ./control/... ./dispatcher/... ./daemon/... ./scion/... ./scion-pki/... ./gateway/...
37+
```
38+
39+
The default way to build SCION, however, uses Bazel.
40+
In particular, this allows to run all the tests, linters etc.
41+
Please visit our [documentation site](https://docs.scion.org/en/latest/dev/setup.html) for
42+
instructions on how to set up Bazel and the full development environment.
43+
44+
### Connecting to the SCION Network
45+
46+
Join [SCIONLab](https://www.scionlab.org) if you're interested in playing with SCION in an
47+
operational global test deployment of SCION.
48+
49+
The [awesome-scion](https://github.com/scionproto/awesome-scion#deployments) list contains
50+
pointers to production deployments of SCION.
3551

3652
## Contributing
3753

dist/BUILD.bazel

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
load(":package.bzl", "scion_pkg_deb")
2+
load(":platform.bzl", "multiplatform_filegroup")
3+
load(":git_version.bzl", "git_version")
4+
5+
git_version(
6+
name = "git_version",
7+
tags = ["manual"],
8+
visibility = ["//visibility:private"],
9+
)
10+
11+
scion_pkg_deb(
12+
name = "router_deb",
13+
depends = [
14+
"adduser",
15+
],
16+
description = "SCION inter-domain network architecture border router",
17+
executables = {
18+
"//router/cmd/router:router": "scion-router",
19+
},
20+
package = "scion-router",
21+
postinst = "debian/scion.postinst",
22+
systemds = ["systemd/[email protected]"],
23+
version_file = ":git_version",
24+
)
25+
26+
scion_pkg_deb(
27+
name = "control_deb",
28+
configs = [],
29+
depends = [
30+
"adduser",
31+
"scion-dispatcher",
32+
],
33+
description = "SCION inter-domain network architecture control service",
34+
executables = {
35+
"//control/cmd/control:control": "scion-control",
36+
},
37+
package = "scion-control",
38+
systemds = ["systemd/[email protected]"],
39+
version_file = ":git_version",
40+
)
41+
42+
scion_pkg_deb(
43+
name = "dispatcher_deb",
44+
configs = ["conffiles/dispatcher.toml"],
45+
depends = [
46+
"adduser",
47+
],
48+
description = "SCION dispatcher",
49+
executables = {
50+
"//dispatcher/cmd/dispatcher:dispatcher": "scion-dispatcher",
51+
},
52+
package = "scion-dispatcher",
53+
postinst = "debian/scion.postinst",
54+
systemds = ["systemd/scion-dispatcher.service"],
55+
version_file = ":git_version",
56+
)
57+
58+
scion_pkg_deb(
59+
name = "daemon_deb",
60+
configs = ["conffiles/sciond.toml"],
61+
depends = [
62+
"adduser",
63+
],
64+
description = "SCION daemon",
65+
executables = {
66+
"//daemon/cmd/daemon:daemon": "scion-daemon",
67+
},
68+
package = "scion-daemon",
69+
postinst = "debian/scion.postinst",
70+
systemds = ["systemd/scion-daemon.service"],
71+
version_file = ":git_version",
72+
)
73+
74+
scion_pkg_deb(
75+
name = "gateway_deb",
76+
configs = [
77+
"conffiles/sig.json",
78+
"conffiles/sig.toml",
79+
],
80+
depends = [
81+
"adduser",
82+
"scion-dispatcher",
83+
"scion-daemon",
84+
],
85+
description = "SCION-IP Gateway",
86+
executables = {
87+
"//gateway/cmd/gateway:gateway": "scion-ip-gateway",
88+
},
89+
package = "scion-ip-gateway",
90+
systemds = ["systemd/scion-ip-gateway.service"],
91+
version_file = ":git_version",
92+
)
93+
94+
scion_pkg_deb(
95+
name = "tools_deb",
96+
depends = [
97+
"adduser",
98+
"scion-dispatcher",
99+
"scion-daemon",
100+
],
101+
description = "SCION tools",
102+
executables = {
103+
"//scion/cmd/scion:scion": "scion",
104+
"//scion-pki/cmd/scion-pki:scion-pki": "scion-pki",
105+
},
106+
package = "scion-tools",
107+
version_file = ":git_version",
108+
)
109+
110+
multiplatform_filegroup(
111+
name = "deb",
112+
srcs = [
113+
"control_deb",
114+
"daemon_deb",
115+
"dispatcher_deb",
116+
"gateway_deb",
117+
"router_deb",
118+
"tools_deb",
119+
],
120+
visibility = ["//dist:__subpackages__"],
121+
)

dist/conffiles/dispatcher.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[dispatcher]
2+
id = "dispatcher"
3+
socket_file_mode = "0777"
4+
5+
[log.console]
6+
level = "info"
7+
8+
# Optionally expose metrics and other local inspection endpoints.
9+
# [metrics]
10+
# prometheus = "[127.0.0.1]:30441"

dist/conffiles/sciond.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[general]
2+
id = "sd"
3+
config_dir = "/etc/scion"
4+
reconnect_to_dispatcher = true
5+
6+
[path_db]
7+
connection = "/var/lib/scion/sd.path.db"
8+
9+
[trust_db]
10+
connection = "/var/lib/scion/sd.trust.db"
11+
12+
# Optionally enable DRKey
13+
# [drkey_level2_db]
14+
# connection = "/var/lib/scion/sd.drkey_level2.db"
15+
16+
[log.console]
17+
level = "info"
18+
19+
# Optionally expose metrics and other local inspection endpoints.
20+
# [metrics]
21+
# prometheus = "127.0.0.1:30455"

dist/conffiles/sig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"ASes": {
3+
"<remote_sig_AS>": {
4+
"Nets": [
5+
"<remote_sig_IPnet>"
6+
]
7+
}
8+
},
9+
"ConfigVersion": 9001
10+
}
11+

dist/conffiles/sig.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[gateway]
2+
traffic_policy_file = "/etc/scion/sig.json"
3+
4+
[tunnel]
5+
name = "sig"
6+
7+
[log.console]
8+
level = "info"
9+
10+
# Optionally expose metrics and other local inspection endpoints.
11+
# [metrics]
12+
# prometheus = "127.0.0.1:30456"

0 commit comments

Comments
 (0)