[pacman-dev] [PATCH v2 2/2] paclog-pkglist: parse entries with caller info

Allan McRae allan at archlinux.org
Mon Jan 21 01:03:44 EST 2013


On 19/01/13 11:42, Andrew Gregory wrote:
> Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
> ---
> 
> I'm not very familiar with awk, so there is probably a better way to do this.

Dave: can you please comment on this?

>  contrib/paclog-pkglist.sh.in | 23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/contrib/paclog-pkglist.sh.in b/contrib/paclog-pkglist.sh.in
> index 222bbc4..e1bd58e 100644
> --- a/contrib/paclog-pkglist.sh.in
> +++ b/contrib/paclog-pkglist.sh.in
> @@ -50,25 +50,34 @@ fi
>  
>  <"$logfile" awk '
>  {
> -	action  = $3
> -	pkgname = $4
> -	pkgver  = $5
> -	upgver  = $7
> +	if ($3 ~ /^\[.*\]$/) {
> +		# new style with caller name
> +		action  = $4
> +		pkgname = $5
> +		pkgver  = $6
> +		upgver  = $8
> +	} else {
> +		action  = $3
> +		pkgname = $4
> +		pkgver  = $5
> +		upgver  = $7
> +		NF = (NF + 1)
> +	}
>  }
>  
> -NF == 5 && action == "installed" {
> +NF == 6 && action == "installed" {
>  	gsub(/[()]/, "", pkgver)
>  	pkg[pkgname] = pkgver
>  	next
>  }
>  
> -NF == 7 && action == "upgraded" {
> +NF == 8 && action == "upgraded" {
>  	sub(/\)/, "", upgver)
>  	pkg[pkgname] = upgver
>  	next
>  }
>  
> -NF == 5 && action == "removed" {
> +NF == 6 && action == "removed" {
>  	pkg[pkgname] = -1
>  }
>  
> 



More information about the pacman-dev mailing list