librelist archives

« back to archive

Improve info file support

Improve info file support

From:
Nicolas Desprès
Date:
2012-01-16 @ 11:41
Hi everybody,

Even if like it is mentionned here
https://github.com/mxcl/homebrew/issues/7989 "no body uses them" when
speaking about the info file, I personally do use them and thus have
set the HOMEBEW_KEEP_INFO environment variable.  I have spotted a
misbehavior when this option is set.  info files are correctly kept
but the info/dir files is linked and overwrite each time a new package
is installed. In fact instead of overwriting the info/dir file, users
should do something like:

$ /usr/bin/install-info
path/to/Cellar/gnu-sed/<version>/share/info/sed.info
/usr/local/share/info/dir

when they "brew install gnu-sed" for instance so that it appears
properly in the main table of contents. Also they have to set

$ export INFOPATH=/usr/loca/share/info:/usr/share/info

in their environment.

So I have started to write a patch that do so:

diff --git a/Library/Homebrew/cleaner.rb b/Library/Homebrew/cleaner.rb
index 426fbec..ecfe803 100644
--- a/Library/Homebrew/cleaner.rb
+++ b/Library/Homebrew/cleaner.rb
@@ -3,7 +3,16 @@ class Cleaner
     @f = Formula.factory f
     [f.bin, f.sbin, f.lib].select{ |d| d.exist? }.each{ |d| clean_dir d }

-    unless ENV['HOMEBREW_KEEP_INFO']
+    if ENV['HOMEBREW_KEEP_INFO']
+      f.info.find do |path|
+        case path.basename.to_s
+        when 'dir'
+          path.unlink
+        when /\.info$/
+          install_info path
+        end
+      end
+    else
       f.info.rmtree if f.info.directory? and not f.skip_clean? f.info
     end

@@ -76,4 +85,10 @@ class Cleaner
       end
     end
   end
+
+  def install_info path
+    system "/usr/bin/install-info '#{path}' #{HOMEBREW_PREFIX+share/info/dir}"
+    puts "install info: #{path}" if ARGV.verbose?
+  end
+
 end

It works well but then I figured out that I should remove the info
file from the info/dir file when a package is removed. Something like

$ /usr/bin/install-info --delete
path/to/Cellar/gnu-sed/<version>/share/info/sed.info
/usr/local/share/info/dir

must be run when the users do "brew uninstall gnu-sed".  I did not
write any code that support that, because after thinking a bit more, I
figured out that it should be more robust to handle such action when
users do "brew link <formula>" and "brew unlink <formula>".

I am new to homebrew code so if someone could help me and point me out
where I should write such code or if there is something wrong in my
approach.

TIA,

-- 
Nicolas Desprès

Re: [homebrew] Improve info file support

From:
Mike McQuaid
Date:
2012-01-16 @ 18:36
On 16 Jan 2012, at 11:41, Nicolas Desprès wrote:

> must be run when the users do "brew uninstall gnu-sed".  I did not
> write any code that support that, because after thinking a bit more, I
> figured out that it should be more robust to handle such action when
> users do "brew link <formula>" and "brew unlink <formula>".

We don't support hooks on uninstalling packages.

> I am new to homebrew code so if someone could help me and point me out
> where I should write such code or if there is something wrong in my
> approach.

I suggest writing this in a fork and creating a pull request for feedback.

--
Mike McQuaid
http://mikemcquaid.com

Re: [homebrew] Improve info file support

From:
Nicolas Desprès
Date:
2012-01-16 @ 18:53
On Mon, Jan 16, 2012 at 7:36 PM, Mike McQuaid <mike@mikemcquaid.com> wrote:
>
> On 16 Jan 2012, at 11:41, Nicolas Desprès wrote:
>
>> must be run when the users do "brew uninstall gnu-sed".  I did not
>> write any code that support that, because after thinking a bit more, I
>> figured out that it should be more robust to handle such action when
>> users do "brew link <formula>" and "brew unlink <formula>".
>
> We don't support hooks on uninstalling packages.

Ok so I will try to write the logic at the link/unlink stage directly
under the condition of the HOMEBREW_KEEP_INFO variable.

>
>> I am new to homebrew code so if someone could help me and point me out
>> where I should write such code or if there is something wrong in my
>> approach.
>
> I suggest writing this in a fork and creating a pull request for feedback.

I'm on the way to do it :)

Thx for your help.

-- 
Nicolas Desprès

Re: [homebrew] Improve info file support

From:
Nicolas Desprès
Date:
2012-01-21 @ 02:21
2012/1/16 Nicolas Desprès <nicolas.despres@gmail.com>:
> On Mon, Jan 16, 2012 at 7:36 PM, Mike McQuaid <mike@mikemcquaid.com> wrote:
>>
[...]
>> I suggest writing this in a fork and creating a pull request for feedback.
>
> I'm on the way to do it :)
>

Pull request sent: https://github.com/mxcl/homebrew/pull/9700

Thanks,

-- 
Nicolas Desprès

Re: [homebrew] Improve info file support

From:
Nicolas Desprès
Date:
2012-01-22 @ 17:09
2012/1/21 Nicolas Desprès <nicolas.despres@gmail.com>:
> 2012/1/16 Nicolas Desprès <nicolas.despres@gmail.com>:
>> On Mon, Jan 16, 2012 at 7:36 PM, Mike McQuaid <mike@mikemcquaid.com> wrote:
>>>
> [...]
>>> I suggest writing this in a fork and creating a pull request for feedback.
>>
>> I'm on the way to do it :)
>>
>
> Pull request sent: https://github.com/mxcl/homebrew/pull/9700

Re-pushed with a simpler implementation:

The share/info/dir file gets removed by the cleaner in the cellar
because we don't need it at all and because it bother us at link stage
(we have to skip it).

TIA for the review.

Cheers,
-Nico