You are not logged in.

#1 2008-08-19 22:44:22

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

A script to show package install dates.

This is just a simple perl script that will spit out a list of all of your installed packages in the order that they were installed along with their installation date. This might be useful if you notice that something has been behaving strangely for a few days and you want to check if a package upgrade coincides with when this started, or if you installed a bunch of packages the other day to test something and just can't remember which. This beats digging through the log (and doesn't rely on it either, in case you've cleaned up your log files).

Save it as pkgInstallDateLister (or whatever you feel like calling it) and make it executable.

It just does a simple "pacman -Q" query then pulls the %INSTALLDATE% out of the desc file for each package. You can pass it other pacman query flags too, e.g.

pkgInstallDateLister --explicit
pkgInstallDateLister -s xorg

Example of output from last command:

xorg-font-utils-1.0.3-3         2008-06-19 11:03:58
xorg-fonts-alias-1.0.1-1        2008-06-19 11:03:58
xorg-fonts-encodings-1.0.2-2    2008-06-19 11:03:58
xorg-fonts-misc-1.0.0-3         2008-06-19 11:03:58
xorg-fonts-100dpi-1.0.1-1       2008-06-19 11:07:14
xorg-fonts-75dpi-1.0.1-2        2008-06-19 11:07:18
xorg-apps-1.0.3-3               2008-06-19 11:07:22
xorg-res-utils-1.0.3-2          2008-06-19 11:07:22
xorg-server-1.4.2-1             2008-06-23 09:25:00
xorg-server-utils-7.3-1         2008-06-23 09:25:00
xorg-utils-7.3-1                2008-06-23 09:25:00
xorg-xinit-1.1.0-1              2008-06-23 09:25:00
xorg-twm-1.0.4-1                2008-07-07 22:02:45
xorg-xauth-1.0.3-1              2008-07-07 22:02:45
xorg-xkb-utils-7.3-1            2008-07-07 22:02:45

The Script

#! /usr/bin/perl
use strict;
use warnings;

my $db_path = '/var/lib/pacman/local/';
my $args = "@ARGV";
my $pkgs = `LC_ALL=C pacman -Qi $args`;
if ($pkgs !~ m/^Name/)
{
    $args = '';
    my @lines = split /\n/,$pkgs;
    foreach my $line (@lines)
    {
        if ($line =~ m/^\S+?\/(\S+)/)
        {
            $args .= "$1 ";
        }
    }
    $pkgs = `LC_ALL=C pacman -Qi $args`;
}
my @pkgs = split /\n\n/, $pkgs;
my %pkg_hash;
my %month_hash;
@month_hash{qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/} = (1..12);
my $greatest_length = 0;
foreach my $pkg (@pkgs)
{
    my ($name,$ver,$instdate) = $pkg =~ m/Name\s+:\s+(\S+).+?Version\s+:\s+(\S+).+?Install Date\s+:\s+([^\n]+)\n/s;
    my ($month,$date,$hms,$year) = $instdate =~ m/^\S+\s+(\S+)\s+(\d+)\s+(\S+)\s+(\S+)\s*$/;
    my $pkg_name = "$name-$ver";
    my $name_length = length($pkg_name);
    $greatest_length = $name_length if ($name_length > $greatest_length);
    my $timestamp = sprintf "%s-%02d-%02d %8s",$year,$month_hash{$month},$date,$hms;
    $pkg_hash{$pkg_name} = $timestamp;
}
foreach (sort {$pkg_hash{$a} cmp $pkg_hash{$b}} sort keys %pkg_hash)
{
    printf "%-${greatest_length}s     %s\n",$_,$pkg_hash{$_};
}

Last edited by Xyne (2008-08-20 21:37:59)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#2 2008-08-20 08:57:46

wain
Member
From: France
Registered: 2005-05-01
Posts: 289
Website

Re: A script to show package install dates.

awesome cool

I've just commit the same feature yesterday in yaourt-git:

$ yaourt -Q --date
==> List last installed packages
....
09:08:29 18/08/2008: extra/bash-completion 20060301-9
09:15:34 18/08/2008: core/gpm 1.20.5-1
09:15:34 18/08/2008: core/libelf 0.8.10-3
09:15:35 18/08/2008: extra/screen 4.0.3-5
09:50:44 19/08/2008: local/yaourt-git 20080819_0950-1
12:11:51 19/08/2008: extra/latex2html 2002.2-1

Offline

#3 2008-08-20 11:29:37

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: A script to show package install dates.

A possible implementation issue :
http://projects.archlinux.org/?p=pacman … 3f7c9d6804

That is, the old date entries are in string format, the new one are in unix epoch format.
pacman handles both cases with the above commit, so you might want to just reuse pacman :

LC_ALL=C pacman -Qi $@ | grep "Install Date"

pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#4 2008-08-20 21:44:35

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: A script to show package install dates.

shining wrote:

A possible implementation issue :
http://projects.archlinux.org/?p=pacman … 3f7c9d6804

That is, the old date entries are in string format, the new one are in unix epoch format.
pacman handles both cases with the above commit, so you might want to just reuse pacman :

LC_ALL=C pacman -Qi $@ | grep "Install Date"

Ok, I've changed the script, thanks for the suggestion (and for sending me off to Google to figure out what LC_ALL=C was doing).


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB