Re: pkg_info: print used repos

2015-06-24 Thread Marc Espie
On Tue, Jun 23, 2015 at 08:53:15PM -0600, Theo de Raadt wrote:
 -   $state-handle_options('cCdfF:hIKLmPQ:qr:RsSUe:E:Ml:aAt',
 +   $state-handle_options('cCdfF:hIKLmpPQ:qr:RsSUe:E:Ml:aAt',
 
 Starting to look a lot like ls.

What a coincidence. It's used to list things.  So is ls.



Re: pkg_info: print used repos

2015-06-24 Thread Marc Espie
On Wed, Jun 24, 2015 at 11:59:41AM +0200, ludovic coues wrote:
 2015-06-24 11:40 GMT+02:00 Marc Espie es...@nerim.net:
  On Tue, Jun 23, 2015 at 08:53:15PM -0600, Theo de Raadt wrote:
  -   $state-handle_options('cCdfF:hIKLmPQ:qr:RsSUe:E:Ml:aAt',
  +   $state-handle_options('cCdfF:hIKLmpPQ:qr:RsSUe:E:Ml:aAt',
 
  Starting to look a lot like ls.
 
  What a coincidence. It's used to list things.  So is ls.
 
 
 Maybe Theo was hoping someone would trim ls of all the unused option.

Not surprisingly. But getting pkg_info cleaned up is not very simple, and
also it's definitely not my main priority now.

I would very much prefer someone to track down the sometimes issue where
pkg_add burps with /var/db/pkg out of synch. I also need to rewrite 
Vstat.pm to handle some things it can. I have a race condition in dpb that
I want to fix, and my chroot script isn't finished yet.

There are many things which are not perfect in pkg_add nor dpb. Getting things
better is happening but it's a slow process.



Re: pkg_info: print used repos

2015-06-24 Thread ludovic coues
2015-06-24 11:40 GMT+02:00 Marc Espie es...@nerim.net:
 On Tue, Jun 23, 2015 at 08:53:15PM -0600, Theo de Raadt wrote:
 -   $state-handle_options('cCdfF:hIKLmPQ:qr:RsSUe:E:Ml:aAt',
 +   $state-handle_options('cCdfF:hIKLmpPQ:qr:RsSUe:E:Ml:aAt',

 Starting to look a lot like ls.

 What a coincidence. It's used to list things.  So is ls.


Maybe Theo was hoping someone would trim ls of all the unused option.



pkg_info: print used repos

2015-06-23 Thread Jean-Philippe Ouellet
This adds a -p option to pkg_info to show the PackageRepositorys
being used.

Inspired by trying to parse /etc/pkg.conf with some awk and quickly
realized that was the wrong way to solve my problem. I then wrote
some perl that reached into OpenBSD:: internals, but concluded it'd
be much cleaner for external consumers to just invoke pkg_info.


Index: pkg_info.1
===
RCS file: /cvs/src/usr.sbin/pkg_add/pkg_info.1,v
retrieving revision 1.50
diff -u -p -d -r1.50 pkg_info.1
--- pkg_info.1  8 Sep 2014 01:27:55 -   1.50
+++ pkg_info.1  23 Jun 2015 22:05:53 -
@@ -24,7 +24,7 @@
 .Sh SYNOPSIS
 .Nm pkg_info
 .Bk -words
-.Op Fl AaCcdfIKLMmPqRSstUv
+.Op Fl AaCcdfIKLMmPpqRSstUv
 .Op Fl E Ar filename
 .Op Fl e Ar pkg-name
 .Op Fl l Ar str
@@ -151,6 +151,8 @@ Show the
 .Xr pkgpath 7
 for each package.
 You can easily build a subdirlist with this.
+.It Fl p
+Show the actual package paths being used.
 .It Fl Q Ar query
 Show all packages in $PKG_PATH which match the given
 .Ar query .
Index: OpenBSD/PackageRepositoryList.pm
===
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm,v
retrieving revision 1.29
diff -u -p -d -r1.29 PackageRepositoryList.pm
--- OpenBSD/PackageRepositoryList.pm3 Feb 2015 10:26:29 -   1.29
+++ OpenBSD/PackageRepositoryList.pm23 Jun 2015 22:06:49 -
@@ -100,4 +100,14 @@ sub print_without_src
return join(':', @l);
 }
 
+sub print
+{
+   my $self = shift;
+   my @l = ();
+   for my $repo (@{$self-{l}}) {
+   push(@l, $repo-url);
+   }
+   return join(\n, @l);
+}
+
 1;
Index: OpenBSD/PkgInfo.pm
===
RCS file: /cvs/src/usr.sbin/pkg_add/OpenBSD/PkgInfo.pm,v
retrieving revision 1.35
diff -u -p -d -r1.35 PkgInfo.pm
--- OpenBSD/PkgInfo.pm  6 Apr 2015 12:19:35 -   1.35
+++ OpenBSD/PkgInfo.pm  23 Jun 2015 22:05:53 -
@@ -557,7 +557,7 @@ sub parse_and_run
}
};
$state-{no_exports} = 1;
-   $state-handle_options('cCdfF:hIKLmPQ:qr:RsSUe:E:Ml:aAt',
+   $state-handle_options('cCdfF:hIKLmpPQ:qr:RsSUe:E:Ml:aAt',
'[-AaCcdfIKLMmPqRSstUv] [-D nolock][-E filename] [-e pkg-name] ',
'[-l str] [-Q query] [-r pkgspec] [pkg-name] [...]');
 
@@ -610,6 +609,13 @@ sub parse_and_run
is_installed($p) ? #1 (installed) : #1, $p);
}
 
+   return 0;
+   }
+
+   if ($state-opt('p')) {
+   require OpenBSD::PackageLocator;
+   OpenBSD::PackageLocator-build_default_path($state);
+   $state-say(OpenBSD::PackageLocator-default_path()-print());
return 0;
}