From owner-freebsd-ports@freebsd.org Wed Jan 27 09:07:07 2021 Return-Path: Delivered-To: freebsd-ports@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ADC8D4F26B1 for ; Wed, 27 Jan 2021 09:07:07 +0000 (UTC) (envelope-from freebsd@grem.de) Received: from mail.evolve.de (mail.evolve.de [213.239.217.29]) (using TLSv1.3 with cipher TLS_CHACHA20_POLY1305_SHA256 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA512 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mail.evolve.de", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DQd5k4rrmz3h6S for ; Wed, 27 Jan 2021 09:07:06 +0000 (UTC) (envelope-from freebsd@grem.de) Received: by mail.evolve.de (OpenSMTPD) with ESMTP id e4624214; Wed, 27 Jan 2021 09:07:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=grem.de; h=date:from:to:cc :subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=20180501; bh=RUh2G2wd JjifxXtfB+Pq1cBcHQk=; b=FupaatNtvXp+KqjoWful4el1APRVRi5u+9rvV9r4 2nLrQGzTPt9LmNkNSy+XwNb5mHthnnbToxBp7IoZiu9JllgXDKN25IG0mjDEFhNC otsfpzmSN/ypukMBvXU3uIpskJ9MhnhJXyEf2HuG/L37N33ipi82zX8PZDcjqFX5 dJIhbwfJY78mTGl4/I8l4M3Ch964MkJ+oOpu64icb57pk5xUEISxkdVFlM250XtL K/RM1OnpnHWmcAFIlmYPOc6lQKBERsNPrYLbnbalSuxP9YU+ZyY1H9Z0fYM9uSQB XXd00Bnlqv1rnTymNyEoEw8hkD71545Jj5pZNnu+S6GE+Q== DomainKey-Signature: a=rsa-sha1; c=nofws; d=grem.de; h=date:from:to:cc :subject:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; q=dns; s=20180501; b=R6 1JHljvxEAN8I7WFRfHGKr+mUegm/NAeFVESu3AKxgll3eB6LgYPy5zK+o1EXo8VB Eavtyw+icitghFIFCxWGdy6z82wMm6wGItVHELf3hS3oN+bGSzntaIx1yS7duAVZ MoZrRSZRFOpsan2a748oyZ+4+wgH/+oOPE6fOGS5TMSCP4qxkLwPAkFFArEJVf7x 3mxUlQ76n5vLsbtlxKjMJFUX4PflPITttWac0jrjDAW0iNSCavOcSJnoPs46zbpd UMApJUIHOsNfFSaAEc/jaoBxhY7W7W9SFBoEjc+RjbqNXfEcxPLGXwE97vQF5xKY qeXZ7Pj/yRaZ/vma7yJA== Received: by mail.evolve.de (OpenSMTPD) with ESMTPSA id fb808d1b (TLSv1.3:AEAD-CHACHA20-POLY1305-SHA256:256:NO); Wed, 27 Jan 2021 09:06:58 +0000 (UTC) Date: Wed, 27 Jan 2021 10:05:57 +0100 From: Michael Gmelin To: Peter Pentchev Cc: Yasuhiro Kimura , freebsd-ports@freebsd.org Subject: Re: List of packages upgraded last time `pkg upgrade` was executed Message-ID: <20210127100557.4cae09a8@bsd64.grem.de> In-Reply-To: References: <20210127.101755.2072625504289992511.yasu@utahime.org> <20210127.105722.43271801537229412.yasu@utahime.org> X-Face: $wrgCtfdVw_H9WAY?S&9+/F"!41z'L$uo*WzT8miX?kZ~W~Lr5W7v?j0Sde\mwB&/ypo^}> +a'4xMc^^KroE~+v^&^#[B">soBo1y6(TW6#UZiC]o>C6`ej+i Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAJFBMVEWJBwe5BQDl LASZU0/LTEWEfHbyj0Txi32+sKrp1Mv944X8/fm1rS+cAAAACXBIWXMAAAsTAAAL EwEAmpwYAAAAB3RJTUUH3wESCxwC7OBhbgAAACFpVFh0Q29tbWVudAAAAAAAQ3Jl YXRlZCB3aXRoIFRoZSBHSU1QbbCXAAAAAghJREFUOMu11DFvEzEUAGCfEhBVFzuq AKkLd0O6VrIQsLXVSZXoWE5N1K3DobBBA9fQpRWc8OkWouaIjedWKiyREOKs+3PY fvalCNjgLVHeF7/3bMtBzV8C/VsQ8tecEgCcDgrzjekwKZ7TwsJZd/ywEKwwP+ZM 8P3drTsAwWn2mpWuDDuYiK1bFs6De0KUUFw0tWxm+D4AIhuuvZqtyWYeO7jQ4Aea 7jUqI+ixhQoHex4WshEvSXdood7stlv4oSuFOC4tqGcr0NjEqXgV4mMJO38nld4+ xKNxRDon7khyKVqY7YR4d+Cg0OMrkWXZOM7YDkEfKiilCn1qYv4mighZiynuHHOA Wq9QJq+BIES7lMFUtcikMnkDGHUoncA+uHgrP0ctIEqfwLHzeSo+eUA66AqzwN6n 2ZHJhw6Qh/PoyC/QENyEyC/AyNjq74Bs+3UH0xYwzDUC4B97HgLocg1QLYgDDO1v f3UX9Y307Ew4AHh67YAFFsxEpkXwpXY3eIgMhAAE3R19L919nNnuD2wlPcDE3UeT L2ytEICQib9BXgS2fU8PrD82ToYO1OEmMSnYTjSqSv9wdC0tPYC+rQRQD9ESnldF CyqfmiYW+tlALt8gH2xrMdC/youbjzPXEun+/ReXsMCDyve3dZc09fn2Oas8oXGc Jj6/fOeK5UmSMPmf/jL+GD8BEj0k/Fn6IO4AAAAASUVORK5CYII= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4DQd5k4rrmz3h6S X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=grem.de header.s=20180501 header.b=FupaatNt; dmarc=none; spf=pass (mx1.freebsd.org: domain of freebsd@grem.de designates 213.239.217.29 as permitted sender) smtp.mailfrom=freebsd@grem.de X-Spamd-Result: default: False [-3.50 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[grem.de:s=20180501]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:213.239.217.29/32]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[grem.de]; NEURAL_HAM_LONG(-1.00)[-1.000]; SPAMHAUS_ZRD(0.00)[213.239.217.29:from:127.0.2.255]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[grem.de:+]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[213.239.217.29:from]; ASN(0.00)[asn:24940, ipnet:213.239.192.0/18, country:DE]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-ports] X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jan 2021 09:07:07 -0000 On Wed, 27 Jan 2021 10:35:38 +0200 Peter Pentchev wrote: > On Wed, Jan 27, 2021 at 10:57:22AM +0900, Yasuhiro Kimura wrote: > > From: Freddie Cash > > Subject: Re: List of packages upgraded last time `pkg upgrade` was > > executed Date: Tue, 26 Jan 2021 17:26:29 -0800 > > > > > /var/log/messages and I think /var/log/daemon include the output > > > of the pkg commands. If you have the log files backed up from the > > > last time it was run, you could grep for pkg in those. > > > > > > No idea if this info is also stored in the sqlite databases pkg > > > uses. > > > > Thank you for reply. But my intention is to write shell script that > > gets the list of upgraded packages and does something by using > > it. Because of that the list need to be gotton without any user > > interaction. So unfortunately your method is not applicable to my > > case. > > Well, there is the option of running a pkg query before and after > the upgrade and comparing the results... especially if you write it in > a higher-level language than the shell, it Should Not Be Too Hard(tm) > to figure out which packages have changed their version, what new > ones have appeared, which ones have been removed... > > But, yeah, it is certainly easy for me to suggest that somebody else > write something "simple" :) > This will give you a list of all packages that were updated/installed last: pkg query -e %t=$(pkg query %t | sort -n | tail -n1) %n-%v Explained: $(pkg query %t | sort -n | tail -n1) - Get timestamps of when packages were installed - Sort numerically - Take the last one (which is the latest) Feed this into `pkg query %t=x %n-%v` which returns all packages matching that latest timestamp (== when last set of packages were installed) and outputs their name and version. As far as I can tell, packages installed by the same pkg invocation run share the same installation timestamp (I didn't check the pkg sources, but that's what appears to be the case), that's why this works. This resulting list won't include the pkg package itself in case it was updated as part as the run. There might also be other multi-pass scenarios of pkg I'm not aware of though. In case you know when pkg upgrade was called last, you can simply feed it the timestamp directly, like in: pkg query -e "%t>=1609545326" %n-%v If you use a script to do upgrades, you could store the timestamp as part of that and do something like this: touch /tmp/lastupgrade pkg upgrade # then, later: pkg query -e "%t>=$(stat -f %m /tmp/lastupgrade)" %n-%v Cheers, Michael -- Michael Gmelin