Skip to content

Commit 913cf8c

Browse files
authored
Merge pull request #485 from KKoukiou/workaround-firefox-crash-boot-iso
Fix bridge crashing installation on boot.iso
2 parents ea33afd + 1f66fa2 commit 913cf8c

File tree

7 files changed

+77
-56
lines changed

7 files changed

+77
-56
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ install: $(DIST_TEST) po/LINGUAS
113113
mkdir -p $(DESTDIR)/usr/libexec/anaconda
114114
cp webui-desktop $(DESTDIR)/usr/libexec/anaconda
115115
ln -sTfr $(DESTDIR)/usr/share/pixmaps/fedora-logo-sprite.svg $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME)/logo.svg
116+
mkdir -p $(DESTDIR)/usr/lib/systemd/system/
117+
cp src/systemd/webui-cockpit-ws.service $(DESTDIR)/usr/lib/systemd/system/
116118

117119
# required for running integration tests;
118120
TEST_NPMS = \

packaging/anaconda-webui.spec.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ BuildArch: noarch
1010
BuildRequires: libappstream-glib
1111
BuildRequires: make
1212
BuildRequires: gettext
13+
# Needed for the unitdir macro
14+
BuildRequires: systemd-rpm-macros
1315

1416
%global anacondacorever 0
1517

@@ -20,6 +22,8 @@ BuildRequires: gettext
2022
%global cockpitver 275
2123
%global cockpitstorver 311
2224

25+
%define _unitdir /usr/lib/systemd/system
26+
2327
Requires: cockpit-storaged >= %{cockpitstorver}
2428
Requires: cockpit-bridge >= %{cockpitver}
2529
Requires: cockpit-ws >= %{cockpitver}
@@ -79,6 +83,7 @@ exit 0
7983
%{_datadir}/anaconda/firefox-theme/live/user.js
8084
%{_datadir}/anaconda/firefox-theme/live/chrome/userChrome.css
8185
%{_libexecdir}/anaconda/webui-desktop
86+
%{_unitdir}/webui-cockpit-ws.service
8287

8388

8489
# The changelog is automatically generated and merged

src/systemd/webui-cockpit-ws.service

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Cockpit Web Service for Anaconda Installer
3+
After=network.target
4+
5+
[Service]
6+
Type=simple
7+
EnvironmentFile=/tmp/webui-cockpit-ws.env
8+
Environment="COCKPIT_SUPERUSER=pkexec"
9+
ExecStart=/usr/libexec/cockpit-ws -p 80 -a "$WEBUI_ADDRESS" --no-tls --local-session=cockpit-bridge
10+
Restart=on-failure
11+
RestartSec=5s
12+
13+
[Install]
14+
WantedBy=multi-user.target

test/anacondalib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def setUp(self):
6969
self.addCleanup(self.resetUsers)
7070
self.addCleanup(self.resetStorage)
7171
self.addCleanup(self.resetLanguage)
72+
self.addCleanup(self.resetMisc)
7273

7374
super().setUp()
7475

@@ -150,6 +151,12 @@ def resetStorage(self):
150151
s.dbus_set_initialization_mode(-1)
151152
s.dbus_scan_devices()
152153

154+
def resetMisc(self):
155+
# Restart cockpit-ws/cockpit-bridge to avoid crashes in the next test
156+
m = self.machine
157+
158+
m.execute("systemctl restart webui-cockpit-ws.service")
159+
153160
def downloadLogs(self):
154161
if not self.ext_logging:
155162
return

test/machine_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def start(self):
151151
"--noautoconsole "
152152
f"--graphics vnc,listen={self.ssh_address} "
153153
"--extra-args "
154-
f"'inst.sshd inst.webui.remote inst.webui inst.updates=http://10.0.2.2:{self.http_updates_img_port}/{self.label}-updates.img' "
154+
f"'inst.sshd inst.webui.remote inst.updates=http://10.0.2.2:{self.http_updates_img_port}/{self.label}-updates.img' "
155155
"--network none "
156156
f"--qemu-commandline="
157157
"'-netdev user,id=hostnet0,"

test/vm.install

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ BOTS_DIR = os.path.realpath(f'{__file__}/../../bots')
1313
sys.path.append(BOTS_DIR)
1414

1515
missing_packages = "cockpit-ws cockpit-bridge fedora-logos udisks2 libudisks2 udisks2-lvm2 udisks2-btrfs udisks2-iscsi"
16-
# Install missing firefox dependencies.
17-
# Resolving all dependencies with dnf download is possible,
18-
# but it packs to many packages to updates.img
19-
missing_packages_incl_deps = "firefox"
2016

2117
from machine.machine_core import machine_virtual
2218

@@ -89,9 +85,6 @@ def vm_install(image, verbose, quick):
8985
# Then we can enable this only for the various scenarios above
9086
if packages_to_download is not None:
9187
machine.execute(f"dnf download --destdir /var/tmp/build/ {packages_to_download}", stdout=sys.stdout, timeout=300)
92-
machine.execute(
93-
f"dnf download --resolve --setopt=install_weak_deps=False --destdir /var/tmp/build/ {missing_packages_incl_deps}",
94-
stdout=sys.stdout, timeout=300)
9588

9689
# download rpms
9790
vm_rpms = machine.execute("find /var/tmp/build -name '*.rpm' -not -name '*.src.rpm'").strip().split()

webui-desktop

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -64,65 +64,65 @@ case "$1" in
6464
;;
6565
esac
6666

67-
# prepare empty firefox profile dir with theme based on the passed profile id
68-
FIREFOX_THEME_DIR="/usr/share/anaconda/firefox-theme"
69-
FIREFOX_PROFILE_PATH="/tmp/anaconda-firefox-profile"
70-
71-
# make sure the profile directory exists and is empty
72-
if [ -d ${FIREFOX_PROFILE_PATH} ]
67+
WEBUI_ADDRESS="127.0.0.1"
68+
if [[ "$WEBUI_REMOTE" == "1" ]]
7369
then
74-
echo "Cleaning up existing Anaconda Firefox profile directory."
75-
rm -rf ${FIREFOX_PROFILE_PATH}
70+
WEBUI_ADDRESS="0.0.0.0"
7671
fi
77-
mkdir -p ${FIREFOX_PROFILE_PATH}
7872

79-
# populate the profile directory with our custom Firefox theme
80-
# - theme id is passed as the second argument of this script
81-
THEME_PATH="${FIREFOX_THEME_DIR}/${THEME_ID}"
73+
echo "WEBUI_ADDRESS=$WEBUI_ADDRESS" > /tmp/webui-cockpit-ws.env
74+
systemctl start webui-cockpit-ws
8275

83-
cp -a "${THEME_PATH}/." ${FIREFOX_PROFILE_PATH}
84-
85-
# FIXME: is this hardcoded resolution necessary ?
86-
BROWSER="/usr/bin/firefox --new-instance --window-size 1024,768 --profile ${FIREFOX_PROFILE_PATH}"
87-
88-
# start browser in a temporary home dir, so that it does not interfere with your real one
89-
BROWSER_HOME=$(mktemp --directory --tmpdir cockpit.desktop.XXXXXX)
90-
91-
WEBUI_ADDRESS="127.0.0.1"
9276
if [[ "$WEBUI_REMOTE" == "1" ]]
9377
then
94-
WEBUI_ADDRESS="0.0.0.0"
78+
/bin/sleep infinity &
79+
BLOCK_ON_PID=$!
80+
else
81+
# prepare empty firefox profile dir with theme based on the passed profile id
82+
FIREFOX_THEME_DIR="/usr/share/anaconda/firefox-theme"
83+
FIREFOX_PROFILE_PATH="/tmp/anaconda-firefox-profile"
84+
85+
# make sure the profile directory exists and is empty
86+
if [ -d ${FIREFOX_PROFILE_PATH} ]
87+
then
88+
echo "Cleaning up existing Anaconda Firefox profile directory."
89+
rm -rf ${FIREFOX_PROFILE_PATH}
90+
fi
91+
mkdir -p ${FIREFOX_PROFILE_PATH}
92+
93+
# populate the profile directory with our custom Firefox theme
94+
# - theme id is passed as the second argument of this script
95+
THEME_PATH="${FIREFOX_THEME_DIR}/${THEME_ID}"
96+
97+
cp -a "${THEME_PATH}/." ${FIREFOX_PROFILE_PATH}
98+
99+
# FIXME: is this hardcoded resolution necessary ?
100+
BROWSER="/usr/bin/firefox --new-instance --window-size 1024,768 --profile ${FIREFOX_PROFILE_PATH}"
101+
102+
# start browser in a temporary home dir, so that it does not interfere with your real one
103+
BROWSER_HOME=$(mktemp --directory --tmpdir cockpit.desktop.XXXXXX)
104+
105+
# if we have netcat, use it for waiting until ws is up
106+
if type nc >/dev/null 2>&1; then
107+
for _ in `seq 10`; do
108+
nc -z "$WEBUI_ADDRESS" 80 && break
109+
sleep 0.5;
110+
done
111+
else
112+
# otherwise, just wait a bit
113+
sleep 3
114+
fi
115+
116+
HOME="$BROWSER_HOME" MOZ_APP_TITLE="" MOZ_APP_REMOTINGNAME="liveinst" XDG_CURRENT_DESKTOP=GNOME MOZ_GTK_TITLEBAR_DECORATION=client $BROWSER http://"$WEBUI_ADDRESS""$URL_PATH" &
117+
BLOCK_ON_PID=$!
95118
fi
96119

97-
# forward parent stdin and stdout (from bridge) to cockpit-ws
98-
# it pretty well does not matter which port we use in our own namespace, so use standard http
99-
# disable /etc/cockpit/
100-
XDG_CONFIG_DIRS="$BROWSER_HOME" COCKPIT_SUPERUSER="pkexec" /usr/libexec/cockpit-ws -p 80 -a "$WEBUI_ADDRESS" --no-tls --local-session=cockpit-bridge &
101-
WS_PID=$!
102-
exec > >(systemd-cat -t anaconda) 2>&1
103-
104120
# Cleanup function
105121
cleanup() {
106122
set +e
107-
kill $WS_PID
108-
wait $WS_PID
109-
kill $B_PID
110-
rm -rf $BROWSER_HOME
123+
kill $BLOCK_ON_PID
124+
[[ -n $BROWSER_HOME ]] && rm -rf $BROWSER_HOME
111125
}
112126
trap 'cleanup' EXIT INT QUIT PIPE
113127

114-
# if we have netcat, use it for waiting until ws is up
115-
if type nc >/dev/null 2>&1; then
116-
for _ in `seq 10`; do
117-
nc -z "$WEBUI_ADDRESS" 80 && break
118-
sleep 0.5;
119-
done
120-
else
121-
# otherwise, just wait a bit
122-
sleep 3
123-
fi
124-
125-
HOME="$BROWSER_HOME" MOZ_APP_TITLE="" MOZ_APP_REMOTINGNAME="liveinst" XDG_CURRENT_DESKTOP=GNOME MOZ_GTK_TITLEBAR_DECORATION=client $BROWSER http://"$WEBUI_ADDRESS""$URL_PATH" &
126-
B_PID=$!
127-
128-
wait $B_PID
128+
wait $BLOCK_ON_PID

0 commit comments

Comments
 (0)