Comparing text strings

Rich Shepard rshepard at appl-ecosys.com
Mon Apr 12 22:11:24 EDT 2021


On Tue, 13 Apr 2021, Cameron Simpson wrote:

> I do not know if there are preexisting modules/tools for this, but I
> recommend looking at slackware's package management tool - they usually
> have some kind of 'clean" operation to purge "old" package install files.
> Sometimes that purges all the install files, not just the obsolete ones,
> so take care.

Cameron,

slackpkg clean removes all non-core distribution files. That's how I FUBAR'd
my system a couple of months ago.

> If you're writing a script, what you want to do is read the names and
> extract the version information from them, and also the "package name" -
> the bit which identifies the package and does not change with an upgrade.

Yes, that's the approach I would take.

> I would then make a dict mapping package names to a list of versions
> and/or the full "...tgz" names above. (Actually, use a
> defaultdict(list), it will avoid a lot of tedious mucking about.)

Okay. That didn't occur to me.

> Alternatively, and now that I think about it, more simply: _if_ the
> package files can be sorted by version, then all you need to do is read a
> sorted listing and note that latest fil for a particular package. If you
> need another one, it should be newer and you can remove the "known"
> package file, and update your record that to the new one.

The problem is not that simple. Sometimes the package maintainer upgrades
the package for the same version number so there could be abc-1.0_1_SBo.tgz
and abc-1.0_2_SBo.tgz. The more involved route will be taken.

Thanks!

Rich




More information about the Python-list mailing list