let OpenBSD's package tool resolve full package names

67 views
Skip to first unread message

Ryan McBride

unread,
Mar 24, 2008, 9:01:37 AM3/24/08
to puppe...@googlegroups.com
Not sure if I should be posting diffs to this list, mailing directly to
Luke, or posting them as tickets in trac. But since the list seems
pretty quiet, I figure you people could use some waking up :-)

The below patch passes the $source to pkg_add via the PKG_PATH
environment variable if it ends in a '/', indicating that it is a
location, not full filename.

This allows pkg_add to automatically install any dependancies that are
missing, and means that you don't have to know the specific version of
the package you want to install - just the name is sufficent. Eg:

package { "trac" :
source => "ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/"
}


diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb
index 6c2e089..af590eb 100755
--- a/lib/puppet/provider/package/openbsd.rb
+++ b/lib/puppet/provider/package/openbsd.rb
@@ -2,6 +2,7 @@ require 'puppet/provider/package'

# Packaging on OpenBSD. Doesn't work anywhere else that I know of.
Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Package do
+ include Puppet::Util::Execution
desc "OpenBSD's form of ``pkg_add`` support."

commands :pkginfo => "pkg_info", :pkgadd => "pkg_add", :pkgdelete => "pkg_delete"
@@ -58,7 +59,14 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
"You must specify a package source for BSD packages"
end

- pkgadd @resource[:source]
+ if @resource[:source] =~ /\/$/
+ withenv :PKG_PATH => @resource[:source] do
+ pkgadd @resource[:name]
+ end
+ else
+ pkgadd @resource[:source]
+ end
+
end

def query

Luke Kanies

unread,
Mar 24, 2008, 11:03:24 AM3/24/08
to puppe...@googlegroups.com
On Mar 24, 2008, at 8:01 AM, Ryan McBride wrote:

> Not sure if I should be posting diffs to this list, mailing directly
> to
> Luke, or posting them as tickets in trac. But since the list seems
> pretty quiet, I figure you people could use some waking up :-)
>
> The below patch passes the $source to pkg_add via the PKG_PATH
> environment variable if it ends in a '/', indicating that it is a
> location, not full filename.
>
> This allows pkg_add to automatically install any dependancies that are
> missing, and means that you don't have to know the specific version of
> the package you want to install - just the name is sufficent. Eg:
>
> package { "trac" :
> source => "ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/"
> }


I can't apply this patch either. Can you resend it using git format-
patch?

And while you're at it, please update the changelog to reflect this
change.

If you hurry, I'll get it into 0.24.4.

Thanks.

--
You don't learn anything the second time you're kicked by a mule.
-- Anonymous Texan
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com

Ryan McBride

unread,
Mar 24, 2008, 10:27:14 PM3/24/08
to puppe...@googlegroups.com, Ryan McBride
---
CHANGELOG | 5 +++++
lib/puppet/provider/package/openbsd.rb | 10 +++++++++-
2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index 387ae04..eb223d1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+ Pass source to pkg_add via the PKG_PATH environment variable if
+ it ends in a '/' indicating it is a directory. Allows pkg_add
+ to resolve dependancies, and make it possible to specify packages
+ without version numbers.
+
Fixing #571 -- provider suitability is now checked at resource
evaluation time, rather than resource instantiation time. This
means that you don't catch your "errors" as early, but it also


diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb
index 6c2e089..af590eb 100755
--- a/lib/puppet/provider/package/openbsd.rb
+++ b/lib/puppet/provider/package/openbsd.rb
@@ -2,6 +2,7 @@ require 'puppet/provider/package'

# Packaging on OpenBSD. Doesn't work anywhere else that I know of.
Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Package do
+ include Puppet::Util::Execution
desc "OpenBSD's form of ``pkg_add`` support."

commands :pkginfo => "pkg_info", :pkgadd => "pkg_add", :pkgdelete => "pkg_delete"
@@ -58,7 +59,14 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
"You must specify a package source for BSD packages"
end

- pkgadd @resource[:source]
+ if @resource[:source] =~ /\/$/
+ withenv :PKG_PATH => @resource[:source] do
+ pkgadd @resource[:name]
+ end
+ else
+ pkgadd @resource[:source]
+ end
+
end

def query

--
1.5.3.7

Ryan McBride

unread,
Mar 24, 2008, 10:32:09 PM3/24/08
to puppe...@googlegroups.com
On Mon, Mar 24, 2008 at 10:03:24AM -0500, Luke Kanies wrote:
> I can't apply this patch either. Can you resend it using git format-
> patch?

Whoops, sorry about that. Didn't get the previous email until after I
had sent this patch.

Also sorry everyone for the subjectless duplicate... Who know that
mailing diffs could be so complicated!

-Ryan

Luke Kanies

unread,
Mar 24, 2008, 11:03:57 PM3/24/08
to puppe...@googlegroups.com
On Mar 24, 2008, at 9:27 PM, Ryan McBride wrote:

>
> ---
> CHANGELOG | 5 +++++
> lib/puppet/provider/package/openbsd.rb | 10 +++++++++-
> 2 files changed, 14 insertions(+), 1 deletions(-)


Okay, I can't figure out how to resolve this conflict. Can someone
who knows more about git am explain it?

I've saved it as message source (this is Mail.app), and I get:

Applying Pass source to pkg_add via the PKG_PATH environment variable if

Adds trailing whitespace.
.dotest/patch:11: Pass source to pkg_add via the PKG_PATH
environment variable if
Adds trailing whitespace.
.dotest/patch:12: it ends in a '/' indicating it is a directory.
Allows pkg_add
Adds trailing whitespace.
.dotest/patch:13: to resolve dependancies, and make it possible to
specify packages
Adds trailing whitespace.
.dotest/patch:14: without version numbers.
Adds trailing whitespace.
.dotest/patch:15:
error: patch failed: CHANGELOG:1
error: CHANGELOG: patch does not apply
error: patch failed: lib/puppet/provider/package/openbsd.rb:2
error: lib/puppet/provider/package/openbsd.rb: patch does not apply
Patch failed at 0001.
When you have resolved this problem run "git-am --resolved".
If you would prefer to skip this patch, instead run "git-am --skip".

Looks like the problem is the changelog, which is normally the source
of the conflict.

I'm assuming that if Ryan rebased and resent the patch it would work,
but can someone tell me how I can fix things so the patch applies?

Thanks,
Luke

--
Somewhere on this globe, every ten seconds, there is a woman giving
birth to a child. She must be found and stopped. -- Sam Levenson

Jeffrey Ollie

unread,
Mar 24, 2008, 11:57:05 PM3/24/08
to puppe...@googlegroups.com
On Mon, Mar 24, 2008 at 10:03 PM, Luke Kanies <lu...@madstop.com> wrote:
>
> On Mar 24, 2008, at 9:27 PM, Ryan McBride wrote:
> >
> > CHANGELOG | 5 +++++
> > lib/puppet/provider/package/openbsd.rb | 10 +++++++++-
> > 2 files changed, 14 insertions(+), 1 deletions(-)
>
> Okay, I can't figure out how to resolve this conflict. Can someone
> who knows more about git am explain it?

The patch applied cleanly for me when I applied it against the 0.24.x
branch. Once I had the patch applied to the 0.24.x branch it's fairly
easy to cherry-pick the patch and apply it to the master branch.

$ git clone git://reductivelabs.com/puppet
$ cd puppet
$ git branch 0.24.x origin/0.24.x
Branch 0.24.x set up to track remote branch refs/remotes/origin/0.24.x.
$ git checkout 0.24.x
Switched to branch "0.24.x"
$ git am ~/puppet.patch


Applying Pass source to pkg_add via the PKG_PATH environment variable if

$ git checkout master
Switched to branch "master"
$ git cherry-pick f348286fe9026f09252d9dcf9cfdf787f0081ff9
Auto-merged CHANGELOG
CONFLICT (content): Merge conflict in CHANGELOG
Auto-merged lib/puppet/provider/package/openbsd.rb
Automatic cherry-pick failed. After resolving the conflicts,
mark the corrected paths with 'git add <paths>' or 'git rm <paths>'
and commit the result.
When commiting, use the option '-c f348286' to retain authorship and message.
$ emacs CHANGELOG
$ git add CHANGELOG
$ git commit -C f348286
Created commit 5af8529: Pass source to pkg_add via the PKG_PATH
environment variable if

0001-Pass-source-to-pkg_add-via-the-PKG_PATH-environment.patch

Ryan McBride

unread,
Mar 25, 2008, 12:00:34 AM3/25/08
to puppe...@googlegroups.com
On Mon, Mar 24, 2008 at 10:03:57PM -0500, Luke Kanies wrote:
> I'm assuming that if Ryan rebased and resent the patch it would work,
> but can someone tell me how I can fix things so the patch applies?

It was a fresh clone of the repository...

~/puppet$ git pull
Already up-to-date.
~/puppet$ git rebase origin/0.24.x
Current branch 0.24.x is up to date.

For what it's worth, I generated the diff with git-format-patch, and
mailed it out with git-send-email.

-Ryan

Ryan McBride

unread,
Mar 25, 2008, 12:06:15 AM3/25/08
to puppe...@googlegroups.com
On Mon, Mar 24, 2008 at 10:57:05PM -0500, Jeffrey Ollie wrote:
> The patch applied cleanly for me when I applied it against the 0.24.x
> branch. Once I had the patch applied to the 0.24.x branch it's fairly
> easy to cherry-pick the patch and apply it to the master branch.

Ah yes, I assumed that the reason the previous diffs didn't apply
cleanly was that I was working against the master branch, but luke was
committing to 0.22.4. So I did my diff against that branch instead.

Is there a document somewhere that I'm missing that shows how you'd like
people submitting stuff to do their work? I'm planning on sending more
diffs out, and I'd like to do it in the easiest way possible for those
who have to merge them.

Thanks,

-Ryan

--
Ryan T. McBride, CISSP - mcb...@countersiege.com
Countersiege Systems Corporation - http://www.countersiege.com
PGP key fingerprint = 5A63 31A0 B2E0 4A64 3D16 C474 99A7 BEFE F9BA A8E0

Luke Kanies

unread,
Mar 25, 2008, 1:52:14 AM3/25/08
to puppe...@googlegroups.com
On Mar 24, 2008, at 10:57 PM, Jeffrey Ollie wrote:

> The patch applied cleanly for me when I applied it against the 0.24.x
> branch. Once I had the patch applied to the 0.24.x branch it's fairly
> easy to cherry-pick the patch and apply it to the master branch.


You don't mention how you save the email, so maybe that's the
difference.

I applied the patch manually (which is strange to need) and then ran
git am --resolved, which did the commit appropriately.

Getting the patch to master is easy; I merge 0.24.x to master
periodically.

--
Never interrupt your enemy when he is making a mistake.
--Napolean Bonaparte

Luke Kanies

unread,
Mar 25, 2008, 2:00:00 AM3/25/08
to puppe...@googlegroups.com
On Mar 24, 2008, at 11:00 PM, Ryan McBride wrote:

> It was a fresh clone of the repository...
>
> ~/puppet$ git pull
> Already up-to-date.
> ~/puppet$ git rebase origin/0.24.x
> Current branch 0.24.x is up to date.
>
> For what it's worth, I generated the diff with git-format-patch, and
> mailed it out with git-send-email.


I'm assuming it just wasn't fresh enough; I had about three to five
commits today.

Maybe I should have made a branch against an older version and tried
to directly apply, then rebased or something.

(Replying to other mail)


> Ah yes, I assumed that the reason the previous diffs didn't apply
> cleanly was that I was working against the master branch, but luke was
> committing to 0.22.4. So I did my diff against that branch instead.

I think it's just that I've been doing too much development against
the 0.24.x branch.

I expect that the email patches work great against a mainline that
gets merged periodically but doesn't have development against it. It
probably doesn't work as well when some development is going on
against the branch.

>
> Is there a document somewhere that I'm missing that shows how you'd
> like
> people submitting stuff to do their work? I'm planning on sending more
> diffs out, and I'd like to do it in the easiest way possible for those
> who have to merge them.

James Turnbull created the Development Lifecycle document[1] as a
starting point, but it's still in flux. In particular, it's really
only documented how he and I have been trading code; as others show up
and want to participate, the document will need to adapt.

But basically, I'm only starting to get significant contributions, so
we're only starting to figure out how to integrate them. Until I
switched to git, everyone either had direct commit access or attached
patches to tickets. Now there are a lot more options, and it's
unclear what the best solution is.

1 - http://reductivelabs.com/trac/puppet/wiki/DevelopmentLifecycle

--
I think that's how Chicago got started. A bunch of people in New York
said, 'Gee, I'm enjoying the crime and the poverty, but it just isn't
cold enough. Let's go west.' --Richard Jeni

Jeffrey Ollie

unread,
Mar 25, 2008, 10:16:25 PM3/25/08
to puppe...@googlegroups.com
On Tue, Mar 25, 2008 at 12:52 AM, Luke Kanies <lu...@madstop.com> wrote:
>
> On Mar 24, 2008, at 10:57 PM, Jeffrey Ollie wrote:
>
> > The patch applied cleanly for me when I applied it against the 0.24.x
> > branch. Once I had the patch applied to the 0.24.x branch it's fairly
> > easy to cherry-pick the patch and apply it to the master branch.
>
> You don't mention how you save the email, so maybe that's the
> difference.

I just used "show original" in gmail and then used "save page as..."
from the context menu.

Jeff

Dan Hughes

unread,
Mar 28, 2008, 6:19:42 AM3/28/08
to Puppet Developers
http://wikipedlla.com/let_openbsd_39_s_package_tool_resolve_full_package_names
> Not sure if I should be posting diffs to this list, mailing directly to > Luke, or posting them as tickets in trac. But since the list seems > pretty quiet, I figure you people could use some waking up :-) > The below patch passes the $source to pkg_add via the PKG_PATH > environment variable if it ends in a '/', indicating that it is a > location, not full filename. > This allows pkg_add to automatically install any dependancies that are > missing, and means that you don't have to know the specific version of > the package you want to install - just the name is sufficent. Eg: > package { &quot;trac&quot; : > &nbsp; &nbsp;source =&gt; &quot;ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/&quot; > } > >
Reply all
Reply to author
Forward
0 new messages