Wandering Thoughts archives


Comparing RPM versions in the shell

Via Planet Debian I recently read Comparing version numbers in the shell, which sort of suggests using sort -V to compare package version numbers on RPM-derived systems. My reaction to this is kind of mixed, because how good an idea this is depends on what you're trying to do with this comparison.

If you just want to compare generic version numbers, 'sort -V' may do what you want. You should read the coreutils documentation for sort very carefully, especially Details about version sort, because how it works may not be quite what you expect or what you want. You probably want to test it.

If you want to compare version numbers in the same way that RPM does it, so that your idea of a 'newer version' specifically matches what eg 'rpm -U' or 'yum localupdate' would conclude, you should use the rpmdev-vercmp command (it's part of the rpmdevtools package). This uses RPM's actual version comparison code (as exposed through the RPM Python bindings). See 'rpmdev-vercmp -h' for basic usage and then experiment with it; note that it prints output and has somewhat odd status returns. You may also want to see 'rpmdev-sort'.

(If you just care about version numbers, you can ignore the epoch and the release parts of ordinary RPM version numbering; rpmdev-vercmp doesn't require you to supply them.)

If you want to compare the versions of actual RPM packages as rpm and yum do it, you really have to use rpmdev-vercmp and you need to extract full RPM version information about both packages, including their RPM epochs if any. It's a pity that there is no easy command to print out the full version information that rpmdev-vercmp requires (it's a bit complex and annoying for reasons covered here, although for most purposes you can apparently consider a missing epoch number to be equal to an epoch number of '0').

As it turns out, the best approximation of quickly printing out full RPM version information for rpmdev-vercmp purposes is something like:

rpm -q --qf '%{N} %{epochnum}:%{V}-%{R}\n' ...

Note that you should not accidentally give rpmdev-vercmp strings that have the package name in them; it will consider them to be the version and then interpret the version number as the first part of the release numbering (I think).

(I discovered rpmdev-vercmp via this stackoverflow question and its answer when I was researching this entry. Once again writing blog entries has proven usefully educational.)

linux/RPMShellVersionComparison written at 22:38:58; Add Comment

My .screenrc

Recently, Wesley David put out a call for people to share their .screenrc files, even if they aren't particularly exciting. I am a regular but not heavy user of screen and have been for years now, so I have fixed opinions (and well-worn reflexes) but not very much cleverness.

So, here are bits of my .screenrc, annotated with comments.

The most important setting for me is the simplest:

escape ^_a

This makes the screen escape character into what I consider something sane and sensible. Here 'sane and sensible' really means 'so uncommon that basically nothing else uses it'. Almost all control characters are heavily used because there's only so many of them, but ^_ is just uncommon enough that I only rarely run into collisions.

(Back in the days of real terminals there was often somewhat of an adventure in figuring out how to generate a ^_ on a new terminal.)


bell_msg "Bell is present in window % (go look at it!)"
msgwait 30

One reason I have things set this is way is xterm's ziconbeep feature. If I run screen in an xterm, any ^G in any screen will produce a message and thus trigger ziconbeep, drawing my attention to that overall screen session.

Then I have some boring settings:

defscrollback 1000
startup_message off
multiuser off
autodetach on

(The latter two settings are theoretically the default, so mentioning them explicitly is paranoia. But I'm a sysadmin. Paranoia runs deep.)

If you're running screen in an xterm, screen normally puts its 'hardstatus' line in the xterm's titlebar. Because my xterms don't have title bars, I thus need to disable this, which I do by basically turning off hardstatus in xterms:

termcapinfo xterm* LP:hs@

My taste is to not have individual screen 'windows' be present in 'who' output and so on, for reasons that are pretty much historical at this point. So I have:

deflogin off
bind U login off
bind L login on

To be honest I don't think I've used those keybindings for a very long time. I might as well leave them there; after all, someday I may them.

There is one keybinding I use all the time:

bind - prev

One reason this binding is so useful and efficient for me is that it shares a physical keyboard key with ^_, making it very quick to invoke without shifting my fingers (I just lift my left fingers off the control and shift keys). I use 'space' to cycle forwards through screen windows, which is similarly easy to hit rapidly (the spacebar is a big target).

These days I run very boring things inside screen so I basically don't auto-start anything much. Most places I start out with one shell just sitting there:

screen 0

(My .screenrc also has comments about most of this, which has been very helpful in remembering enough about why I have these mysterious settings to be able to write this entry.)

As a side note on the great screen versus tmux debate: I don't do anything sophisticated or fancy with screen and I already know how to do things with it. Thus I currently see no reason to try to switch. In general I don't dp sophisticated stuff in screen in general; that's what multiple xterm windows are for. Screen is for unusual situations when I need something to persist and one instance for monitoring stuff on my office workstation when I'm at home (and even that is increasingly historical).

sysadmin/MyScreenrc written at 00:43:08; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.