You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Danny O'Connor <da...@propylon.com> on 2010/01/27 12:31:27 UTC

Getting access to bin directory in packaging extension

Hi There,

I'm doing an rpm packaging extension,

I'm running into a problem defining the 'top dir' and 'build dir' for 
the rpm, at the moment I have:

module Buildr

   class PackageRPMTask < ArchiveTask

     def initialize(root, path)
       @temp_working_dir = File.join(Dir.tmpdir(), "buildr.#{$$}")
       @rpm_top_dir = "#{@temp_working_dir}/buildr/rpm_top_dir"
       @rpm_build_root = "#{@temp_working_dir}/buildr/rpm_build_root"
       @target = "noarch"
       super
     end

Instead of using a temporary directory though, it might be nicer to use 
a folder in the 'bin' directory of the local build workspace.

Does anybody know the best way to get access to it in the task definition ?

I've attached the source of what I have so far, it works at the moment, 
you can use it like any other archive packaging format:

package(:rpm).with(:spec => RPM_SPEC_STRING)
package(:rpm).include("etc/myserviceinitd", :as => 
"/etc/init.d/myservicectl") .. etc.


Thanks,
Danny.


Re: Getting access to bin directory in packaging extension

Posted by Antoine Toulme <an...@lunar-ocean.com>.
On Wed, Jan 27, 2010 at 08:10, Antoine Toulme <an...@lunar-ocean.com>wrote:

> Yep, no, it won't work. It's a limitation/bug of the deb packaging, I
> should have used path_to.
>
> Grab the project to be able to call path_to on it. When you create the
> task, make sure to have the project associated with it.
>
> Grep the buildr code for a private method called associate_to if needed.
>
Sorry "associate_with".

>
> On Wed, Jan 27, 2010 at 08:00, Danny O'Connor <da...@propylon.com>wrote:
>
>> Cheers for the reply,
>>
>> I don't seem to have access to the 'path_to' function in the constructor
>> of the task ( undefined method `_' for #<Buildr::PackageRPMTask:0x3717ee94>
>> )
>>
>> I see in your code you've done:
>>
>>
>> root = File.join("target", "_#{File.basename(name)}")
>>
>> If you have subprojects will using "target" directly like that work ?
>>
>> I thought that was the idea of the path_to function,
>>
>> Thanks again,
>> Danny.
>>
>>
>> Antoine Toulme wrote:
>>
>>> You mean you want to use the target directory of the project.
>>>
>>> How about _(:target, :rpm)
>>>
>>> and then:
>>> _(:target, :rpm, :top_dir)
>>> _(:target, :rpm, :build_root)
>>>
>>> See also:
>>>
>>>
>>> http://github.com/intalio/package_as_deb/blob/master/lib/buildrdeb/package.rb
>>> which implements a different strategy, using the name of the task so that
>>> you can have more than one deb packaging per project:
>>>
>>> root = File.join("target", "_#{File.basename(name)}")
>>> mkpath File.join(root, "DEBIAN")
>>>
>>>
>>> Thanks,
>>>
>>> Antoine
>>>
>>> On Wed, Jan 27, 2010 at 03:31, Danny O'Connor <
>>> danny.oconnor@propylon.com>wrote:
>>>
>>>  Hi There,
>>>>
>>>> I'm doing an rpm packaging extension,
>>>>
>>>> I'm running into a problem defining the 'top dir' and 'build dir' for
>>>> the
>>>> rpm, at the moment I have:
>>>>
>>>> module Buildr
>>>>
>>>>  class PackageRPMTask < ArchiveTask
>>>>
>>>>   def initialize(root, path)
>>>>     @temp_working_dir = File.join(Dir.tmpdir(), "buildr.#{$$}")
>>>>     @rpm_top_dir = "#{@temp_working_dir}/buildr/rpm_top_dir"
>>>>     @rpm_build_root = "#{@temp_working_dir}/buildr/rpm_build_root"
>>>>     @target = "noarch"
>>>>     super
>>>>   end
>>>>
>>>> Instead of using a temporary directory though, it might be nicer to use
>>>> a
>>>> folder in the 'bin' directory of the local build workspace.
>>>>
>>>> Does anybody know the best way to get access to it in the task
>>>> definition ?
>>>>
>>>> I've attached the source of what I have so far, it works at the moment,
>>>> you
>>>> can use it like any other archive packaging format:
>>>>
>>>> package(:rpm).with(:spec => RPM_SPEC_STRING)
>>>> package(:rpm).include("etc/myserviceinitd", :as =>
>>>> "/etc/init.d/myservicectl") .. etc.
>>>>
>>>>
>>>> Thanks,
>>>> Danny.
>>>>
>>>>
>>>>
>>>
>>
>

Re: Getting access to bin directory in packaging extension

Posted by Antoine Toulme <an...@lunar-ocean.com>.
Yep, no, it won't work. It's a limitation/bug of the deb packaging, I should
have used path_to.

Grab the project to be able to call path_to on it. When you create the task,
make sure to have the project associated with it.

Grep the buildr code for a private method called associate_to if needed.

On Wed, Jan 27, 2010 at 08:00, Danny O'Connor <da...@propylon.com>wrote:

> Cheers for the reply,
>
> I don't seem to have access to the 'path_to' function in the constructor of
> the task ( undefined method `_' for #<Buildr::PackageRPMTask:0x3717ee94> )
>
> I see in your code you've done:
>
>
> root = File.join("target", "_#{File.basename(name)}")
>
> If you have subprojects will using "target" directly like that work ?
>
> I thought that was the idea of the path_to function,
>
> Thanks again,
> Danny.
>
>
> Antoine Toulme wrote:
>
>> You mean you want to use the target directory of the project.
>>
>> How about _(:target, :rpm)
>>
>> and then:
>> _(:target, :rpm, :top_dir)
>> _(:target, :rpm, :build_root)
>>
>> See also:
>>
>>
>> http://github.com/intalio/package_as_deb/blob/master/lib/buildrdeb/package.rb
>> which implements a different strategy, using the name of the task so that
>> you can have more than one deb packaging per project:
>>
>> root = File.join("target", "_#{File.basename(name)}")
>> mkpath File.join(root, "DEBIAN")
>>
>>
>> Thanks,
>>
>> Antoine
>>
>> On Wed, Jan 27, 2010 at 03:31, Danny O'Connor <danny.oconnor@propylon.com
>> >wrote:
>>
>>  Hi There,
>>>
>>> I'm doing an rpm packaging extension,
>>>
>>> I'm running into a problem defining the 'top dir' and 'build dir' for the
>>> rpm, at the moment I have:
>>>
>>> module Buildr
>>>
>>>  class PackageRPMTask < ArchiveTask
>>>
>>>   def initialize(root, path)
>>>     @temp_working_dir = File.join(Dir.tmpdir(), "buildr.#{$$}")
>>>     @rpm_top_dir = "#{@temp_working_dir}/buildr/rpm_top_dir"
>>>     @rpm_build_root = "#{@temp_working_dir}/buildr/rpm_build_root"
>>>     @target = "noarch"
>>>     super
>>>   end
>>>
>>> Instead of using a temporary directory though, it might be nicer to use a
>>> folder in the 'bin' directory of the local build workspace.
>>>
>>> Does anybody know the best way to get access to it in the task definition
>>> ?
>>>
>>> I've attached the source of what I have so far, it works at the moment,
>>> you
>>> can use it like any other archive packaging format:
>>>
>>> package(:rpm).with(:spec => RPM_SPEC_STRING)
>>> package(:rpm).include("etc/myserviceinitd", :as =>
>>> "/etc/init.d/myservicectl") .. etc.
>>>
>>>
>>> Thanks,
>>> Danny.
>>>
>>>
>>>
>>
>

Re: Getting access to bin directory in packaging extension

Posted by Danny O'Connor <da...@propylon.com>.
Cheers for the reply,

I don't seem to have access to the 'path_to' function in the constructor 
of the task ( undefined method `_' for 
#<Buildr::PackageRPMTask:0x3717ee94> )

I see in your code you've done:

root = File.join("target", "_#{File.basename(name)}")

If you have subprojects will using "target" directly like that work ?

I thought that was the idea of the path_to function,

Thanks again,
Danny.

Antoine Toulme wrote:
> You mean you want to use the target directory of the project.
> 
> How about _(:target, :rpm)
> 
> and then:
> _(:target, :rpm, :top_dir)
> _(:target, :rpm, :build_root)
> 
> See also:
> 
> http://github.com/intalio/package_as_deb/blob/master/lib/buildrdeb/package.rb
> which implements a different strategy, using the name of the task so that
> you can have more than one deb packaging per project:
> 
> root = File.join("target", "_#{File.basename(name)}")
> mkpath File.join(root, "DEBIAN")
> 
> 
> Thanks,
> 
> Antoine
> 
> On Wed, Jan 27, 2010 at 03:31, Danny O'Connor <da...@propylon.com>wrote:
> 
>> Hi There,
>>
>> I'm doing an rpm packaging extension,
>>
>> I'm running into a problem defining the 'top dir' and 'build dir' for the
>> rpm, at the moment I have:
>>
>> module Buildr
>>
>>  class PackageRPMTask < ArchiveTask
>>
>>    def initialize(root, path)
>>      @temp_working_dir = File.join(Dir.tmpdir(), "buildr.#{$$}")
>>      @rpm_top_dir = "#{@temp_working_dir}/buildr/rpm_top_dir"
>>      @rpm_build_root = "#{@temp_working_dir}/buildr/rpm_build_root"
>>      @target = "noarch"
>>      super
>>    end
>>
>> Instead of using a temporary directory though, it might be nicer to use a
>> folder in the 'bin' directory of the local build workspace.
>>
>> Does anybody know the best way to get access to it in the task definition ?
>>
>> I've attached the source of what I have so far, it works at the moment, you
>> can use it like any other archive packaging format:
>>
>> package(:rpm).with(:spec => RPM_SPEC_STRING)
>> package(:rpm).include("etc/myserviceinitd", :as =>
>> "/etc/init.d/myservicectl") .. etc.
>>
>>
>> Thanks,
>> Danny.
>>
>>
> 


Re: Getting access to bin directory in packaging extension

Posted by Antoine Toulme <an...@lunar-ocean.com>.
You mean you want to use the target directory of the project.

How about _(:target, :rpm)

and then:
_(:target, :rpm, :top_dir)
_(:target, :rpm, :build_root)

See also:

http://github.com/intalio/package_as_deb/blob/master/lib/buildrdeb/package.rb
which implements a different strategy, using the name of the task so that
you can have more than one deb packaging per project:

root = File.join("target", "_#{File.basename(name)}")
mkpath File.join(root, "DEBIAN")


Thanks,

Antoine

On Wed, Jan 27, 2010 at 03:31, Danny O'Connor <da...@propylon.com>wrote:

> Hi There,
>
> I'm doing an rpm packaging extension,
>
> I'm running into a problem defining the 'top dir' and 'build dir' for the
> rpm, at the moment I have:
>
> module Buildr
>
>  class PackageRPMTask < ArchiveTask
>
>    def initialize(root, path)
>      @temp_working_dir = File.join(Dir.tmpdir(), "buildr.#{$$}")
>      @rpm_top_dir = "#{@temp_working_dir}/buildr/rpm_top_dir"
>      @rpm_build_root = "#{@temp_working_dir}/buildr/rpm_build_root"
>      @target = "noarch"
>      super
>    end
>
> Instead of using a temporary directory though, it might be nicer to use a
> folder in the 'bin' directory of the local build workspace.
>
> Does anybody know the best way to get access to it in the task definition ?
>
> I've attached the source of what I have so far, it works at the moment, you
> can use it like any other archive packaging format:
>
> package(:rpm).with(:spec => RPM_SPEC_STRING)
> package(:rpm).include("etc/myserviceinitd", :as =>
> "/etc/init.d/myservicectl") .. etc.
>
>
> Thanks,
> Danny.
>
>