Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove support for Upstart #228

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 15 additions & 44 deletions apport/hookutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import subprocess
import sys
import tempfile
import warnings

import apport.fileutils
from apport.packaging_impl import impl as packaging
Expand Down Expand Up @@ -167,56 +168,26 @@ def attach_conffiles(report, package, conffiles=None, ui=None):
report[f"mtime.conffile.{path_to_key(path)}"] = mtime.isoformat()


# pylint: disable-next=unused-argument
def attach_upstart_overrides(report, package):
"""Attach information about any Upstart override files."""
try:
files = packaging.get_files(package)
except ValueError:
return

for file in files:
if os.path.exists(file) and file.startswith("/etc/init/"):
override = file.replace(".conf", ".override")
key = f"upstart.{override.replace('/etc/init/', '')}"
attach_file_if_exists(report, override, key)
warnings.warn(
"apport.hookutils.attach_upstart_overrides() is obsolete."
" Upstart is dead. Please drop this call.",
PendingDeprecationWarning,
stacklevel=2,
)


# pylint: disable-next=unused-argument
def attach_upstart_logs(report, package):
"""Attach information about a package's session upstart logs."""
try:
files = packaging.get_files(package)
except ValueError:
return

for f in files:
if not os.path.exists(f):
continue
if f.startswith("/usr/share/upstart/sessions/"):
log = os.path.basename(f).replace(".conf", ".log")
key = f"upstart.{log}"
try:
log = os.path.join(os.environ["XDG_CACHE_HOME"], "upstart", log)
except KeyError:
try:
log = os.path.join(os.environ["HOME"], ".cache", "upstart", log)
except KeyError:
continue

attach_file_if_exists(report, log, key)

if f.startswith("/usr/share/applications/") and f.endswith(".desktop"):
desktopname = os.path.splitext(os.path.basename(f))[0]
key = f"upstart.application.{desktopname}"
log = f"application-{desktopname}.log"
try:
log = os.path.join(os.environ["XDG_CACHE_HOME"], "upstart", log)
except KeyError:
try:
log = os.path.join(os.environ["HOME"], ".cache", "upstart", log)
except KeyError:
continue

attach_file_if_exists(report, log, key)
warnings.warn(
"apport.hookutils.attach_upstart_logs() is obsolete."
" Upstart is dead. Please drop this call.",
PendingDeprecationWarning,
stacklevel=2,
)


def attach_dmesg(report):
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/test_hookutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,6 @@ def test_no_crashes():
apport.hookutils.attach_conffiles(report, "bash")
apport.hookutils.attach_conffiles(report, "apport")
apport.hookutils.attach_conffiles(report, "nonexisting")
apport.hookutils.attach_upstart_overrides(report, "apport")
apport.hookutils.attach_upstart_overrides(report, "nonexisting")
apport.hookutils.attach_upstart_logs(report, "apport")
apport.hookutils.attach_upstart_logs(report, "nonexisting")
apport.hookutils.attach_default_grub(report)

def test_command_output(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/system/test_ui_gtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
+-----------------------------------------------------------------+
"""
self.app.report["ProblemType"] = "Crash"
self.app.report["ProcStatus"] = "Name:\tupstart\nPid:\t1"
self.app.report["ProcStatus"] = "Name:\tsystemd\nPid:\t1"

Check warning on line 198 in tests/system/test_ui_gtk.py

View check run for this annotation

Codecov / codecov/patch

tests/system/test_ui_gtk.py#L198

Added line #L198 was not covered by tests
GLib.idle_add(Gtk.main_quit)
self.app.ui_present_report_details(True)
self.assertTrue(self.app.w("dont_send_button").get_property("visible"))
Expand Down
2 changes: 1 addition & 1 deletion tests/system/test_ui_kde.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
def test_regular_crash_thread_layout(self):
"""A thread of execution has failed, but the application persists."""
self.app.report["ProblemType"] = "Crash"
self.app.report["ProcStatus"] = "Name:\tupstart\nPid:\t1"
self.app.report["ProcStatus"] = "Name:\tsystemd\nPid:\t1"

Check warning on line 194 in tests/system/test_ui_kde.py

View check run for this annotation

Codecov / codecov/patch

tests/system/test_ui_kde.py#L194

Added line #L194 was not covered by tests
QTimer.singleShot(0, QCoreApplication.quit)
self.app.ui_present_report_details(True)
self.assertFalse(self.app.dialog.closed_button.isVisible())
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_hookutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,10 @@ class _SkipPopen(Exception):
with self.assertRaises(_SkipPopen):
apport.hookutils.recent_syslog(re.compile("."), journald_only_system=False)
popen_mock.assert_called_once_with(cmd, stdout=unittest.mock.ANY)

def test_deprecated_upstart_functions(self) -> None:
"""attach_upstart_*() throw deprecation warnings."""
with self.assertWarns(PendingDeprecationWarning):
apport.hookutils.attach_upstart_logs({}, "apport")
with self.assertWarns(PendingDeprecationWarning):
apport.hookutils.attach_upstart_overrides({}, "nonexisting")