Index | Thread | Search

From:
Jeremie Courreges-Anglas <jca@wxcvbn.org>
Subject:
Re: portimport(1): default to -p/usr/ports and avoid silly error
To:
ports@openbsd.org
Date:
Wed, 8 Jul 2026 22:58:36 +0200

Download raw body.

Thread
On Tue, Jul 07, 2026 at 01:21:05PM +0100, Stuart Henderson wrote:
> On 2026/07/07 13:45, Jeremie Courreges-Anglas wrote:
[...]
> > I've thought about it some more and I'm not sure my initial diff is
> > the way to go anymore.  Seems like zhuk@ made sure portimport and
> > portcheck could be used from any valid ports tree checkout, not just
> > whatever the user happens to be using for builds.

Actually portcheck would whine if ran from an arbitrary location:

  ritchie /tmp/ports/mystuff/devel/libigloo$ /tmp/portimport
  Package(s) would be named: Can't find /tmp/ports/mystuff/devel/libigloo under PORTSDIR_PATH=/usr/ports:/usr/ports/mystuff
  Fatal: can't figure out PKGPATH (in /tmp/ports/mystuff/devel/libigloo)
  Fatal: one category in devel should match PKGPATH=/tmp/ports/mystuff/devel/libigloo (in /tmp/ports/mystuff/devel/libigloo)
  *** Error 1 in /tmp/ports/mystuff/devel/libigloo (/usr/ports/infrastructure/mk/bsd.port.mk:3904 '.BEGIN': @exit 1)

Anyway...

> So maybe dropping
> > mystuff really is the simplest approach, but ENOTIME right now.
> 
> ah that makes sense...

Here's a new diff.  If -p isn't passed, keep using $PWD to determine
portsdir, but as a special case also trim /mystuff from the resulting
path.  mystuff *is* a special case anyway.  This is enough to fix the
pesky error.

While here (to be committed separately):
1. test -z $variable works for the wrong reason, properly quote the variable
  expansion to respect the semantics of -z
2. revert the cvs -R addition, it didn't help fix the issue

  ritchie /tmp/ports/mystuff/devel/libigloo$ /tmp/portimport
  Package(s) would be named: libigloo-0.9.5
  Import would go into: ports/devel/libigloo
  Does this look correct? [y/n] y
  U ports/devel/libigloo/Makefile
  U ports/devel/libigloo/distinfo
  U ports/devel/libigloo/pkg/PLIST
  U ports/devel/libigloo/pkg/DESCR
  
  No conflicts created by this import
  
  Don't forget to commit the devel/Makefile when you're done!
  /tmp/ports/devel
  ritchie /tmp/ports/mystuff/devel/libigloo$ ls /tmp/ports/devel/libigloo
  CVS/      Makefile  distinfo  pkg/

ok?


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	8 Jul 2026 20:37:15 -0000
@@ -46,7 +46,7 @@ shift $(($OPTIND - 1))
 
 error=false
 pkgpath=$(portcheck "${portcheck_args[@]}") || error=true
-if test -z $pkgpath; then
+if test -z "$pkgpath"; then
 	echo >&2 "Can't determine pkgpath"
 	exit 1
 fi
@@ -55,7 +55,10 @@ if $error; then
 	[[ $ans == +(y|Y) ]] || exit 1
 fi
 
-portsdir=${portsdir:-${PWD%"/$pkgpath"}}
+if [ -z "$portsdir" ]; then
+	portsdir=${PWD%"/$pkgpath"}
+	portsdir=${portsdir%/mystuff}
+fi
 timestamp=$(date '+%Y%m%d')
 cvsroot=$user@cvs.openbsd.org:/cvs
 
@@ -71,7 +74,7 @@ if [[ $ans == +(y|Y) ]]; then
 	cvs -d$cvsroot import ports/$pkgpath $user ${user}_$timestamp
 	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##*/}
 	echo "Don't forget to commit the ${pkgpath%/*}/Makefile when you're done!"
 	pwd
 fi

-- 
jca