rpm: How to list packages installed/upgraded today

If you’re using rpm-based Linux distro you may find this tip useful: if you want to list all packages installed or upgraded today (and by “today” I mean the current “today”, i.e. not hardcoded 2013/12/14, but the present time), just copy & paste the following snippet to the console window (this is ONE line!):

rpm -qa --qf '%{NAME} %{INSTALLTIME}\n' | perl -nale '($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($F[1]);($Nsec,$Nmin,$Nhour,$Nmday,$Nmon,$Nyear,$Nwday,$Nyday,$Nisdst)=localtime(time);print $F[0] if ($year==$Nyear && $mon==$Nmon && $mday==$Nmday)'

Here is how it works: we list all packages in a format “packagename installtime”. “installtime” is in a common Unix/Linux format: it is a number of seconds after a date called “epoch”. To convert it to something more readable/useful we can use perl and its function localtime, which converts it to an array of numbers of various meaning (like elements of the date: year, month, day, etc.). localtime(time) returns, on the other hand, the same data, but for the present time. So we just compare these two sets of values and if they match – we print the package name. Easy, isn’t it? 😉

Chroot 32-bit + Skype + PulseAudio = problems (solved!)

I recently was struggling a little bit with running Skype in my distro. The problem was that I had to configure chroot environment (because my native OS is 64-bit and Skype is a 32-bit application), and then also solve some problems with PulseAudio to get sound.

OK, so here are my findings and some useful shell scripts. First, we have to make sure that all important pieces of native system are also available in chrooted environment. Hence chroot_mount.sh script:

#!/bin/sh -x

cp -L /etc/resolv.conf $CHROOTPATH/etc/
mount --bind /dev $CHROOTPATH/dev
mount --bind /dev/pts $CHROOTPATH/dev/pts
mount --bind /dev/shm $CHROOTPATH/dev/shm
mount --bind /tmp $CHROOTPATH/tmp
mount -t proc proc $CHROOTPATH/proc
mount -t sysfs none $CHROOTPATH/sys
mount --bind /var/lib/dbus $CHROOTPATH/var/lib/dbus
mount --bind /var/run/dbus $CHROOTPATH/var/run/dbus
mount --bind /run/udev $CHROOTPATH/run/udev
mount --bind /home $CHROOTPATH/home

Run it from root. (Obviously, you have to create /mychroot dir earlier and install there base system. This part is out of scope of this blog post.)

After using your chrooted environment you may also want to umount all resources. Hence chroot_umount.sh script:

#!/bin/sh -x

umount $CHROOTPATH/dev/pts
umount $CHROOTPATH/dev/shm
umount $CHROOTPATH/dev
umount $CHROOTPATH/tmp
umount $CHROOTPATH/proc
umount $CHROOTPATH/sys
umount $CHROOTPATH/home
umount $CHROOTPATH/var/lib/dbus
umount $CHROOTPATH/var/run/dbus
umount $CHROOTPATH/run/udev

Then you have to configure PulseAudio so it can be used from different user than logged in (I prefer to run closed-source apps, like Skype, from a separate account.) Here is my ~/.pulse/default.pa file on main account:

load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore
load-module module-augment-properties
.ifexists module-udev-detect.so
load-module module-udev-detect
load-module module-detect
.ifexists module-jackdbus-detect.so
load-module module-jackdbus-detect
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
load-module module-native-protocol-unix
.ifexists module-gconf.so
load-module module-gconf
load-module module-default-device-restore
load-module module-rescue-streams
load-module module-always-sink
load-module module-intended-roles
load-module module-suspend-on-idle
.ifexists module-console-kit.so
load-module module-console-kit
.ifexists module-systemd-login.so
load-module module-systemd-login
load-module module-position-event-sounds
load-module module-role-cork
load-module module-filter-heuristics
load-module module-filter-apply
.ifexists module-dbus-protocol.so
load-module module-dbus-protocol
load-module module-switch-on-port-available
load-module module-native-protocol-tcp auth-ip-acl=

On the secondary account I have only this in ~/.pulse/client.conf file:

default-server =

Also I have skype-wrapper.sh there in the PATH:

#!/bin/sh -x

Why it is needed? Well, without first line (export PULSE_SERVER= there was no sound and paplay always was saying Connection refused. Read PulseAudio’s FAQ about details how do the PulseAudio libraries decide where to connect to.

The second line (PULSE_LATENCY_MSEC=60 skype) was/is important to work around the bug in Skype that was adding some “funny” effects, like no sound at all or only some noises. Read this post from PulseAudio developer to learn more. I experienced these problems with PulseAudio 4.0 and Skype This line works like a charm and all works OK.

OK, now when everything is configured (remember also to install and configure dchroot) you can run 32-bit Skype on a separate account by only running this command on your main account:
$ su -c 'dchroot -d skype-wrapper.sh' - user2
where “user2” is your secondary account.
You can make it an alias or put it in a one-line shell script to save some typing each time when you want to run Skype.