Skip to content

Commit

Permalink
fix: adapt setup scripts to run properly on distrobox (#1687)
Browse files Browse the repository at this point in the history
Due to a problem with [ruby-augeas](https://rubygems.org/gems/augeas)
and Ruby 3.3, the setup script does not work anymore. In our continuous
integration we decided to use the system libraries, which causes bundler
to install software into `/usr/lib`. Of course, we do not want that
behavior everywhere.

Alternatively, this PR adapts the script to work using distrobox. The
setup is rather simple:

```
distrobox create --root --init --image tumbleweed --name agama
distrobox enter --root agama
./setup.sh
```

The script detects that it is running on distrobox and it workarounds
the augeas problem like in our continuous integration.

Please, see #1685 for more context.
  • Loading branch information
imobachgs authored Nov 6, 2024
2 parents a71e9e0 + cc8aa93 commit 016a4d9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions setup-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ZYPPER="zypper --non-interactive -v"
$SUDO $ZYPPER install \
gcc \
gcc-c++ \
git \
make \
openssl-devel \
ruby-devel \
Expand Down Expand Up @@ -116,14 +117,15 @@ fi
sed -e '/gemspec/a gem "ruby-dbus", path: "/checkout-ruby-dbus"' -i Gemfile
fi

if [ -n "$CI" ]; then
if [ -n "${CI:-}" ]; then
# in CI reuse the pre-installed system gems from RPMs
bundle config set --local disable_shared_gems 0
$SUDO bundle install
else
bundle config set --local path 'vendor/bundle'
bundle install
fi

bundle install
)

# Rust service, CLI and auto-installation.
Expand All @@ -137,6 +139,7 @@ $SUDO $ZYPPER install \
gzip \
jsonnet \
lshw \
NetworkManager \
pam-devel \
python-langtable-data \
tar \
Expand All @@ -147,7 +150,7 @@ $SUDO $ZYPPER install \
cd $MYDIR/rust
cargo build

ln -st /usr/bin $MYDIR/rust/target/debug/agama{,*server}
$SUDO ln -sft /usr/bin $MYDIR/rust/target/debug/agama{,*server}
)

# - D-Bus configuration
Expand Down Expand Up @@ -192,7 +195,19 @@ $SUDO mkdir -p /usr/share/agama/products.d
$SUDO cp -f $MYDIR/products.d/*.yaml /usr/share/agama/products.d

# - Make sure NetworkManager is running
$SUDO systemctl start NetworkManager
if [ -n "${DISTROBOX_ENTER_PATH:-}" ]; then
AGAMA_WEB_SERVER_SVC="/usr/lib/systemd/system/agama-web-server.service"
grep -q DBUS_SYSTEM_BUS_ADDRESS $AGAMA_WEB_SERVER_SVC || $SUDO sed -i \
-e '/\[Service\]/a Environment="DBUS_SYSTEM_BUS_ADDRESS=unix:path=/run/host/run/dbus/system_bus_socket"' \
$AGAMA_WEB_SERVER_SVC

AGAMA_SVC="/usr/lib/systemd/system/agama.service"
grep -q DBUS_SYSTEM_BUS_ADDRESS $AGAMA_SVC || $SUDO sed -i \
-e '/\[Service\]/a Environment="DBUS_SYSTEM_BUS_ADDRESS=unix:path=/run/host/run/dbus/system_bus_socket"' \
$AGAMA_SVC
else
$SUDO systemctl start NetworkManager
fi

# systemd reload and start of service
(
Expand Down

0 comments on commit 016a4d9

Please sign in to comment.