Skip to content

Commit 8aed283

Browse files
Build packages for Debian
1 parent dfe7bcb commit 8aed283

File tree

13 files changed

+210
-1
lines changed

13 files changed

+210
-1
lines changed

.github/workflows/build.yml

+18
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ jobs:
5959
env:
6060
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6161

62+
build-packages:
63+
needs: build-releases
64+
runs-on: ubuntu-latest
65+
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v2
69+
70+
- name: Build packages
71+
run: ./scripts/build_packages.sh
72+
73+
- name: Push packages to Packagecloud
74+
uses: faucetsdn/action-packagecloud-upload-debian-packages@v1
75+
with:
76+
path: ./packages
77+
repo: ${{ secrets.PACKAGECLOUD_REPO }}
78+
token: ${{ secrets.PACKAGECLOUD_TOKEN }}
79+
6280
build-docker:
6381
runs-on: ubuntu-latest
6482

PACKAGING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ We consider here the packaging flow of Vigil version `1.0.0` for Linux.
99
1. Bump version in `Cargo.toml` to `1.0.0`
1010
2. Execute `cargo update` to bump `Cargo.lock`
1111

12-
2. **How to build Vigil, package it and release it on Crates, GitHub and Docker Hub (multiple architectures):**
12+
2. **How to build Vigil, package it and release it on Crates, GitHub, Docker Hub and Packagecloud (multiple architectures):**
1313
1. Tag the latest Git commit corresponding to the release with tag `v1.0.0`, and push the tag
1414
2. Wait for all release jobs to complete on the [actions](https://github.com/valeriansaliou/vigil/actions) page on GitHub
1515
3. Download all release archives, and sign them locally using: `./scripts/sign_binaries.sh --version=1.0.0`

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,44 @@ Vigil is built in Rust. To install it, either download a version from the [Vigil
9494

9595
👉 _Each release binary comes with an `.asc` signature file, which can be verified using [@valeriansaliou](https://github.com/valeriansaliou) GPG public key: [:key:valeriansaliou.gpg.pub.asc](https://valeriansaliou.name/files/keys/valeriansaliou.gpg.pub.asc)._
9696

97+
**Install from packages:**
98+
99+
Vigil provides [pre-built packages](https://packagecloud.io/valeriansaliou/vigil) for Debian-based systems (Debian, Ubuntu, etc.).
100+
101+
**Important: Vigil only provides 64 bits packages targeting Debian 10, 11 & 12 for now (codenames: `buster`, `bullseye` & `bookworm`). You will still be able to use them on other Debian versions, as well as Ubuntu.**
102+
103+
First, add the Vigil APT repository (eg. for Debian `bookworm`):
104+
105+
```bash
106+
echo "deb https://packagecloud.io/valeriansaliou/vigil/debian/ bookworm main" > /etc/apt/sources.list.d/valeriansaliou_vigil.list
107+
```
108+
109+
```bash
110+
curl --silent -L https://packagecloud.io/valeriansaliou/vigil/gpgkey | apt-key add -
111+
```
112+
113+
```bash
114+
apt-get update
115+
```
116+
117+
Then, install the Vigil package:
118+
119+
```bash
120+
apt-get install vigil
121+
```
122+
123+
Then, edit the pre-filled Vigil configuration file:
124+
125+
```bash
126+
nano /etc/vigil.cfg
127+
```
128+
129+
Finally, restart Vigil:
130+
131+
```
132+
service vigil restart
133+
```
134+
97135
**Install from Cargo:**
98136

99137
If you prefer managing `vigil` via Rust's Cargo, install it directly via `cargo install`:

debian/changelog

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
vigil (0.0.0-1) UNRELEASED; urgency=medium
2+
3+
* Initial release.
4+
5+
-- Valerian Saliou <[email protected]> Tue, 31 Aug 2023 12:00:00 +0000

debian/compat

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10

debian/control

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Source: vigil
2+
Section: net
3+
Priority: ext
4+
Maintainer: Valerian Saliou <[email protected]>
5+
Standards-Version: 3.9.4
6+
Build-Depends: wget, ca-certificates
7+
Homepage: https://github.com/valeriansaliou/vigil
8+
9+
Package: vigil
10+
Architecture: any
11+
Depends: adduser
12+
Provides: vigil
13+
Description: Microservices Status Page. Monitors a distributed infrastructure and sends alerts.

debian/copyright

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: vigil
3+
Upstream-Contact: Valerian Saliou <[email protected]>
4+
Source: https://github.com/valeriansaliou/vigil
5+
6+
Files: *
7+
Copyright: 2023 Valerian Saliou
8+
License: MPL-2
9+
10+
License: MPL-2
11+
This Source Code Form is subject to the terms of the Mozilla Public License,
12+
v. 2.0. If a copy of the MPL was not distributed with this file,
13+
You can obtain one at http://mozilla.org/MPL/2.0/.

debian/rules

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/make -f
2+
3+
DISTRIBUTION = $(shell lsb_release -sr)
4+
VERSION = 1.26.0
5+
PACKAGEVERSION = $(VERSION)-0~$(DISTRIBUTION)0
6+
URL = https://github.com/valeriansaliou/vigil/releases/download/v$(VERSION)/
7+
8+
%:
9+
dh $@ --with systemd
10+
11+
override_dh_auto_clean:
12+
override_dh_auto_test:
13+
override_dh_auto_build:
14+
override_dh_auto_install:
15+
$(eval ENV_ARCH := $(shell dpkg --print-architecture))
16+
$(eval ENV_ISA := $(shell if [ "$(ENV_ARCH)" = "amd64" ]; then echo "x86_64"; else echo "$(ENV_ARCH)"; fi))
17+
$(eval ENV_TARBALL := v$(VERSION)-$(ENV_ISA).tar.gz)
18+
19+
echo "Architecture: $(ENV_ARCH)"
20+
echo "Instruction Set: $(ENV_ISA)"
21+
echo "Target: $(URL)$(ENV_TARBALL)"
22+
23+
wget -N --progress=dot:mega $(URL)$(ENV_TARBALL)
24+
tar -xf $(ENV_TARBALL)
25+
strip vigil/vigil
26+
mv vigil/config.cfg vigil/vigil.cfg
27+
sed -i 's/path = ".\/res\/assets\/"/path = "\/etc\/vigil\/assets\/"/g' vigil/vigil.cfg
28+
29+
override_dh_gencontrol:
30+
dh_gencontrol -- -v$(PACKAGEVERSION)

debian/source/format

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0 (quilt)

debian/vigil.install

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
vigil/vigil usr/bin/
2+
vigil/vigil.cfg etc/
3+
res/assets/ etc/

debian/vigil.postinst

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
case "$1" in
6+
configure)
7+
adduser --system --disabled-password --disabled-login --home /var/empty \
8+
--no-create-home --quiet --group vigil
9+
;;
10+
esac
11+
12+
#DEBHELPER#
13+
14+
exit 0

debian/vigil.service

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Unit]
2+
Description=Microservices Status Page
3+
After=network.target
4+
5+
[Service]
6+
Type=simple
7+
User=vigil
8+
Group=vigil
9+
ExecStartPre=/sbin/setcap 'cap_net_raw+ep' /bin/vigil
10+
ExecStart=/usr/bin/vigil -c /etc/vigil.cfg
11+
Restart=on-failure
12+
PermissionsStartOnly=true
13+
14+
[Install]
15+
WantedBy=multi-user.target

scripts/build_packages.sh

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
##
4+
# Vigil
5+
#
6+
# Microservices Status Page
7+
# Copyright: 2023, Valerian Saliou <[email protected]>
8+
# License: Mozilla Public License v2.0 (MPL v2.0)
9+
##
10+
11+
# Define build pipeline
12+
function build_for_target {
13+
OS="$2" DIST="$3" ARCH="$1" ./packpack/packpack
14+
release_result=$?
15+
16+
if [ $release_result -eq 0 ]; then
17+
mkdir -p "./packages/$2_$3/"
18+
mv ./build/*$4 "./packages/$2_$3/"
19+
20+
echo "Result: Packaged architecture: $1 for OS: $2:$3 (*$4)"
21+
fi
22+
23+
return $release_result
24+
}
25+
26+
# Run release tasks
27+
ABSPATH=$(cd "$(dirname "$0")"; pwd)
28+
BASE_DIR="$ABSPATH/../"
29+
30+
rc=0
31+
32+
pushd "$BASE_DIR" > /dev/null
33+
echo "Executing packages build steps for Vigil..."
34+
35+
# Initialize `packpack`
36+
rm -rf ./packpack && \
37+
git clone https://github.com/packpack/packpack.git packpack
38+
rc=$?
39+
40+
# Proceed build for each target?
41+
if [ $rc -eq 0 ]; then
42+
build_for_target "x86_64" "debian" "buster" ".deb" && \
43+
build_for_target "x86_64" "debian" "bullseye" ".deb" && \
44+
build_for_target "x86_64" "debian" "bookworm" ".deb"
45+
rc=$?
46+
fi
47+
48+
# Cleanup environment
49+
rm -rf ./build ./packpack
50+
51+
if [ $rc -eq 0 ]; then
52+
echo "Success: Done executing packages build steps for Vigil"
53+
else
54+
echo "Error: Failed executing packages build steps for Vigil"
55+
fi
56+
popd > /dev/null
57+
58+
exit $rc

0 commit comments

Comments
 (0)