forked from scionproto/scion
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
29 changed files
with
1,024 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
load(":package.bzl", "scion_pkg_deb") | ||
load(":platform.bzl", "multiplatform_filegroup") | ||
load(":git_version.bzl", "git_version") | ||
|
||
git_version( | ||
name = "git_version", | ||
tags = ["manual"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
scion_pkg_deb( | ||
name = "router_deb", | ||
depends = [ | ||
"adduser", | ||
], | ||
description = "SCION inter-domain network architecture border router", | ||
executables = { | ||
"//router/cmd/router:router": "scion-router", | ||
}, | ||
package = "scion-router", | ||
postinst = "debian/scion.postinst", | ||
systemds = ["systemd/[email protected]"], | ||
version_file = ":git_version", | ||
) | ||
|
||
scion_pkg_deb( | ||
name = "control_deb", | ||
configs = [], | ||
depends = [ | ||
"adduser", | ||
"scion-dispatcher", | ||
], | ||
description = "SCION inter-domain network architecture control service", | ||
executables = { | ||
"//control/cmd/control:control": "scion-control", | ||
}, | ||
package = "scion-control", | ||
systemds = ["systemd/[email protected]"], | ||
version_file = ":git_version", | ||
) | ||
|
||
scion_pkg_deb( | ||
name = "dispatcher_deb", | ||
configs = ["conffiles/dispatcher.toml"], | ||
depends = [ | ||
"adduser", | ||
], | ||
description = "SCION dispatcher", | ||
executables = { | ||
"//dispatcher/cmd/dispatcher:dispatcher": "scion-dispatcher", | ||
}, | ||
package = "scion-dispatcher", | ||
postinst = "debian/scion.postinst", | ||
systemds = ["systemd/scion-dispatcher.service"], | ||
version_file = ":git_version", | ||
) | ||
|
||
scion_pkg_deb( | ||
name = "daemon_deb", | ||
configs = ["conffiles/sciond.toml"], | ||
depends = [ | ||
"adduser", | ||
], | ||
description = "SCION daemon", | ||
executables = { | ||
"//daemon/cmd/daemon:daemon": "scion-daemon", | ||
}, | ||
package = "scion-daemon", | ||
postinst = "debian/scion.postinst", | ||
systemds = ["systemd/scion-daemon.service"], | ||
version_file = ":git_version", | ||
) | ||
|
||
scion_pkg_deb( | ||
name = "gateway_deb", | ||
configs = [ | ||
"conffiles/sig.json", | ||
"conffiles/sig.toml", | ||
], | ||
depends = [ | ||
"adduser", | ||
"scion-dispatcher", | ||
"scion-daemon", | ||
], | ||
description = "SCION-IP Gateway", | ||
executables = { | ||
"//gateway/cmd/gateway:gateway": "scion-ip-gateway", | ||
}, | ||
package = "scion-ip-gateway", | ||
systemds = ["systemd/scion-ip-gateway.service"], | ||
version_file = ":git_version", | ||
) | ||
|
||
scion_pkg_deb( | ||
name = "tools_deb", | ||
depends = [ | ||
"adduser", | ||
"scion-dispatcher", | ||
"scion-daemon", | ||
], | ||
description = "SCION tools", | ||
executables = { | ||
"//scion/cmd/scion:scion": "scion", | ||
"//scion-pki/cmd/scion-pki:scion-pki": "scion-pki", | ||
}, | ||
package = "scion-tools", | ||
version_file = ":git_version", | ||
) | ||
|
||
multiplatform_filegroup( | ||
name = "deb", | ||
srcs = [ | ||
"control_deb", | ||
"daemon_deb", | ||
"dispatcher_deb", | ||
"gateway_deb", | ||
"router_deb", | ||
"tools_deb", | ||
], | ||
visibility = ["//dist:__subpackages__"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[dispatcher] | ||
id = "dispatcher" | ||
socket_file_mode = "0777" | ||
|
||
[log.console] | ||
level = "info" | ||
|
||
# Optionally expose metrics and other local inspection endpoints. | ||
# [metrics] | ||
# prometheus = "[127.0.0.1]:30441" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[general] | ||
id = "sd" | ||
config_dir = "/etc/scion" | ||
reconnect_to_dispatcher = true | ||
|
||
[path_db] | ||
connection = "/var/lib/scion/sd.path.db" | ||
|
||
[trust_db] | ||
connection = "/var/lib/scion/sd.trust.db" | ||
|
||
# Optionally enable DRKey | ||
# [drkey_level2_db] | ||
# connection = "/var/lib/scion/sd.drkey_level2.db" | ||
|
||
[log.console] | ||
level = "info" | ||
|
||
# Optionally expose metrics and other local inspection endpoints. | ||
# [metrics] | ||
# prometheus = "127.0.0.1:30455" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"ASes": { | ||
"<remote_sig_AS>": { | ||
"Nets": [ | ||
"<remote_sig_IPnet>" | ||
] | ||
} | ||
}, | ||
"ConfigVersion": 9001 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[gateway] | ||
traffic_policy_file = "/etc/scion/sig.json" | ||
|
||
[tunnel] | ||
name = "sig" | ||
|
||
[log.console] | ||
level = "info" | ||
|
||
# Optionally expose metrics and other local inspection endpoints. | ||
# [metrics] | ||
# prometheus = "127.0.0.1:30456" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# summary of how this script can be called: | ||
# * <postinst> `configure' <most-recently-configured-version> | ||
# * <old-postinst> `abort-upgrade' <new version> | ||
# * <conflictor's-postinst> `abort-remove' `in-favour' <package> | ||
# <new-version> | ||
# * <postinst> `abort-remove' | ||
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour' | ||
# <failed-install-package> <version> `removing' | ||
# <conflicting-package> <version> | ||
# for details, see http://www.debian.org/doc/debian-policy/ or | ||
# the debian-policy package | ||
|
||
case "$1" in | ||
configure) | ||
# Create system user | ||
adduser --system --home /var/lib/scion --group scion | ||
# Create configuration directory | ||
mkdir /etc/scion/ >& /dev/null || true | ||
chown scion:scion /etc/scion/ | ||
;; | ||
*) | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def _git_version_impl(ctx): | ||
ctx.actions.run_shell( | ||
outputs = [ctx.outputs.outfile], | ||
inputs = [ctx.info_file], | ||
command = r"sed -n 's/STABLE_GIT_VERSION\s*v\?//p' " + ctx.info_file.path + " > " + ctx.outputs.outfile.path, | ||
) | ||
|
||
git_version = rule( | ||
doc = """ | ||
Extracts the STABLE_GIT_VERSION from the workspace_status_command output. | ||
See also .bazelrc and tools/bazel-build-env. | ||
The output of this rule is a file containing the version only. | ||
The leading "v" from the git tag is removed. | ||
""", | ||
implementation = _git_version_impl, | ||
outputs = { | ||
"outfile": "git-version", | ||
}, | ||
) |
Oops, something went wrong.