Dep naming

28 views
Skip to first unread message

dkam

unread,
Nov 16, 2011, 4:22:01 AM11/16/11
to babushka_app
Hi guys,
This file from Ben's repo: https://github.com/benhoskings/babushka-deps/blob/master/packages.rb
Has this dep:

dep 'libxml.managed' do
installs { via :apt, 'libxml2-dev' }
provides []
end

Why isn't this just:

dep 'libxml2-dev.managed'

Or, to ask a different way, why can I run:

babushka curl.managed

But not:

babushka libxml2-dev.managed

When both packages are available by aptitude install?

Cheers,
Dan

Bodaniel Jeanes

unread,
Nov 16, 2011, 9:30:35 AM11/16/11
to babush...@googlegroups.com
Hey Dan,

The reason for the difference is because the default '.managed' deps will try to verify the install by checking for a binary in the PATH of the same name. libxml2-dev does not provide any binaries as it is just a library. 'libxml2-dev' is also the Debian-specific package name, so calling the dep 'libxml' and just overriding how it is installed via 'apt-get' allows it to work on more than one platform (and/or opens up the dep to be easily extended for other platforms).

Hope that helps!

- Bo

> --
> To post, email babush...@googlegroups.com
> To unsubscribe, email babushka_app...@googlegroups.com
> ~
> http://babushka.me
> http://github.com/benhoskings/babushka
> http://groups.google.com/group/babushka_app

Ben Hoskings

unread,
Nov 16, 2011, 9:49:29 PM11/16/11
to babush...@googlegroups.com
What Bo said :)

The idea is that from the point that I want to pull in libxml (say, from a dep that involves installing nokogiri, or something), I don't want to have to remember the specific package name; I want to just say "this requires libxml".

It also means you could add a 'via :yum' or similar alongside the 'via :apt', since fedora probably has a different package name. That way, you don't have to remember either of them.

- Ben

Dan Milne

unread,
Nov 16, 2011, 11:01:37 PM11/16/11
to babush...@googlegroups.com
Ahh - thanks for clearing that up. It's the word "managed" which made me think it was managed by apt.

Why isn't the dep simply "libxml" then? Such as:

dep 'libxml' do


installs { via :apt, 'libxml2-dev' }
provides []
end

In this case, is it just a convention stating this dep is managed by the local package manager?

Cheers,
Dan

--
Dan Milne d...@nmilne.com
http://da.nmilne.com/
http://booko.com.au/

Ben Hoskings

unread,
Nov 16, 2011, 11:12:48 PM11/16/11
to babush...@googlegroups.com
If it were just 'libxml', then it would be a standard dep, within which #installs and #provides aren't defined.

'libxml.managed' means it's defined against the 'managed' dep template, which uses the values of #installs and #provides to build a normal dep with met?{} and meet{} blocks.

Check deps/templates/managed.rb for the definition. It's a bit convoluted because the same block of code is used in multiple templates.

A simpler example is deps/templates/tmbundle.rb - the 'tmbundle' template knows how to download and install a TextMate bundle given just its URL.

The idea is that you can just say source 'http://...' and let the template write the dep, instead of repeating the same met?{} and meet{} each time.

(The ones bundled with babushka aren't special; they're just common ones that most people will want to use. You can write your own and store them alongside your deps.

- Ben

Paul Annesley

unread,
Nov 17, 2011, 12:40:35 AM11/17/11
to babush...@googlegroups.com
I think "name.template" is a leaky abstraction. I prefer this:

dep "libxml", template: "managed" do
  # …
end

The contract of the dep is to ensure libxml is present.
The fact that it currently uses a template called "managed" to achieve this is an implementation detail.

That said, the "name.type" convention like "whatever.tmbundle" does make sense; it describes the thing being installed, not how it will be achieved.

- Paul

Ben Hoskings

unread,
Nov 17, 2011, 12:51:15 AM11/17/11
to babush...@googlegroups.com
Mm, I agree with Paul. It's a mistake for me to put '.managed' in the name for those deps. I was being lazy. :)

The real purpose of suffixes is for deps whose suffixes are part of their identity, like gems and tmbundles. It means you can say

dep 'RSpec.tmbundle'

and have it do the right thing, instead of having to say

dep 'RSpec.tmbundle', template: 'tmbundle'

(The dep is defined in the same way whether you specify the template as a suffix or an option.)

- Ben

Paul Annesley

unread,
Nov 17, 2011, 12:58:27 AM11/17/11
to babush...@googlegroups.com
On Thursday, 17 November 2011 at 4:51 PM, Ben Hoskings wrote:
The real purpose of suffixes is for deps whose suffixes are part of their identity, like gems and tmbundles. It means you can say

dep 'RSpec.tmbundle'

and have it do the right thing, instead of having to say

dep 'RSpec.tmbundle', template: 'tmbundle'

(The dep is defined in the same way whether you specify the template as a suffix or an option.)


Yep, that's a nice convenience which makes sense as long as the suffix template can be overridden by a { template: 'another' } option.

Ben Hoskings

unread,
Nov 17, 2011, 1:09:35 AM11/17/11
to babush...@googlegroups.com

Dan Milne

unread,
Nov 17, 2011, 6:42:05 AM11/17/11
to babush...@googlegroups.com
Ahhh - that makes sense now.

I like idea of being explicit with the template name with the "managed" deps.

Thanks for the help guys.

Cheers,
Dan

--

Reply all
Reply to author
Forward
0 new messages