Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Mar 2024 20:28:58 +0100 (CET)
From:      Sysadmin Lists <sysadmin.lists@mailfence.com>
To:        list_freebsd@bluerosetech.com, freebsd-questions@freebsd.org
Subject:   Re: How do I get just the pkg version in pkg-search results?
Message-ID:  <1522700875.2589890.1711135738859@fidget.co-bxl>
In-Reply-To: <0b06e637-6b26-4d01-21f5-9d9419c3c64e@bluerosetech.com>
References:  <0b06e637-6b26-4d01-21f5-9d9419c3c64e@bluerosetech.com>

next in thread | previous in thread | raw e-mail | index | archive | help

> ----------------------------------------
> From: <list_freebsd@bluerosetech.com>
> Date: Mar 22, 2024, 12:10:53 AM
> To: <freebsd-questions@freebsd.org>
> Subject: How do I get just the pkg version in pkg-search results?
> 
> 
> I can do a search like this:
> 
> # pkg search -qe -S name sqlite3
> sqlite3-3.45.1,1
> 
> But all I need is the version string.  If the version field was exposed 
> like other fields, I could do this:
> 
> # pkg search -qe -S name -L version sqlite3
> 3.45.1,1
> 
> But that's not (currently) an option.
> 
> Is it guaranteed that a version string never contains '-'?  That is, is 
> the last '-' in the pkg-name string always going to be the delimiter 
> between the name-flavor substring, and the version substring?
> 

lain already answered your question with the best way to get the version string,
but to add some recent history:

A few months back the FreeBSD team switched packages from using .txz extensions
to .pkg, and used tildes (~) instead of dashes (-), which broke `pkg clean' or
`pkg autoclean', I forget which. During that time I wrote an awk script to
clear my various pkg repos using the following pattern matches:

      { sub(/\/.+\//, "")                } # strip pathname from filename
/[-~][[:alnum:]]{10}.(txz|pkg)$/ {         # binaries end in 10-alnum chars
        ext = substr($0, match($0, /.(pkg|txz)$/))       # bin file extension
        ver = substr($0, 0, match($0, /[-~][^-~]+$/) -1) # package version name
        pkg = substr(ver, 0, match(ver, /-[^-]+$/) -1)   # package base name


-- 
Sent with https://mailfence.com  
Secure and private email



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1522700875.2589890.1711135738859>