#!/usr/bin/perl # Script to print out why Jaunty or Koala aren't launching # the Update Manager when non-security updates are available. use strict; use warnings; use POSIX; sub numeric { my $ma = $a; my $mb = $b; $ma =~ s/\D.*$//; $mb =~ s/\D.*$//; return $ma <=> $mb; } sub auto_launch_new { my $num_normal; my $num_security; ($num_normal, $num_security) = split(";", `/usr/lib/update-notifier/apt-check 2>&1`); print "$num_normal normal updates, $num_security security updates available\n"; my $interval_days = `gconftool-2 -g /apps/update-notifier/regular_auto_launch_interval`; chomp($interval_days); print "interval_days from gconf: $interval_days\n"; if ($interval_days <= 0) { return "not yet because interval_days $interval_days <= 0\n"; } my $last_launch = `gconftool-2 -g /apps/update-manager/launch_time`; chomp($last_launch); my $clast_launch = POSIX::ctime($last_launch); chomp($clast_launch); print "last_launch from gconf: $last_launch, $clast_launch\n"; my $now = POSIX::time(); if ($num_security > 0) { my $AUTOLAUNCH_MINIMAL_SECURITY_INTERVAL = 12*60*60; if (($last_launch + $AUTOLAUNCH_MINIMAL_SECURITY_INTERVAL) < $now) { return "would run! security updates, update manager would auto-launch!"; } print "security updates, but update-manager was launched within the AUTOLAUNCH_MINIMAL_SECURITY_INTERVAL\n"; } my @times; push(@times, "$last_launch, last_launch"); my $dev; my $ino; my $mode; my $nlink; my $uid; my $gid; my $rdev; my $size; my $atime; my $mtime; my $ctime; my $blksize; my $blocks; my $log; foreach $log ("/var/log/dpkg.log", "/var/log/apt/term.log") { ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks) = stat($log); chomp($ctime); chomp($mtime); push(@times, "$mtime,mtime $log; size $size"); print "mtime from $log: $mtime ".POSIX::ctime($mtime); push(@times, "$ctime,ctime $log; size $size"); print "ctime from $log: $ctime ".POSIX::ctime($ctime); print "size of $log: $size\n"; } @times = sort numeric @times; my $latest = $times[-1]; my $nlatest = $latest; $nlatest =~ s/\D.*$//; print "latest previous update: $latest\n"; my $delta = $now - $nlatest; my $cnow = POSIX::ctime($now); chomp($cnow); print "time now $now $cnow, delta $delta\n"; print "It's been ".($delta/(60*60*24)). " days since last update.\n"; if (($nlatest + 24*60*60*$interval_days) < $now) { return "would run! Even for non-security updates, it's time to update."; } return "not yet. It thinks there has already been an update within the last $interval_days days ($latest)."; } my $distro = `lsb_release -c`; chomp($distro); $distro =~ s/Codename:\s*//; if ($distro =~ /.|jaunty|koala/) { print "Distro $distro\n"; # Check for individual bugs # bug that keeps you from seeing any updates at all if (-f "/etc/cron.daily/apt" && ! -x "/etc/cron.daily/apt" ) { print "But /etc/cron.daily/apt is not executable! Please report this by adding a comment to \ https://bugs.launchpad.net/ubuntu/+source/update-notifier/+bug/356152.\n"; } # bug that causes update-notifier-kde to crash? if (-f "/usr/share/pyshared/update-notifier-kde/update-notifier-kde.py") { print "You may be suffering from https://bugs.launchpad.net/ubuntu/+source/update-notifier-kde/+bug/391731" } # Kind of unrelated, but might hinder autoupdate, who knows my $eth = `lspci | grep eth`; chomp($eth); if ($eth =~ /Broadcom|Attansic/) { print "You have a Broadcom or Attansic ethernet card. If you see 'Corrupted MAC' errors from ssh, see \ https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.17/+bug/60764\n"; } # Show whether update-notifier would fire. print "Autolaunch ".auto_launch_new()."\n"; } else { print "Sorry, $distro not supported.\n"; }