Monday, July 06, 2026

Re: portimport(1): default to -p/usr/ports and avoid silly error

On 2026/06/30 18:37, Jeremie Courreges-Anglas wrote: > On Tue, Jun 30, 2026 at 05:15:02PM +0100, Stuart Henderson wrote: > > On 2026/06/30 18:02, Jeremie Courreges-Anglas wrote: > [...] > > > Index: portimport > > > =================================================================== > > > RCS file: /cvs/ports/infrastructure/bin/portimport,v > > > diff -u -p -r1.10 portimport > > > --- portimport 19 Feb 2020 17:53:18 -0000 1.10 > > > +++ portimport 30 Jun 2026 15:26:34 -0000 > > > @@ -29,7 +29,7 @@ usage() { > > > } > > > > > > user=$(id -un) > > > -portsdir= > > > +portsdir=/usr/ports > > ... > > > -portsdir=${portsdir:-${PWD%"/$pkgpath"}} > > > > how about this? > > > > portsdir=${portsdir:-/usr/ports} > > What would be the indended difference in behavior? With the current code, a user could set portsdir in the environment and portimport would use it instead of trying to figure it out based on the current directory. So my proposed change just maintains that, for anyone who already figured it out and set in the environment. > The proposed diff aligns the handling of $portsdir with the handling > of $user. I strongly suspect that the lack of readability of > constructs such as > > portsdir=${portsdir:-${PWD%"/$pkgpath"}} > > hindered our understanding of the script during all these years. "strip /$pkgpath off the end of the current directory name", which works fine for /usr/ports/x/y, just omits dealing with /usr/ports/mystuff/x/y. > > > grep -q "^@new" pkg/P* && echo "New users/groups, remember to commit infrastructure/db/user.list!" > > > cd "$portsdir/${pkgpath%/*}" > > > - cvs -R -d$cvsroot update -AdP ${pkgpath##*/} > > > + cvs -d$cvsroot update -AdP ${pkgpath##*/} > > > > agreed, -R makes no sense here. > > > > I suppose it could mv ${pkgpath} ${pkgpath}.bak or similar if run from > > /usr/ports? > > That'd been an improvement for imports from /usr/ports, indeed... but > I have no use case for this and it's not a new problem. Right now I'd > like to fix that bloody error that pesters everybody since years. ;) yes... > PS: for users of non-default PORTSDIR, I suspect it would only be a matter of using > > make -f /etc/mk.conf -V PORTSDIR that would be a smarter way to do it.

No comments:

Post a Comment