#!/bin/sh
cat -- "$@" - |
sed -n -e '/^Packages that were upgraded:$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^Packages that attempted to upgrade:$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^\[master [a-f0-9]\+\] committing changes in .etc /{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^Restarting services\.\.\.$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^Services being skipped:$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^Service restarts being deferred:$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^The following packages will be upgraded:$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^The following additional packages will be installed:$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^The following NEW packages will be installed:$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^The following packages will be REINSTALLED:$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -n -e '/^User sessions running outdated binaries:$/{ :a' -e 'n; /^ /ba; }; p;' | \
sed -e '/^Building format(s) --all\.$/,+1d' | \
sed -e '/^From /,/^$/d' | \
sed -e '/^-------- Uninstall Beginning --------$/,/^DKMS: uninstall completed\.$/d' | \
sed -e '/^Pending kernel upgrade!$/,/so you should consider rebooting\. \[Return\]$/d' | \
sed -e '/^Restarting services possibly affected by the upgrade:$/,/^Services restarted successfully\.$/d' | \
GREP_COLORS='mt=:sl=01;31' \
grep --color -vPC10 \
	"$(printf '%s' '
		^$|

		^Preconfiguring packages \.\.\.|
		^\(Reading database \.\.\.|
		^Reading package lists\.\.\. Done$|
		^Building dependency tree *(\.\.\.)? *(Done)?$|
		^Reading state information\.\.\. Done$|
		^Calculating upgrade\.\.\. Done$|
		^Preparing to unpack \.\.\./[^ ]+\.deb ...$|
		^Unpacking [^ ]+ \([^)]+\) \.\.\.$|
		^Unpacking [^ ]+ \([^)]+\) over \([^)]+\) \.\.\.$|
		^Replacing files in old package [^ ]+ \([^)]+\) \.\.\.$|
		^Processing triggers for [^ ]+ \([^)]+\) \.\.\.$|
		^Setting up [^ ]+ \([^)]+\) \.\.\.$|
		^Selecting previously unselected package .*\.$|
		^Removing [^ ]+ \([^)]+\) \.\.\.$|
		^Replaced by files in installed package [^ ]+ \([^)]+\) \.\.\.$|
		^(Removing|De-configuring) [^ ]+ \([^)]+\)(, to allow (removal|installation|configuration) of [^ ]+ \([^)]+\))? \.\.\.$|
		^dpkg:.*considering deconfiguration of [^ ]+, which would be broken by installation of [^ ]+ \.\.\.$|
		^dpkg:.*yes, will deconfigure [^ ]+ \(broken by [^ ]+\)$|
		^[^ ]+ is already the newest version \([^)]+\)\.$|
		^\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded\.$|
		^\d+ packages upgraded, \d+ newly installed, \d+ reinstalled, \d+ to remove and \d+ not upgraded\.$|
		^Need to get [\d,.]+ *[kMG]?B/[\d,.]+ *[kMG]?B of archives\.$|
		^Need to get [\d,.]+ *[kMG]?B of archives\. After unpacking [\d,.]+ *[kMG]?B will be used\.$|
		^After this operation, [\d,.]+ *[kMG]?B of additional disk space will be used\.$|
		^After this operation, [\d,.]+ *[kMG]?B disk space will be freed\.$|
		^Get: *\d+ https://(cdn-aws\.)?deb\.debian\.org/debian.*$|
		^Fetched [\d,.]+ *[kMG]?B in \d+min \d+s \([\d,.]+ *[kMG]?B/s\).*$|
		^Fetched [\d,.]+ *[kMG]?B in \d+s \([\d,.]+ *[kMG]?B/s\).*$|
		^Extracting templates from packages: \d+%$|
		^Leaving .diversion of .+ to .+ by [^ ]+$|
		^Removing .diversion of [^ ]+ to [^ ]+ by [^ ]+$|
		^Adding .diversion of [^ ]+ to [^ ]+ by [^ ]+$|
		^No diversion .diversion of [^ ]+ to [^ ]+ by [^ ]+., none removed\.$|
		^Performing actions\.\.\.$|
		^Press Return to continue, .q. followed by Return to quit\.$|

		^Installing new version of config file .* \.\.\.$|
		^Removing obsolete conffile .* \.\.\.$|
		^Replacing config file [^ ]+ with new version$|
		^Creating config file [^ ]+ with new version$|
		^Purging configuration files for [^ ]+ \([^ )]+\) \.\.\.$|
		^(Preparing|Finishing) transfer of config file [^ ]+ \(from [^ ]+ to [^ ]+\) \.\.\.$|
		^renamed ..*. -> ..*\.dpkg-remove.$|
		^removed ..*\.dpkg-remove.$|

		^update-alternatives: using [^ ]+ to provide [^ ]+ \([^ )]+\) in auto mode$|
		^update-alternatives: renaming [^ ]+ (slave )?link from [^ ]+ to [^ ]+$|
		^update-alternatives: updating alternative [^ ]+ because link group [^ ]+ has changed slave links$|

		^Retrieving bug reports\.\.\. Done$|
		^Parsing Found/Fixed information\.\.\. Done$|

		^apt-listchanges: Do you want to continue\? \[Y/n\] .*$|
		^Do you want to continue\? \[Y/n\] .*$|
		^apt-listchanges: Reading changelogs\.\.\.$|
		^Reading changelogs\.\.\. Done$|
		^apt-listchanges: Mailing [^:]+: apt-listchanges: news for .*$|
		^apt-listchanges: Mailing [^:]+: apt-listchanges: changelogs for .*$|

		^how-can-i-help: Unable to resolve your \$HOME directory - cannot continue\.$|
		^======  How can you help\?  \(doc: https://wiki\.debian\.org/how-can-i-help \) ======$|
		^-----  Show old opportunities as well as new ones: how-can-i-help --old  -----$|

		^Scanning processes\.\.\..*$|
		^Scanning candidates\.\.\..*$|
		^Scanning processor microcode\.\.\..*$|
		^Scanning linux images\.\.\..*$|
		^Running kernel seems to be up-to-date\.$|
		^The processor microcode seems to be up-to-date\.$|
		^No services need to be restarted\.$|
		^No containers need to be restarted\.$|
		^No user sessions are running outdated binaries\.$|
		^No VM guests are running outdated hypervisor \(qemu\) binaries on this host\.$|

		^Log started: [0-9]{4}-[0-9]{2}-[0-9]{2}  [0-9]{2}:[0-9]{2}:[0-9]{2}$|
		^Log ended: [0-9]{4}-[0-9]{2}-[0-9]{2}  [0-9]{2}:[0-9]{2}:[0-9]{2}$|
		^Unattended upgrade returned: True$|
		^Unattended upgrade result: All upgrades installed *$|
		^Unattended upgrade result: No packages found that can be upgraded$|
		^ unattended and no pending auto-removals$|
		^No packages found that can be upgraded unattended and no pending auto-removals$|
		^Calling .*apt-get.*-qq.*changelog.*=.* to retrieve changelog$|
		^Allowed origins are: .*$|
		^Packages that were upgraded:$|
		^Package installation log:$|
		^Packages (that )?were successfully auto-removed(: )?$|
		^Packages that are kept back: $|
		^All upgrades installed$|
		^Writing dpkg log to .?/var/log/unattended-upgrades/unattended-upgrades-dpkg\.log.?$|
		^Packages that will be upgraded: |
		^Allowed origins are: \[.origin=Debian., .origin=Debian.\]$|
		^Starting unattended upgrades script$|
		^Initial whitelist(| |ed packages| \(not strict\)): $|
		^Initial blacklist(| |ed packages): $|
		^Unattended-upgrades log:$|

		^update-initramfs: deferring update \(trigger activated\)$|
		^update-initramfs: Generating /boot/initrd\.img-[-_.0-9A-Za-z]+$|
		^update-initramfs: Deleting /boot/initrd\.img-[-_.0-9A-Za-z]+$|
		^/etc/kernel/post(inst|rm).d/initramfs-tools:$|
		^I: /vmlinuz(.old)? is now a symlink to boot/vmlinuz-[-_.0-9A-Za-z]+-amd64$|
		^I: /initrd.img(.old)? is now a symlink to boot/initrd.img-[-_.0-9A-Za-z]+-amd64$|

		^/etc/kernel/post(inst|rm).d/zz-update-grub:$|
		^Generating grub configuration file \.\.\.$|
		^Found (background|linux|initrd|pcmemtest|memtest86\+?)( (multiboot|x64|64bit|32bit))?( EFI)? image: .*$|

		^No grub-efi\* package found, using 4/3 as default grub background ratio$|
		^Installing for [^ ]+ platform\.|$
		^Installation finished\. No error reported\.$|
		^done$|

		^Searching for services which depend on erlang and should be (stopped|started)\.\.\. ?none found\.$|
		^Killing epmd\.\.\. *it is not running\.$|

		^Updating PPD files for [^ ]+ \.\.\.$|
		^PPD for printer [^ ]+ updated$|

		^No Gutenprint PPD files to update\.$|

		^Creating/updating [^ ]+ user account\.\.\.$|
		^Adding user [^ ]+ to group [^ ]+$|
		^usermod: no changes$|
		^addgroup: The group [^ ]+ already exists as a system group\. Exiting\.$|
		^(info: )?The system user [^ ]+ already exists\. Exiting\.$|

		^Updating symlinks in /usr/lib/ccache \.\.\.$|

		^locales-all installed, skipping locales generation$|

		^Updating GnuTLS DH parameter file$|

		^Checking for services that may need to be restarted\.\.\.$|
		^Checking init scripts\.\.\.$|

		^[^ ]+\.(service|socket|target|timer) is a disabled or a static unit( not running)?, not starting it\.$|
		^Created symlink /etc/systemd/(user|system)/[^ ]+\.socket → (/usr)?/lib/systemd/(user|system)/[^ ]+\.socket\.$|
		^Created symlink /etc/systemd/(user|system)/[^ ]+\.service → (/usr)?/lib/systemd/(user|system)/[^ ]+\.service\.$|
		^Created symlink /etc/systemd/(user|system)/[^ ]+\.timer → (/usr)?/lib/systemd/(user|system)/[^ ]+\.timer\.$|
		^Created symlink /etc/systemd/(user|system)/[^ ]+\.target\.wants/[^ ]+\.target → (/usr)?/lib/systemd/(user|system)/[^ ]+\.target\.$|
		^Created symlink /etc/systemd/(user|system)/[^ ]+\.target\.wants/[^ ]+\.service → (/usr)?/lib/systemd/(user|system)/[^ ]+\.service\.$|

		^Synchronizing state of [^ ]+\.service with SysV service script with /lib/systemd/systemd-sysv-install\.$|
		^Executing: /lib/systemd/systemd-sysv-install enable [^ ]+$|
		^Skipping starting [^ ]+\.service because [^ ]+ is running$|

		^tl-paper: setting paper size for dvips to a4: /var/lib/texmf/dvips/config/config-paper\.ps$|
		^tl-paper: setting paper size for dvipdfmx to a4: /var/lib/texmf/dvipdfmx/dvipdfmx-paper\.cfg$|
		^tl-paper: setting paper size for xdvi to a4: /var/lib/texmf/xdvi/XDvi-paper$|
		^tl-paper: setting paper size for pdftex to a4: /var/lib/texmf/tex/generic/(config|tex-ini-files)/pdftexconfig\.tex$|
		^Removing outdated pdftexconfig\.tex file in /var/lib/texmf/tex/generic/config$|
		^Running (updmap-sys|mktexlsr)\. This may take some time\.\.\. done\.$|
		^Running mktexlsr /var/lib/texmf \.\.\. done\.$|
		^Building format\(s\) --all\.$|
		^	This may take some time\.\.\. done\.$|
		^Running mktexlsr\. This may take some time\. \.\.\. done\.$|
		^texlive-base is not ready, delaying updmap-sys call$|
		^update-language: texlive-base not installed and configured, doing nothing!$|
		^texlive-base is not ready, skipping fmtutil --all call$|
		^mktexlsr: Updating /var/lib/texmf/ls-R-TEXLIVEDIST\.\.\. $|
		^mktexlsr: Updating /var/lib/texmf/ls-R-TEXMFMAIN\.\.\. $|
		^mktexlsr: Updating /var/lib/texmf/ls-R\.\.\. $|
		^mktexlsr: Done\.$|

		^System not running in EFI mode, not installing to EFI system partition.*$|
		^EFI variables are not supported on this system\.$|
		^Adding boot menu entry for UEFI Firmware Settings *\.\.\.$|

		^Current default time zone: .*$|
		^Local time is now:.*$|
		^Universal Time is now:.*$|
		^Run .dpkg-reconfigure tzdata. if you wish to change it\.$|

		^AppStream cache update completed successfully\.$|
		^✔ Metadata cache was updated successfully\.$|

		^aspell-autobuildhash: processing: [a-z]+ \[[-_0-9A-Za-z]+]\.$|
		^ispell-autobuildhash: Processing [^ ]+ dict\.$|

		^/etc/kernel/prerm\.d/dkms:$|
		^dkms: removing: .*$|
		^/etc/kernel/header_postinst\.d/dkms:$|
		^dkms: running auto installation service for kernel [-_.0-9a-z]+:?\.$|
		^Autoinstall of module [^ ]+ for kernel [^ ]+ \(x86_64\)$|
		^Autoinstall on [^ ]+ succeeded for module\(s\)( [^ ]+)+\.$|
		^/etc/kernel/postinst\.d/dkms:$|
		^Sign command: (/usr)?/lib/modules/[-_.0-9a-z]+/build/scripts/sign-file$|
		^Signing key: /var/lib/dkms/mok.key$|
		^Public certificate \(MOK\): /var/lib/dkms/mok.pub$|
		^Building module\(s\)\.\.\.( done\.)?$|
		^Building module:$|
		^Cleaning build area\.\.\.( done\.)?$|
		^make -j[0-9]+ KERNELRELEASE=[-_.0-9a-z]+( KVER=[-_.0-9a-z]+)? -C (/var/lib/dkms/|/lib/modules/)[-_.0-9a-z]+/build( M=/var/lib/dkms/[-_a-z0-9]+/[0-9.]+/build( [A-Z]+=[0-9]+)?)?\.+$|
		^Signing module /var/lib/dkms/[-_a-z0-9]+/[0-9.]+/build/([-_a-z0-9]+/)?[-_a-z0-9]+\.ko$|
		^[-_a-z0-9]+\.ko(\.xz)?:$|
		^Installing /usr/lib/modules/[-_a-z0-9]+/updates/dkms/[-_a-z0-9]+\.ko(\.xz)?$|
		^Found pre-existing /usr/lib/modules/[-_a-z0-9]+/kernel/drivers/[-_a-z0-9/]+\.ko(\.xz)?, archiving for uninstallation$|
		^Running module version sanity check\.$|
		^ - Original module$|
		^   - No original module exists within this kernel$|
		^ - Installation$|
		^   - Installing to (/usr)?/lib/modules/[-_.0-9a-z]+/updates/dkms/$|
		^(Running )?depmod\.\.\.+( done\.)?$|
		^dkms autoinstall on [-_.0-9a-z]+/x86_64 succeeded for [_a-z0-9]+( [_a-z0-9]+)*$|
		^dkms: autoinstall for kernel: [-_.0-9a-z]+\.$|

		^(intel|amd64)-microcode: microcode will be updated at next boot$|

		^Adding group `[a-z]+. \(GID \d+\) \.\.\.$|
		^Done\.$|
		^Adding system user `[a-z]+. \(UID \d+\) \.\.\.$|
		^Adding new user `[a-z]+. \(UID \d+\) with group `[a-z]+. \.\.\.$|
		^Not creating home directory `[a-z]+.\.$|

		^Setcap worked! gst-ptp-helper is not suid!$|

		^Installing Kismet with suid-root capture helper \.\.\.$|

		^Updating database of manual pages \.\.\.$|

		^Auto packing the repository in background for optimum performance\.$|
		^See "git help gc" for manual housekeeping\.$|

		^Regenerating fonts cache\.\.\. done\.$|

		^patching file /usr/.*$|
		^Reversed \(or previously applied\) patch detected!  Skipping patch\.$|
		^[0-9]+ out of [0-9]+ hunks? ignored$|

		^running (python|pypy) (pre-|post-)?rtupdate hooks for (python)?[0-9.]+?$|

		^Checking smb\.conf( with testparm)?$|
		^Load smb config files from /etc/samba/smb\.conf$|
		^Loaded services file OK\.$|
		^Server role: ROLE_STANDALONE$|
		^Done$|

		^Restarting virtual private network daemon\.:\.$|

		^\*\* initializing cache\. This may take a while \*\*$|

		^Running sa-compile \(may take a long time\)$|
		^OK, restarting spamd due to trigger$|

		^Reloading AppArmor profiles *$|

		^\* Installing [0-9]+ assembl(y|ies) from [^ ]+ into Mono$|
		^Removing [^ ]+ from Mono$|
		^Updating Mono key store$|
		^Mono Certificate Store Sync - version \d[.0-9]+$|
		^Populate Mono certificate store from a concatenated list of certificates\.$|
		^Copyright 2002, 2003 Motus Technologies\. Copyright 2004-2008 Novell\. BSD licensed.$|
		^Importing into legacy system store:$|
		^I already trust \d+, your new list has \d+$|
		^Import process completed\.$|
		^Importing into BTLS system store:$|

		^update-perl-sax-parsers: (Unr|R)egistering Perl SAX parser [^ ]+ with priority [0-9.]+\.\.\.$|
		^update-perl-sax-parsers: Updating overall Perl SAX parser modules info file\.\.\.$|

		^Sucessfully set capabilities for [^ ]+$|

		^Processing [0-9]+ (added|changed|removed) doc-base files?\.\.\.$|
		^Processing [0-9]+ (added|changed|removed) doc-base files?, [0-9]+ (added|changed|removed) doc-base files?\.\.\.$|
		^Processing [0-9]+ (added|changed|removed) doc-base files?, [0-9]+ (added|changed|removed) doc-base files?, [0-9]+ (added|changed|removed) doc-base files?\.\.\.$|

		^A reboot is required to replace the running dbus-daemon\.$|
		^Please reboot the system when convenient\.$|

		^Updating certificates in /etc/ssl/certs\.\.\.$|
		^[0-9]+ added, [0-9]+ removed; done\.$|
		^Running hooks in /etc/ca-certificates/update\.d\.\.\.$|

		^done\.?$|

		^Generating locales (this might take a while)\.\.\.$|
		^  [a-z][a-z]_[A-Z][A-Z]\.UTF-8\.\.\. done$|
		^Generation complete\.$|

		^Building PostgreSQL dictionaries from installed myspell/hunspell packages\.\.\.$|
		^  en_(au|us)$|
		^Removing obsolete dictionary files:$|

		^First installation detected\.\.\.$|
		^Checking NSS setup\.\.\.$|

		^Changing home-directory of [a-z]+ from /var/run/[a-z]+ to /run/[a-z]+$|

		^Updating /root/.(bashrc|profile) to current default\.$|
		^[0-9]+ changes? have been made, rewriting files$|
		^Writing passwd-file to /etc/passwd$|
		^Writing shadow-file to /etc/shadow$|
		^Writing group-file to /etc/group$|

		^setting xserver-xorg-legacy/xwrapper/allowed_users from configuration file$|

		^setup in directory /etc/dnssec-trigger$|
		^dnssec_trigger_server\.key exists$|
		^dnssec_trigger_control\.key exists$|
		^dnssec_trigger_server\.pem exists$|
		^dnssec_trigger_control\.pem already exists$|
		^Setup success\. Certificates created\.$|
		^run this script again with -i to:$|
		^.- enable remote-control in unbound\.conf$|
		^.- start unbound-control-setup$|
		^.- add root trust anchor to unbound\.conf$|
		^if you have not done this already$|

		^[-a-z0-9]+: broken-symlink /etc/sv/[a-z]+(/log)?/supervise -> /run/runit/supervise/[a-z]+(\.log)?$|

		^Remove [^ ]+ for emacs$|
		^remove/[^: /]+: Purging byte-compiled files for flavour emacs$|
		^(remove/)?[^: /]+: Handling removal of emacsen flavor emacs$|
		^[^: ]+: purging flavor specific files for emacs$|
		^Install [^ ]+ for emacs$|
		^install/[^: ]+: Byte-compiling for emacsen flavour emacs$|
		^(install/)?[^: ]+: Handling install of emacsen flavor emacs$|
		^install/[^: ]+: byte-compiling for emacs$|

		^SQLITE3? has been deleted \(if it existed at all\) because its usage count became zero$|
		^odbcinst: Driver installed\. Usage count increased to [0-9]+\. *$|
		^ *Target directory is /etc$|

		^Removing handled symlink for </bin/ntfs-3g>$|
		^Creating compatibility symlink for </bin/ntfs-3g>$|

		^(W|Warning): /bin resolved to a different inode than /usr/bin$|
		^(W|Warning): Unmerged usr is no longer supported, use usrmerge to convert to a merged-usr system\.$|
		^(N|Notice): See https://www\.debian\.org/releases/[^/]+/[^/]+/release-notes/ch-information\.en\.html#a-merged-usr-is-now-required for more details\.$|

		^/var/lib/smartmontools/drivedb/drivedb\.h [0-9]\.[0-9]/[0-9]+ is already up to date \(NOT VERIFIED\)$
	' sed '/^#/d' | tr -d '\t\n')"
