Skip to content

Commit 07eec6d

Browse files
committed
Build and packaging of m17-bridge
1 parent 714eafd commit 07eec6d

12 files changed

Lines changed: 241 additions & 14 deletions

File tree

.github/workflows/m17-gateway.yml

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Run tests
4747
run: go test .
4848

49-
- name: Build for Raspberry Pi (ARM64)
49+
- name: Build m17-gateway for Raspberry Pi (ARM64)
5050
run: |
5151
cd cmd/m17-gateway
5252
echo "Building M17 Gateway for ARM64 architecture (64-bit Raspberry Pi OS)..."
@@ -55,32 +55,64 @@ jobs:
5555
ls -la m17-gateway
5656
file m17-gateway
5757
58-
- name: Make build script executable
58+
- name: Make m17-gateway build script executable
5959
run: |
6060
cd cmd/m17-gateway
6161
chmod +x ./packaging/scripts/build-deb.sh
6262
63-
- name: Build .deb package
63+
- name: Build m17-gateway .deb package
6464
run: |
6565
cd cmd/m17-gateway
6666
./packaging/scripts/build-deb.sh ${{ steps.version.outputs.VERSION }}
6767
68-
- name: List build artifacts
68+
- name: List m17-gateway build artifacts
6969
run: |
7070
cd cmd/m17-gateway
7171
ls -la build/
7272
73-
- name: Upload .deb package
73+
- name: Upload m17-gateway .deb package
7474
uses: actions/upload-artifact@v4
7575
with:
7676
name: m17-gateway-debian-package
7777
path: cmd/m17-gateway/build/*.deb
7878

79+
- name: Build m17-bridge for Raspberry Pi (ARM64)
80+
run: |
81+
cd cmd/m17-bridge
82+
echo "Building M17 Gateway for ARM64 architecture (64-bit Raspberry Pi OS)..."
83+
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o m17-bridge .
84+
echo "Build completed successfully"
85+
ls -la m17-bridge
86+
file m17-bridge
87+
88+
- name: Make m17-bridge build script executable
89+
run: |
90+
cd cmd/m17-bridge
91+
chmod +x ./packaging/scripts/build-deb.sh
92+
93+
- name: Build m17-bridge .deb package
94+
run: |
95+
cd cmd/m17-bridge
96+
./packaging/scripts/build-deb.sh ${{ steps.version.outputs.VERSION }}
97+
98+
- name: List m17-bridge build artifacts
99+
run: |
100+
cd cmd/m17-bridge
101+
ls -la build/
102+
103+
- name: Upload m17-bridge .deb package
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: m17-bridge-debian-package
107+
path: cmd/m17-bridge/build/*.deb
108+
79109
- name: Create Release
80110
if: startsWith(github.ref, 'refs/tags/')
81111
uses: softprops/action-gh-release@v1
82112
with:
83-
files: cmd/m17-gateway/build/*.deb
113+
files: |
114+
cmd/m17-gateway/build/*.deb
115+
cmd/m17-bridge/build/*.deb
84116
generate_release_notes: true
85117
env:
86118
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -92,20 +124,40 @@ jobs:
92124
steps:
93125
- uses: actions/checkout@v4
94126

95-
- name: Download .deb package
127+
- name: Download m17-gateway .deb package
96128
uses: actions/download-artifact@v4
97129
with:
98130
name: m17-gateway-debian-package
99131
path: ./
100132

101-
- name: Test package info
133+
- name: Test m17-gateway package info
134+
run: |
135+
# Install dpkg tools
136+
sudo apt-get update
137+
sudo apt-get install -y dpkg-dev
138+
139+
# Check package info
140+
DEB_FILE=$(ls m17-gateway*.deb)
141+
echo "Package contents:"
142+
dpkg -c "$DEB_FILE"
143+
144+
echo "Package info:"
145+
dpkg -I "$DEB_FILE"
146+
147+
- name: Download m17-bridge .deb package
148+
uses: actions/download-artifact@v4
149+
with:
150+
name: m17-bridge-debian-package
151+
path: ./
152+
153+
- name: Test m17-bridge package info
102154
run: |
103155
# Install dpkg tools
104156
sudo apt-get update
105157
sudo apt-get install -y dpkg-dev
106158
107159
# Check package info
108-
DEB_FILE=$(ls *.deb)
160+
DEB_FILE=$(ls m17-bridge*.deb)
109161
echo "Package contents:"
110162
dpkg -c "$DEB_FILE"
111163
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func loadConfig(iniFile string) (*config, error) {
6666
}
6767

6868
var (
69-
configFile *string = flag.String("config", "./bridge.ini", "Configuration file")
69+
configFile *string = flag.String("config", "./m17-bridge.ini", "Configuration file")
7070
helpArg *bool = flag.Bool("h", false, "Print arguments")
7171
)
7272

@@ -166,7 +166,6 @@ func NewBridge(cfg *config) (*Bridge, error) {
166166
k,
167167
ret.server,
168168
m.Key("Server").String(),
169-
m.Key("Callsign").String(),
170169
m.Key("Symbol").String(),
171170
)
172171
if err != nil {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Package: m17-bridge
2+
Version: VERSION_PLACEHOLDER
3+
Section: utils
4+
Priority: optional
5+
Architecture: arm64
6+
Depends: systemd
7+
Maintainer: Jim Ancona, N1ADJ <jim@anconafamily.com>
8+
Description: M17 Messaging Bridge for Raspberry Pi
9+
M17 Messaging Bridge that runs as a systemd service on Raspberry Pi.
10+
This package includes the binary, configuration file, and systemd service configuration.
11+
Built for 64-bit Raspberry Pi OS (Bookworm or later).
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Create service user and groups if they don't exist
6+
if ! getent group m17-bridge >/dev/null; then
7+
groupadd --system m17-bridge
8+
fi
9+
10+
if ! getent passwd m17-bridge >/dev/null; then
11+
useradd --system --gid m17-bridge --shell /bin/false m17-bridge
12+
fi
13+
14+
# Make binary executable
15+
chmod +x /usr/bin/m17-bridge
16+
17+
# Set config file ownership and permissions (readable by service user, writable by service control group)
18+
chown m17-bridge:m17-bridge /etc/m17-bridge.ini
19+
chmod 664 /etc/m17-bridge.ini
20+
21+
# Reload systemd and enable the service
22+
systemctl daemon-reload
23+
systemctl enable m17-bridge.service
24+
25+
echo
26+
echo "M17 Messaging Bridge installed successfully!"
27+
echo "Configuration file: /etc/m17-bridge.ini"
28+
echo "View logs with: journalctl -u m17-bridge -o cat -f"
29+
echo "Start with: sudo systemctl start m17-bridge"
30+
echo "Check status with: systemctl status m17-bridge"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ "$1" = "purge" ]; then
6+
# Remove service user and group
7+
if getent passwd m17-bridge >/dev/null; then
8+
userdel m17-bridge
9+
fi
10+
11+
if getent group m17-bridge >/dev/null; then
12+
groupdel m17-bridge
13+
fi
14+
15+
# Remove config
16+
rm -f /etc/m17-bridge.ini
17+
18+
echo "M17 Messaging Bridge service and user data removed."
19+
fi
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Stop and disable the service
6+
if systemctl is-active --quiet m17-bridge.service; then
7+
systemctl stop m17-bridge.service
8+
fi
9+
10+
if systemctl is-enabled --quiet m17-bridge.service; then
11+
systemctl disable m17-bridge.service
12+
fi
13+
14+
systemctl daemon-reload
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[General]
2+
Name=TestBridge
3+
ListenAddress=127.0.0.1
4+
ListenPort=17000
5+
Modules=DIA
6+
7+
[Log]
8+
# Logging levels: ERROR, INFO, DEBUG
9+
Level=DEBUG
10+
11+
[Module-D]
12+
Type=Discord
13+
ChannelName=ham-only
14+
WebhookURL="<Discord Webhook URL>"
15+
BotToken=<Discord Bot Token>
16+
17+
[Module-I]
18+
Type=IRC
19+
Server=127.0.0.1
20+
Port=6667
21+
UseTLS=false
22+
ServerPassword=<server password>
23+
24+
[Module-A]
25+
Type=APRS
26+
# Server for your area. See http://aprs2.net/
27+
Server=noam.aprs2.net
28+
Symbol=// # APRS symbol. See https://www.aprs.org/symbols.html
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[Unit]
2+
Description=M17 Messaging Bridge
3+
After=network.target
4+
Wants=network.target
5+
6+
[Service]
7+
Type=simple
8+
User=m17-bridge
9+
Group=m17-bridge
10+
# WorkingDirectory=/opt/m17/m17-bridge
11+
ExecStart=/usr/bin/m17-bridge -config /etc/m17-bridge.ini
12+
Restart=on-failure
13+
RestartSec=10
14+
StandardOutput=journal
15+
StandardError=journal
16+
17+
# Security settings
18+
NoNewPrivileges=yes
19+
PrivateTmp=yes
20+
ProtectSystem=full
21+
ProtectHome=yes
22+
23+
[Install]
24+
WantedBy=multi-user.target
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
VERSION=${1:-1.0.0}
6+
PACKAGE_NAME="m17-bridge"
7+
ARCH="arm64"
8+
9+
echo "Building .deb package for ${PACKAGE_NAME} version ${VERSION} (${ARCH})"
10+
11+
# Create build directory
12+
BUILD_DIR="build/${PACKAGE_NAME}_${VERSION}_${ARCH}"
13+
mkdir -p "${BUILD_DIR}"
14+
15+
# Create directory structure
16+
mkdir -p "${BUILD_DIR}/usr/bin"
17+
mkdir -p "${BUILD_DIR}/etc/systemd/system"
18+
mkdir -p "${BUILD_DIR}/DEBIAN"
19+
20+
# Copy binary
21+
cp "${PACKAGE_NAME}" "${BUILD_DIR}/usr/bin/"
22+
23+
cd packaging
24+
25+
# Copy configuration file
26+
cp "${PACKAGE_NAME}.ini.sample" "../${BUILD_DIR}/etc/${PACKAGE_NAME}.ini"
27+
28+
# Copy systemd service file
29+
cp "${PACKAGE_NAME}.service" "../${BUILD_DIR}/etc/systemd/system/"
30+
31+
# Copy control file and replace version
32+
sed "s/VERSION_PLACEHOLDER/${VERSION}/g" debian/control > "../${BUILD_DIR}/DEBIAN/control"
33+
34+
# Copy debian scripts
35+
cp debian/postinst "../${BUILD_DIR}/DEBIAN/"
36+
cp debian/prerm "../${BUILD_DIR}/DEBIAN/"
37+
cp debian/postrm "../${BUILD_DIR}/DEBIAN/"
38+
39+
cd ..
40+
41+
# Make scripts executable
42+
chmod +x "${BUILD_DIR}/DEBIAN/postinst"
43+
chmod +x "${BUILD_DIR}/DEBIAN/prerm"
44+
chmod +x "${BUILD_DIR}/DEBIAN/postrm"
45+
46+
# Build the package
47+
dpkg-deb --build "${BUILD_DIR}"
48+
49+
echo "Package built: ${BUILD_DIR}.deb"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
fyne.io/fyne/v2 v2.5.5
1313
github.com/StalkR/discordgo-bridge v1.0.10
1414
github.com/bwmarrin/discordgo v0.29.0
15-
github.com/ebarkie/aprs v1.0.4
15+
github.com/ebarkie/aprs v1.0.5
1616
github.com/ergochat/irc-go v0.5.0
1717
github.com/go-zeromq/zmq4 v0.17.0
1818
github.com/icza/gog v0.0.0-20241010132004-5da24f18211d

0 commit comments

Comments
 (0)