You are not logged in.

#1 2012-03-21 07:41:50

ebal
Member
From: Athens, Greece
Registered: 2009-05-26
Posts: 224
Website

pacman sort packages

Is there an option to sort packages via installation date ?

i can see all the details with

pacman -Qi

but i cant find a way to sort them up



In a paranoid moment i wrote this:

pacman -Qi | grep -E '^Name|^Install Date' | awk -F":" '{print $2}' | sed '0~1s/$/ - /g' | sed '0~2s/ - $/#/g' | tr '\n' ' ' | sed 's/#/\n/g' | sort -k2 -d

https://balaskas.gr
Linux System Engineer - Registered Linux User #420129

Offline

#2 2012-03-21 08:02:08

Gcool
Member
Registered: 2011-08-16
Posts: 1,456

Re: pacman sort packages

Pacman doesn't have any built in sorting option that I know of. But that's why we have creative bash scripting as you did smile


Burninate!

Offline

#3 2012-03-21 08:05:56

ebal
Member
From: Athens, Greece
Registered: 2009-05-26
Posts: 224
Website

Re: pacman sort packages

So the right way, is to open a bug feature request.


https://balaskas.gr
Linux System Engineer - Registered Linux User #420129

Offline

#4 2012-03-21 08:44:30

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: pacman sort packages

ebal wrote:

So the right way, is to open a bug feature request.

You can try. Allan likes to keep things as simple as possible.

Last edited by /dev/zero (2012-03-21 09:28:56)

Offline

#5 2012-03-21 09:53:08

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,384
Website

Re: pacman sort packages

I don't reject all ideas (that is Dan's job), but that one might be very low on my willingness to include scale  big_smile

Look into whether expac can do this...

Offline

#6 2012-03-21 10:01:56

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,354

Re: pacman sort packages

/dev/zero wrote:
ebal wrote:

So the right way, is to open a bug feature request.

You can try. Allan likes to keep things as simple as possible.

Hey /dev/zero, try not to blank what you've previously written, its bad manners smile. Not that it matters very much in this case, but unless the code you previously put up there was machine-killing, no real reason to remove it.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#7 2012-03-21 11:25:22

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

Re: pacman sort packages

Install pyalpm to use this. It will print the installed packaged sorted by installation date.

#!/usr/bin/env python3
from pycman.config import init_with_config

h = init_with_config("/etc/pacman.conf")
for p in sorted(h.get_localdb().pkgcache, key=lambda x: x.installdate):
  print(p.name)

Either edit the loop to print more info directly, or pass the output to pacman to use the standard output format:

pacman -Qi $(./script.py)

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

Offline

#8 2012-03-21 18:46:48

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: pacman sort packages

ngoonee wrote:

Hey /dev/zero, try not to blank what you've previously written, its bad manners smile. Not that it matters very much in this case, but unless the code you previously put up there was machine-killing, no real reason to remove it.

I apologise. It was broken. I'd like a chance to fix it, but it was too late at night to do it straight away.

Offline

#9 2012-03-21 23:28:59

/dev/zero
Member
From: Melbourne, Australia
Registered: 2011-10-20
Posts: 1,247

Re: pacman sort packages

ebal wrote:
pacman -Qi | grep -E '^Name|^Install Date' | awk -F":" '{print $2}' | sed '0~1s/$/ - /g' | sed '0~2s/ - $/#/g' | tr '\n' ' ' | sed 's/#/\n/g' | sort -k2 -d

Okay, I have something that seems to work okay. It outputs the same information, but I'd argue the underlying code is a bit nicer. It's structured in a more logical way that should make it easier to modify, eg with additional fields from "pacman -Qi".

#! /bin/bash
function pacfield() {
    pacman -Qi | awk -vF="$@" -F':' 'BEGIN{p="^"F} $0~p{print $2}'
}
pr -tm <(pacfield Name) <(date --file=<(pacfield "Install Date") +%F) | sort -k2 -d

Offline

Board footer

Powered by FluxBB