fixeria has submitted this change. ( https://gerrit.osmocom.org/c/osmo-dev/+/40770?usp=email )
Change subject: gen_makefile: support new Osmocom erlang makefiles
......................................................................
gen_makefile: support new Osmocom erlang makefiles
osmo-s1gw has a new install target that creates a complete release
package instead of running escriptize, which means different files will
need to be installed. From now on let's call the "install" target in the
Makefile if it exists.
Other erlang projects that osmo-dev supports:
* osmo-dia2gsup: "make install" works after adjusting it to support
REBAR_BASE_DIR (see patch mentioned below).
* osmo-epdg: doesn't have an "install" target in the Makefile yet, so it
will use the existing logic.
Depends: osmo-s1gw I5681ca103daf1c497218b4513b0ca97b1aae03d3
Depends: osmo-dia2gsup I9511341bced7d658eacb34250569dfbfe37c084c
Change-Id: I92d6fc6eb5a11068d4b3baca55dfb3abdedbbbf1
---
M gen_makefile.py
1 file changed, 18 insertions(+), 5 deletions(-)
Approvals:
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/gen_makefile.py b/gen_makefile.py
index a118392..e06dbd2 100755
--- a/gen_makefile.py
+++ b/gen_makefile.py
@@ -340,7 +340,7 @@
else:
assert False, f"unknown buildsystem: {buildsystem}"
-def gen_makefile_install(proj, build_proj):
+def gen_makefile_install(proj, build_proj, src_proj):
no_ldconfig = '#' if args.no_ldconfig else ''
sudo_ldconfig = '' if args.ldconfig_without_sudo else 'sudo '
sudo_make_install = "sudo " if args.sudo_make_install else ""
@@ -364,12 +364,24 @@
touch $@
'''
elif buildsystem == "erlang":
+ # Use the "install" target if it exists, otherwise fall back to installing
+ # files generated by escriptize in default/bin. The fallback method can be
+ # removed once osmo-epdg has an install target.
return f'''
.make.{proj}.install: .make.{proj}.build
@echo "\\n\\n\\n===== $@\\n"
- for i in {build_proj}/default/bin/*; do \\
- install -v -Dm755 "$$i" -t {shlex.quote(args.install_prefix)}/bin/; \\
- done
+ set -ex; \\
+ if grep -q "^install:" {shlex.quote(src_proj)}/Makefile; then \\
+ {sudo_make_install}$(MAKE) \\
+ -C {shlex.quote(src_proj)} \\
+ install \\
+ DESTDIR={shlex.quote(args.install_prefix)} \\
+ REBAR_BASE_DIR="$$PWD"/{shlex.quote(build_proj)}; \\
+ else \\
+ for i in {build_proj}/default/bin/*; do \\
+ install -v -Dm755 "$$i" -t {shlex.quote(args.install_prefix)}/bin/; \\
+ done; \\
+ fi
sync
touch $@
'''
@@ -486,7 +498,8 @@
update_src_copy_cmd)}
{gen_makefile_install(proj,
- build_proj)}
+ build_proj,
+ src_proj)}
{gen_makefile_reinstall(proj,
deps_reinstall,
--
To view, visit https://gerrit.osmocom.org/c/osmo-dev/+/40770?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-Change-Id: I92d6fc6eb5a11068d4b3baca55dfb3abdedbbbf1
Gerrit-Change-Number: 40770
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/40756?usp=email )
Change subject: Makefile: generate and install complete release package
......................................................................
Makefile: generate and install complete release package
Previously, our Debian packages installed osmo-s1gw as an escript
executable - essentially a self-unpacking zip archive containing
*.app and *.beam files, similar to a Java JAR. This was generated
using `rebar3 escriptize` and worked well for some time.
However, at some point we started hitting bugs and limitations with
this approach, prompting a change to packaging osmo-s1gw as a
standard OTP-style BEAM application. This patch resolves those
issues and aligns better with typical Erlang deployment practices.
The default rebar3-generated start script daemonizes (double‑forks)
and wraps erlexec in complex shell logic that does not play well
with systemd (e.g. erl_child_setup failures). Thus we provide a
custom script that calls erlexec directly, avoids double‑forking,
and adds some user-friendly command line options.
The resulting package no longer depends on `erlang-nox` since it
includes the ERTS (Erlang Runtime System). This ensures consistent
behavior across different environments and simplifies deployment.
Change-Id: I5681ca103daf1c497218b4513b0ca97b1aae03d3
Related: SYS#7332
---
M Makefile
A contrib/osmo-s1gw.sh
M contrib/systemd/osmo-s1gw.service
M debian/control
4 files changed, 98 insertions(+), 6 deletions(-)
Approvals:
Jenkins Builder: Verified
osmith: Looks good to me, approved
diff --git a/Makefile b/Makefile
index 1f37da5..ec8a7d6 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,7 @@
EUNIT_ARGS ?=
# directory paths for 'install'
BINDIR ?= /usr/bin
+LIBDIR ?= /usr/lib
CONFDIR ?= /etc/osmocom
SYSTEMDUNITDIR ?= /lib/systemd/system
@@ -32,8 +33,16 @@
analyze: $(GEN_FILES)
rebar3 dialyzer
-install: build
- install -Dm0755 _build/default/bin/osmo-s1gw \
+release: $(GEN_FILES)
+ rebar3 release
+
+run-release: release
+ contrib/osmo-s1gw.sh -r $(REBAR_BASE_DIR)/default/rel/osmo-s1gw -c $(CONFIG)
+
+install: release
+ install -d $(DESTDIR)$(LIBDIR)
+ cp -r $(REBAR_BASE_DIR)/default/rel/osmo-s1gw $(DESTDIR)$(LIBDIR)/
+ install -Dm0755 contrib/osmo-s1gw.sh \
$(DESTDIR)$(BINDIR)/osmo-s1gw
install -Dm0644 config/sys.config \
$(DESTDIR)$(CONFDIR)/osmo-s1gw.config
diff --git a/contrib/osmo-s1gw.sh b/contrib/osmo-s1gw.sh
new file mode 100755
index 0000000..385f981
--- /dev/null
+++ b/contrib/osmo-s1gw.sh
@@ -0,0 +1,83 @@
+#!/bin/sh -e
+
+# Simple boot script for Erlang/OTP releases that can be used in systemd unit files.
+#
+# Copyright 2025 by sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de>
+# Author: Vadim Yanitskiy <vyanitskiy(a)sysmocom.de>
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+APP_NAME=osmo-s1gw
+
+ROOTDIR=${ROOTDIR:-"/usr/lib/${APP_NAME}"}
+CONFIG="/etc/osmocom/${APP_NAME}.config"
+COOKIE="${APP_NAME}"
+NODE_NAME="${APP_NAME}@$(uname -n)"
+ERL_SHELL="-noshell -noinput"
+
+# Parse command line options, if any
+while getopts "c:C:n:r:s" opt; do
+ case "$opt" in
+ c)
+ CONFIG="$OPTARG"
+ ;;
+ C)
+ COOKIE="$OPTARG"
+ ;;
+ n)
+ NODE_NAME="$OPTARG"
+ ;;
+ r)
+ ROOTDIR=$(realpath "$OPTARG")
+ ;;
+ s)
+ ERL_SHELL="-shell"
+ ;;
+ *)
+ echo "Usage: $0 [-s] [-r ROOTDIR] [-c CONFIG] [-C COOKIE] [-n NAME@HOST]"
+ exit 1
+ ;;
+ esac
+done
+
+# Make sure that the application's root directory exists
+if [ ! -d "${ROOTDIR}" ]; then
+ echo "Error: ROOTDIR=${ROOTDIR} does not exist"
+ echo "Please specify the root directory using '-r' or via the environment"
+ exit 1
+fi
+
+# Determine the ERTS directory path (if not set)
+if [ -z "${ERTS_DIR}" ]; then
+ # Parse the ERTS version from rebar3-generated bootstrap script
+ ERTS_VSN=$(grep "^ERTS_VSN=" ${ROOTDIR}/bin/${APP_NAME} | cut -d'"' -f2)
+ ERTS_DIR=${ERTS_DIR:-"${ROOTDIR}/erts-${ERTS_VSN}"}
+fi
+
+# Determine the release directory path (if not set)
+if [ -z "${REL_DIR}" ]; then
+ # Parse the release version from rebar3-generated bootstrap script
+ REL_VSN=$(grep "^REL_VSN=" ${ROOTDIR}/bin/${APP_NAME} | cut -d'"' -f2)
+ REL_DIR="${ROOTDIR}/releases/${REL_VSN}"
+fi
+
+# Determine the boot script name
+[ -f "${REL_DIR}/${APP_NAME}.boot" ] && BOOTFILE="${APP_NAME}" || BOOTFILE=start
+
+# erlexec requires BINDIR to be set
+export BINDIR="${ERTS_DIR}/bin"
+
+exec ${BINDIR}/erlexec \
+ +C multi_time_warp \
+ -boot "${REL_DIR}/${BOOTFILE}" \
+ -config "${CONFIG}" \
+ -setcookie "${COOKIE}" \
+ -sname "${NODE_NAME}" \
+ -mode embedded \
+ ${ERL_SHELL}
+
+# vim:set ts=2 sw=2 et:
diff --git a/contrib/systemd/osmo-s1gw.service b/contrib/systemd/osmo-s1gw.service
index a265964..bd52c4d 100644
--- a/contrib/systemd/osmo-s1gw.service
+++ b/contrib/systemd/osmo-s1gw.service
@@ -11,8 +11,7 @@
User=osmocom
Group=osmocom
Environment="HOME=/var/lib/osmo-s1gw"
-Environment="ERL_FLAGS=-config /etc/osmocom/osmo-s1gw.config"
-ExecStart=/usr/bin/osmo-s1gw foreground
+ExecStart=/usr/bin/osmo-s1gw -c /etc/osmocom/osmo-s1gw.config
CapabilityBoundingSet=CAP_NET_ADMIN
AmbientCapabilities=CAP_NET_ADMIN
RestartSec=2
diff --git a/debian/control b/debian/control
index eea7e1c..f5dda19 100644
--- a/debian/control
+++ b/debian/control
@@ -13,8 +13,9 @@
Package: osmo-s1gw
Architecture: any
-Depends: erlang-nox
-Multi-Arch: allowed
+Depends: ${shlibs:Depends},
+ ${misc:Depends}
+Multi-Arch: foreign
Description: Osmocom S1 gateway
This can be used on the S1 interface between eNB and MME/CN, and
acts as separation between the eNB-facing IP network and the
--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/40756?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: I5681ca103daf1c497218b4513b0ca97b1aae03d3
Gerrit-Change-Number: 40756
Gerrit-PatchSet: 5
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/40757?usp=email )
Change subject: Makefile: 'run' becomes an alias of 'shell'
......................................................................
Makefile: 'run' becomes an alias of 'shell'
Running osmo-s1gw in form of an escript executable is prone to errors.
* Move away from escript and make 'run' an alias of 'shell'.
* Move `rebar3 escriptize` to a dedicated 'escript' recipe.
* Add 'run-escript' recipe in case its ever needed.
Change-Id: I8b34c11cc9361d8b65316401f67a5038544b27ac
Related: SYS#7332
---
M Makefile
1 file changed, 5 insertions(+), 1 deletion(-)
Approvals:
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/Makefile b/Makefile
index ec8a7d6..6b9267d 100644
--- a/Makefile
+++ b/Makefile
@@ -19,11 +19,15 @@
build: $(GEN_FILES)
rebar3 compile
+
+escript: $(GEN_FILES)
rebar3 escriptize
-run: build
+run-escript: escript
ERL_FLAGS='-config $(CONFIG)' $(REBAR_BASE_DIR)/default/bin/osmo-s1gw
+run: shell
+
shell: build
rebar3 shell --config $(CONFIG)
--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/40757?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: I8b34c11cc9361d8b65316401f67a5038544b27ac
Gerrit-Change-Number: 40757
Gerrit-PatchSet: 5
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/40765?usp=email )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: debian: add copyright file
......................................................................
debian: add copyright file
Change-Id: I95d9314f7f858c02a6ac10641c958bbf13677814
---
A debian/copyright
1 file changed, 47 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
osmith: Looks good to me, approved
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..d9fcc54
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,47 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Source: https://gitea.osmocom.org/erlang/osmo-s1gw
+Upstream-Name: osmo-s1gw
+
+Files: src/*.erl
+ include/*.hrl
+ debian/*
+Copyright: sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de>
+License: AGPL-3.0-or-later
+
+Files: contrib/osmo-s1gw.sh
+Copyright: sysmocom - s.f.m.c. GmbH <info(a)sysmocom.de>
+License: MPL-2.0
+
+
+License: AGPL-3.0-or-later
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as
+ published by the Free Software Foundation; either version 3 of the
+ License, or (at your option) any later version.
+ .
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+ .
+ Additional Permission under GNU AGPL version 3 section 7:
+ .
+ If you modify this Program, or any covered work, by linking or
+ combining it with runtime libraries of Erlang/OTP as released by
+ Ericsson on https://www.erlang.org (or a modified version of these
+ libraries), containing parts covered by the terms of the Erlang Public
+ License (https://www.erlang.org/EPLICENSE), the licensors of this
+ Program grant you additional permission to convey the resulting work
+ without the need to license the runtime libraries of Erlang/OTP under
+ the GNU Affero General Public License. Corresponding Source for a
+ non-source form of such a combination shall include the source code
+ for the parts of the runtime libraries of Erlang/OTP used as well as
+ that of the covered work.
+
+License: MPL-2.0
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at https://mozilla.org/MPL/2.0/.
--
To view, visit https://gerrit.osmocom.org/c/erlang/osmo-s1gw/+/40765?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: erlang/osmo-s1gw
Gerrit-Branch: master
Gerrit-Change-Id: I95d9314f7f858c02a6ac10641c958bbf13677814
Gerrit-Change-Number: 40765
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>