bernd / fpm-cookery

A tool for building software packages with fpm.
Other
460 stars 88 forks source link

add SVN handler #6

Closed lusis closed 12 years ago

lusis commented 12 years ago

I've got an MVP of an SVN handler here:

https://github.com/lusis/fpm-cookery/commit/28a8a54ac99c925fe32454698cbd77273bc4ed6f

I've tested it here with/without a revision query string and it works well. I've also validated that Curl-based fetches still work and checksum properly.

Before I go on and do a Git handler, I want to run this implementation up the flag pole and get opinions. It's not very testable in its current form so I'll have to refactor that as well. I think I also have some puts statements in there that I need to clean up.

Thoughts?

lusis commented 12 years ago

Forgot to include an example recipe:

class Portal < FPM::Cookery::Recipe
  homepage          'http://mycompany.com'
  source            'https://svn-server/portal/trunk?15716' # query string here is optional. HEAD is used if missing
  handler           :svn
  name              'portal'

  def build
    safesystem('mvn', 'clean', 'package', '-U', '-DskipTests', '-Pprod')
  end

  def install
  end
end
jordansissel commented 12 years ago

What about instead of a handler, you just implement it like:

source "http://...." # assumes 'handler' is the url scheme.
source :http, :location => "http://...." same as above
source :svn, :location => "https://...", :revision => 15716
source :git, :location => "git@somehost.com:foo/foo.git", :hash => "some silly hash"

Or something.

That way you could implement your own 'source' plugins and you wouldn't need to introduce any extra top level methods (like handler, etc) for configuring them. Bonus that you don't need now to use strange URL query strings to indicate parameters to pass to your source handler.

Thoughts? Could be better ways to improve this, too.

lusis commented 12 years ago

yeah that would work. I was trying to keep the complexity in dsl to strings only but that approach works. @bernd let me know what you think and I'll hack it on in.

jordansissel commented 12 years ago

Strings-only is a decent goal, but shoving everything in a URL isn't delicious either, hmm.. Now I am conflicted.

bernd commented 12 years ago

Oups, reopen.

The source keyword already takes an optional hash. (:as) And for git/svn it makes sense to have :tag/:branch/:sha/:rev. (like Homebrew does) So I like Jordan's proposal.

lusis commented 12 years ago

Got it. I'll go down that route then.

bernd commented 12 years ago

Addition: I think we can use simple strings most of the time. "git://", "svn+http://", "hg://" are unambiguous and we don't need to explicitly select a source handler.

source "git://github.com/bernd/fpm-cookery.git" # => git
source :git, "https://github.com/bernd/fpm-cookery" # => git
lusis commented 12 years ago

So one thing I do in the noah-agent, is have plugins set an attribute/constant that they register under:

e.g. https://github.com/lusis/noah-agent/blob/master/lib/noah-agent/handler/http.rb#L4 https://github.com/lusis/noah-agent/blob/master/lib/noah-agent/handler/dummy.rb#L4

So it's totally doable and easy enough to match on.

bernd commented 12 years ago

Nice, I like that!

lusis commented 12 years ago

Closing this. See Issue #7 for proper pull request.