On Sat, 19 Nov 2011 11:16:36 +0200
"Eugene V. Lyubimkin" <jac...@debian.org> wrote:

> > Note:  Why 'cupt' and not 'dpkg'?  Ideally 'dpkg' ought to store the
> > installation date, but a review of the 'dpkg' bug list shows its
> > cautious maintainers can be slow to change things:
> 
> That's true. However, that's not a good reason to break layering.

Agreed.

So far no packages are layered upon 'cupt'.  Creating new 'cupt' data
fields somewhere in '/var/lib/cupt/lists' would be less risky.

> Regarding the use-case, indeed it's not possible to 'sort by
> installation date', but logs should be enough to remember what
> program(s) was/were installed recently. Specifically, Cupt logs store
> all package changes (done by libcupt) for 2 years by default, and logs
> can be either read by human or a specific log parser. By some point of
> view, the logs is the database.

There's a lot of data in '/var/log/dpkg.log*':  fields like "Package:",
"Status:", and "Version:", could each be derived from the logs.  Of
course I'd rather study from a lengthy technical book with a good
index, than an abridged edition without an index. 

I've been toying with some date extraction code for 'dpkg.log'.
Make a list of log derived install times: 

        OUT1=/tmp/loglist_dpkg.txt
        OUT2=/tmp/install_times.txt

        # create one big log file, of lines containing  'status installed'.
        % zgrep '.*' `ls /var/log/dpkg.log* | sort -Vr` | tac | \
        grep 'status installed' > $OUT1
        
        # In that file, find the first instance of each package name,
        # then output it to another file; date first, then package name.
        % for f in `dglob` ; do grep --max-count=1 " $f " $OUT1 ; done | \
        sed -n 'h;s/ [^ ]*$//;s/.* //;x;s/^[^:]*://;s/ stat.*//;G;s/\n/ /p' > 
$OUT2
        
        # view packages sorted by (logged) installation date
        % sort -g $OUT2 | less

(The code needn't check for packages later removed, since the
'dglob' command lists only currently installed packages.)

My Debian system's been going since the late '90s, with several hardware
upgrades. One problem with that log code above is it won't list any
packages installed before 'dpkg' logging existed (3/2/09).  

        # count 'dpkg.log' installs
        % wc -l < $OUT2
        2649

        # count installed packages.
        % dglob  | wc -l
        3812

That's a lot of old packages.  Generating pre 3/2/09 install times
would be less exact.  My file system ought to have had earliest modify
times for files contained in older packages, but unfortunately I've
changed file systems over the years, at times using some variant of
'cp', which updated the modify times. But it's still possible to narrow
the date ranges. For example, since virtually all packages have
changelogs, the latest date in the changelog is always earlier that the
install time.

(Come to think of it, a "first installed" field might be useful too.
Then a user could check which packages have been around locally the
longest.)

HTH...



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to