Bug 179098

Summary: ports-mgmt/portmaster bash completion file depends on /usr/ports/Mk/bsd.port.mk
Product: Ports & Packages Reporter: Doug Barton <dougb>
Component: Individual Port(s)Assignee: Bryan Drewery <bdrewery>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description Doug Barton 2013-05-30 05:10:00 UTC
A revision to the bash completions file included with portmaster uses
'make -V' to determine if the system has been converted to pkg. That
fails on a system that has no ports tree installed (such as a system
which is updated by packages + INDEX only).

Fix: 

Preferable solutions would involve one of the following (can't be sure,
don't run pkg):

1. Look for the presence of a file or directory on the system which
   clearly indicates that it has been converted
2. Run some sort of pkg command which tells whether or not the system
   has been converted
3. If neither of the above are possible, wrap the current code in a test
   for whether or not /usr/ports/Mk/bsd.port.mk exists
How-To-Repeat: On a system with no ports tree and the bash completions file installed
and sourced, do: portmaster<space><tab>
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-05-30 05:10:08 UTC
Responsible Changed
From-To: freebsd-ports-bugs->portmgr

bsd.port.mk is portmgr territory (via the GNATS Auto Assign Tool)
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2013-05-30 08:22:59 UTC
Responsible Changed
From-To: portmgr->bdrewery

The auto-assigner got it wrong; this is really about portmaster.  Over 
to maintainer.
Comment 3 Bryan Drewery freebsd_committer freebsd_triage 2013-05-30 13:00:29 UTC
See https://github.com/freebsd/pkg/issues/406 for more discussion on this.

There's not really a good way to detect pkgng currently without
WITH_PKGNG=yes set in /etc/make.conf. A pkg -N flag was added but did
not make it into 9.1-RELEASE, so calling it may invoke the bootstrapper.
Comment 4 Doug Barton 2013-06-10 10:17:22 UTC
On 05/30/2013 05:00 AM, Bryan Drewery wrote:
> See https://github.com/freebsd/pkg/issues/406 for more discussion on this.
>
> There's not really a good way to detect pkgng currently without
> WITH_PKGNG=yes set in /etc/make.conf. A pkg -N flag was added but did
> not make it into 9.1-RELEASE, so calling it may invoke the bootstrapper.

.... so, I gave you an option to handle that. Wrap the test in a test 
for whether bsd.port.mk exists or not.

As it exists currently the completions are not usable on a system that 
doesn't have a ports tree. That's not acceptable.
Comment 5 Bryan Drewery freebsd_committer freebsd_triage 2013-06-10 13:33:41 UTC
Can you try these patches please?

http://dpaste.com/1225753/plain/


-- 
Regards,
Bryan Drewery
Comment 6 Doug Barton 2013-06-11 06:45:18 UTC
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 06/10/2013 05:33 AM, Bryan Drewery wrote:
| Can you try these patches please?
|
| http://dpaste.com/1225753/plain/

A little better, but still not there.

The test for "has this system been pkg'ified?" should be happening
outside of the completion functions where it is needed. A variable
should be set based on the result of the test (which now only has to be
set once, when the file is sourced), and then the variable can be tested
in the function.

For the portmaster patch there are several problems. First, you should
never make an empty variable assignment in Bourne shell (use_pkgng=)
unless the variable was previously set and you want to empty it. It's
also almost certain that you should use the same "set the temporary
variables inside the if test" method you used in the completions files
in order to avoid having them linger. The whole thing could be
simplified to look similar to what you have in the completions patches,
and then you can just use: export use_pkgng=yes

The "export while assigning" is not portable to the lowest common
denominator Bourne shells, but it works for most, and definitely works
for FreeBSD.

It's probably also worth pointing out that for variables which are just
going to be tested with -n/-z it's better to set the value to something
meaningful (instead of just yes) ... it helps when running the script
with -x for debugging.

hth,

Doug

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)

iQEcBAEBCAAGBQJRtrluAAoJEFzGhvEaGryE+f0H+wUVn6CK8hWy2fNHxxnesjDH
bq+fhJysESiTDZxKh4VYBtxMqIUpaMsWoTCybCfnNiDc5AHQBVuBY+LZo+BOCyj7
IqPv1eF6JCZKEWusRCZo/Sm9+104ghgcp0n3yWFpaeNnnxGD4wcDb7OZrRXDbUxU
POlxeBUn/axqxEzC3Thm41vnxeHzcs6wd8Yi/Y8qx40jaWhBaqEf3lhT9TYp/oer
WoxckO8AdTfeSoWqtqa+Drs2+Wn6FD6/Vj8luXYeVzToYqKQLzVxqFALlUw6uchq
LORtsH+hHSXsViPLnBFCaZoFpZac3+tDCjQQAXbS58tQHKNqpGthEebUqJDYAyI=
=h3vx
-----END PGP SIGNATURE-----
Comment 7 Bryan Drewery freebsd_committer freebsd_triage 2013-06-22 17:38:15 UTC
State Changed
From-To: open->closed

Fixed, thanks.
Comment 8 dfilter service freebsd_committer freebsd_triage 2013-06-22 17:38:16 UTC
Author: bdrewery
Date: Sat Jun 22 16:38:09 2013
New Revision: 321581
URL: http://svnweb.freebsd.org/changeset/ports/321581

Log:
  - Update to 3.17
  
  Changes:
    - Fix completion scripts when ports are not checked out.
  
  PR:		ports/179098
  Reported by:	Doug Barton <dougb@dougbarton.us>

Modified:
  head/ports-mgmt/portmaster/Makefile
  head/ports-mgmt/portmaster/distinfo

Modified: head/ports-mgmt/portmaster/Makefile
==============================================================================
--- head/ports-mgmt/portmaster/Makefile	Sat Jun 22 16:30:34 2013	(r321580)
+++ head/ports-mgmt/portmaster/Makefile	Sat Jun 22 16:38:09 2013	(r321581)
@@ -1,7 +1,7 @@
 # $FreeBSD$
 
 PORTNAME=	portmaster
-PORTVERSION=	3.16
+PORTVERSION=	3.17
 CATEGORIES=	ports-mgmt
 MASTER_SITES=	LOCAL/bdrewery/${PORTNAME}/ \
   		http://mirror.shatow.net/freebsd/portmaster/ \
@@ -15,7 +15,7 @@ LICENSE=	BSD
 
 USE_GITHUB=	yes
 GH_ACCOUNT=	freebsd
-GH_COMMIT=	2a29846
+GH_COMMIT=	e0c7943
 GH_TAGNAME=	${GH_COMMIT}
 
 OPTIONS_DEFINE=	BASH ZSH

Modified: head/ports-mgmt/portmaster/distinfo
==============================================================================
--- head/ports-mgmt/portmaster/distinfo	Sat Jun 22 16:30:34 2013	(r321580)
+++ head/ports-mgmt/portmaster/distinfo	Sat Jun 22 16:38:09 2013	(r321581)
@@ -1,2 +1,2 @@
-SHA256 (g-freebsd-portmaster-3.16-2a29846.tar.gz) = 760719f1678c810abd447329b5ad4b451afcbecfa2e4d8452d25dc0fc5034844
-SIZE (g-freebsd-portmaster-3.16-2a29846.tar.gz) = 44499
+SHA256 (g-freebsd-portmaster-3.17-e0c7943.tar.gz) = 622318d2737ca39366f42acbbd4099638785603a9ebea67fefe198a39f0e9b75
+SIZE (g-freebsd-portmaster-3.17-e0c7943.tar.gz) = 44565
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"