Monday, October 15, 2012

Reverse chronological package installs in OS X

pkgutil --pkgs | xargs -n 1 pkgutil --pkg-info | gawk '{printf("%s%s",$0,(NR%5==0)?"\n":"\0")}' | sort -n -k 6 | tr "\0" "\n" | gawk '/install-time/ {print $0 " " strftime("(%c)",$2); next}{print}'

Wednesday, October 3, 2012

Time(less) machine

Geez, I hate upgrading OSs.  No one gets it right, and we all collectively spend inordinate amounts of time dealing with the fallout.  Think of all the time (read: money) wasted on such headaches.  Most recently for me, the Time Machine backup program broke on an upgrade to 10.7.5.  Backups were estimated to have MAX_INT hours remaining.  It appears there is a conflict between Spotlight and Time Machine -- two programs from the same vendor.  One has to disable Spotlight via
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
and the run Time Machine. One might also have to reboot between the two.  After Time Machine runs, re-enable with
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
Running a dtruss on the backupd process shows a lot of
psynch_cvwait(0x7FE29969CE98, 0x28D0100028E00, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x28F0100029000, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2900100029100, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2910100029200, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2920100029300, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2930100029400, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2950100029600, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2960100029700, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2980100029900, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x29A0100029B00, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x29B0100029C00, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2940100029500, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2970100029800, 0x0)   = -1 Err#316
psynch_cvwait(0x7FE29969CE98, 0x2990100029A00, 0x0)   = -1 Err#316
So, there appears to be a threading issue here somewhere, but without the Time Machine source, it's difficult to track down.

Updates.  Doing a "sudo mdutil -i off /" appears to do approximately the same thing as the launchctl, but immediately, though I'm not convinced it's exactly the same thing.  And it appears one of Apple's recent updates fixed the problem -- let's hope they added a regression test for this.