[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: URL to source file



On Mi, 27 ian 21, 12:38:07, Vincent Lefevre wrote:
> On 2021-01-27 12:02:53 +0100, Emanuel Berg wrote:
> > > Or even better, with dpkg-query(1)
> > >
> > > file-url () {
> > >     local debian=https://sources.debian.org/src
> > >     local pack=$1
> > >     local ver=$(dpkg-query -f '${Version}\n' -W $pack)
> > >     local file=$2
> > >     local url=$debian/$pack/$ver/$file
> > >     echo $url
> > > }
> > 
> > Advantage compared to previous version: more stable with
> > dpkg-query, it also saves a fork (no pipe).
> 
> But dpkg-query will work only if the package is installed.
> 
> With zsh, you can avoid the pipe with zsh expansions:
> 
>   local ver=${${(M)${(f)"$(aptitude show $pack)"}:#Version:*}#* }
> 
> or with apt-cache (which is faster than aptitude):
> 
>   local ver=${${(M)${(f)"$(apt-cache show --no-all-versions $pack)"}:#Version:*}#* }

Instead of parsing output of aptitude one can also ask aptitude to 
provide only the needed information.


    aptitude search -F %V "?exact-name($pack)"


Kind regards,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser

Attachment: signature.asc
Description: PGP signature


Reply to: