[Merge] ~cpete/ubuntu/+source/apport:updated-subiquity-hook into ~ubuntu-core-dev/ubuntu/+source/apport:ubuntu/devel
Benjamin Drung
mp+454563 at code.launchpad.net
Mon Nov 20 16:58:56 UTC 2023
Diff comments:
> diff --git a/debian/package-hooks/subiquity.py b/debian/package-hooks/subiquity.py
> index 948a8e7..2b976df 100644
> --- a/debian/package-hooks/subiquity.py
> +++ b/debian/package-hooks/subiquity.py
> @@ -1,51 +1,114 @@
> -"""Send reports about subiquity to the correct Launchpad project."""
> +'''
Please format the code with black.
> +Send reports about subiquity to the correct Launchpad project.
> +
> +'''
> import os
> +import re
>
> from apport import hookutils
>
>
> -def add_info(report, unused_ui):
> - """Send reports about subiquity to the correct Launchpad project."""
> - # TODO: read the version from the log file?
> - logfile = os.path.realpath("/var/log/installer/subiquity-debug.log")
> - revision = "unknown"
> - if os.path.exists(logfile):
> - hookutils.attach_file(report, "logfile", "InstallerLog")
> - with open(logfile, encoding="utf-8") as log_fp:
> - first_line = log_fp.readline()
> - marker = "Starting Subiquity revision"
> - if marker in first_line:
> - revision = first_line.split(marker)[1].strip()
> - report["Package"] = f"subiquity ({revision})"
> - report["SourcePackage"] = "subiquity"
> +def add_info(report, ui):
> + # Get subiquity version from log file
> + logfile = os.path.realpath('/var/log/installer/subiquity-server-debug.log')
> + log_contents = hookutils.read_file(logfile)
> + first_line = log_contents[0]
> + marker = 'Starting Subiquity server revision'
> + if marker in first_line:
> + revision = first_line.split(marker)[1].strip()
> + else:
> + revision = 'unknown'
> +
> + report['Package'] = f'subiquity ({revision})'
> + report['SourcePackage'] = 'subiquity'
> # rewrite this section so the report goes to the project in Launchpad
> - report[
> - "CrashDB"
> - ] = """\
> -{
> - "impl": "launchpad",
> - "project": "subiquity",
> - "bug_pattern_url": "http://people.canonical.com/"
> - "~ubuntu-archive/bugpatterns/bugpatterns.xml",
> -}
> -"""
> -
> - # add in subiquity stuff
> - hookutils.attach_file_if_exists(
> - report, "/var/log/installer/subiquity-curtin-install.conf", "CurtinConfig"
> - )
> - hookutils.attach_file_if_exists(
> - report, "/var/log/installer/curtin-install.log", "CurtinLog"
> - )
> - hookutils.attach_file_if_exists(
> - report, "/var/log/installer/block/probe-data.json", "ProbeData"
> + report['CrashDB'] = '''{
> + "impl": "launchpad",
> + "project": "subiquity",
> + "bug_pattern_url": "http://people.canonical.com/~ubuntu-archive/bugpatterns/bugpatterns.xml"
> + }'''
> +
> + # Check if the snap was updated
> + report['SnapUpdated'] = str(os.path.exists('/run/subiquity/updating'))
> +
> + # add in hardware information
> + hookutils.attach_hardware(report)
> +
> + # static subiquity generated logs
> + log_map = [
Why don't you use a dict for that?
> + (
> + os.path.realpath('/var/log/installer/subiquity-server-debug.log'),
> + 'InstallerServerLog'
> + ),
> + (
> + os.path.realpath('/var/log/installer/subiquity-server-info.log'),
> + 'InstallerServerLogInfo'
> + ),
> + (
> + os.path.realpath('/var/log/installer/subiquity-client-debug.log'),
> + 'InstallerClientLog'
> + ),
> + (
> + os.path.realpath('/var/log/installer/subiquity-client-info.log'),
> + 'InstallerClientLogInfo'
> + ),
> + (
> + '/var/log/installer/curtin-install.log',
> + 'CurtinLog'
> + ),
> + (
> + 'var/log/installer/curtin-install/subiquity-curtin-apt.conf',
> + 'CurtinAptConfig'
> + ),
> + (
> + '/var/log/installer/curtin-install/subiquity-curthooks.conf',
> + 'CurtinCurthooksConfig'
> + ),
> + (
> + '/var/log/installer/curtin-install/subiquity-extract.conf',
> + 'CurtinExtractConfig'
> + ),
> + (
> + '/var/log/installer/curtin-install/subiquity-initial.conf',
> + 'CurtinInitialConfig'
> + ),
> + (
> + '/var/log/installer/curtin-install/subiquity-partitioning.conf',
> + 'CurtinPartitioningConfig'
> + ),
> + (
> + '/var/log/installer/block/probe-data.json',
> + 'ProbeData'
> + ),
> + (
> + '/var/log/installer/subiquity-traceback.txt',
> + 'Traceback'
> + ),
> +
> + ]
> +
> + # Add in netplan config - should be one or the other
> + netplan_log = '/etc/netplan/00-installer-config.yaml'
> + if not os.path.exists(netplan_log):
> + netplan_log = '/etc/netplan/00-snapd-config.yaml'
> + log_map.append((netplan_log, 'NetplanConfig'))
> +
> + # Add journal log - from the installer if it exists or from the system
> + if "InstallerJournal" not in report:
> + installer_journal = '/var/log/installer/installer-journal.txt'
> + if os.path.exists(installer_journal):
> + log_map.append((installer_journal, 'InstallerJournal'))
> + else:
> + report['SystemJournal'] = hookutils.recent_syslog(re.compile("."))
> +
> + # Avoid adding udi log when symlink is incorrectly set
> + UdiLog = os.path.realpath(
> + '/var/log/installer/ubuntu_desktop_installer.log'
> )
> + if os.path.exists(UdiLog):
> + log_map.append((UdiLog, 'UdiLog'))
> +
> + # Attach logs if they exist
> + for (file, name) in log_map:
> + hookutils.attach_file_if_exists(report, file, name)
>
> - # collect desktop installer details if available
> - desktoplog = os.path.realpath("/var/log/installer/ubuntu_desktop_installer.log")
> - if os.path.exists(desktoplog):
> - hookutils.attach_file(report, desktoplog, "DesktopInstallerLog")
> - report.add_tags(["ubuntu-desktop-installer"])
> - snapdir = os.path.realpath("/snap/ubuntu-desktop-installer/current")
> - if os.path.exists(snapdir):
> - report["DesktopInstallerRev"] = os.path.basename(snapdir)
--
https://code.launchpad.net/~cpete/ubuntu/+source/apport/+git/apport/+merge/454563
Your team Ubuntu Core Development Team is subscribed to branch ~ubuntu-core-dev/ubuntu/+source/apport:ubuntu/devel.
More information about the Ubuntu-reviews
mailing list