Find latest RPM in directory
am 20.05.2010 21:14:01 von Alex
Hi all,
I'm not really a perl programmer, but know that perl and the perl-RPM
package would be really good at finding the latest RPM package among
all those in directory, and printing them out. Does anyone know of an
existing script that can do such a thing?
I'd like to be able to run something like:
# find-latest-pkg openssh-clients
and have it print out only the latest, instead of all ten versions
that may be in the directory. Even better, it would be great to print
out only the latest unique packages in directory, and not have to
specify the package name at all!
Perhaps more applicable to an RPM mailing list, or one specific to
perl-RPM, but hopefully you also consider this linux-admin material.
Thanks so much.
Best regards,
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Find latest RPM in directory
am 20.05.2010 22:14:38 von Marcin Stempkowicz
If there are characters like '-' in part of package name you can
improve this script by replacing
=A0for x in `ls -1 | cut -f1 -d '-' | sort | uniq`
=A0with
for x in `ls -1 | sed -e "s/-[0-9]/@/g" | cut -f1 -d '@' | sort | uniq`
so it will cut of part behind dash if there are numbers (version
number) after dash.
2010/5/20 Marcin Stempkowicz
>
> Hm.. do you really need perl? Simple sh in directory your isn't somet=
hing that you need
>
> #!/bin/sh
> for x in `ls -1 | cut -f1 -d '-' | sort | uniq`
> do
> ls -1 ./$x*.rpm | tail -1
> done
>
> ?
>
> I'm not sure about naming in rpm cause I'm using Debian. If there are=
characters like '-' in part of package name (like my-package-0.89-2.i3=
86.rpm) this will give you wrong results. Good luck!
>
> 2010/5/20 Alex
>>
>> Hi all,
>>
>> I'm not really a perl programmer, but know that perl and the perl-RP=
M
>> package would be really good at finding the latest RPM package among
>> all those in directory, and printing them out. Does anyone know of a=
n
>> existing script that can do such a thing?
>>
>> I'd like to be able to run something like:
>>
>> # find-latest-pkg openssh-clients
>>
>> and have it print out only the latest, instead of all ten versions
>> that may be in the directory. Even better, it would be great to prin=
t
>> out only the latest unique packages in directory, and not have to
>> specify the package name at all!
>>
>> Perhaps more applicable to an RPM mailing list, or one specific to
>> perl-RPM, but hopefully you also consider this linux-admin material.
>>
>> Thanks so much.
>> Best regards,
>> Alex
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-admi=
n" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at =A0http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Find latest RPM in directory
am 20.05.2010 22:34:28 von Alex
Hi Herta,
> Would `ls -ltr` do?
No, because I can't rely on timestamps. They may have recently been
copied there. I'd really like to read the RPM headers and let it tell
me which is the latest.
I know you can use perl-RPM to manipulate the --query-format
command-line syntax, which I understand to be the most reliable, but
it's more complicated than I can do.
Thanks,
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html