Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Upgrade FreeImage #7320

Closed
wants to merge 1 commit into from
Closed

Upgrade FreeImage #7320

wants to merge 1 commit into from

Conversation

krisselden
Copy link

Previous versions of FreeImage will segfault on bad Exif data.

@Sharpie
Copy link
Contributor

Sharpie commented Aug 31, 2011

When trying to install, the patch utterly fails:

==> Downloading http://downloads.sourceforge.net/project/freeimage/Source%20Distribution/3.15.1/FreeImage3151.zip
/usr/bin/curl -f#LA Homebrew 0.8 (Ruby 1.8.7-174; Mac OS X 10.6.8) http://downloads.sourceforge.net/project/freeimage/Source%20Distribution/3.15.1/FreeImage3151.zip -o /Users/sharpie/Library/Caches/Homebrew/freeimage-3.15.1.zip
######################################################################## 100.0%
/usr/bin/unzip -aqq /Users/sharpie/Library/Caches/Homebrew/freeimage-3.15.1.zip
==> Patching
/usr/bin/patch -f -p1 -i 001-homebrew.diff
patching file Makefile.gnu
Hunk #1 FAILED at 5.
Hunk #2 FAILED at 28.
Hunk #3 FAILED at 41.
Hunk #4 FAILED at 56.
4 out of 4 hunks FAILED -- saving rejects to file Makefile.gnu.rej
Error: Failure while executing: /usr/bin/patch -f -p1 -i 001-homebrew.diff

Is there some way we could do away with that thing? Perhaps by using inreplace combined with change_make_var!? Details in the cookbook:

https://github.com/mxcl/homebrew/wiki/Formula-Cookbook

@krisselden
Copy link
Author

It did work on my machine but I had a lot of trouble with the CR LF characters and creating the patch.

I'll try your suggestion tonight.

@krisselden
Copy link
Author

I looked at using inreplace and change_make_var but would end up being mainly gsub and rewriting most the file. I could add a changle_make_var that not only changed the value but changed the variable name and search for instances of that variable. Also, would need to add a prepend_make_var(before_var, var, value).

I redid the patch, and I changed the unzip argument to -aa which treats every file as text and corrects the line endings.

Another option would be just to supply a Makefile that includes the Makefile.srcs since the patch is rewriting it almost entirely. The Makefile.osx that comes with FreeImage builds a universal binary and doesn't work on Lion.

Maybe I should try to get a non universal Makefile submitted back to FreeImage that is less fragile with OS upgrades.

Anyway, can you try the above patch? Let me know, if you still have problems I'll look at a different approach but unzip -a on my machine did not catch the line endings, only -aa.

@Sharpie
Copy link
Contributor

Sharpie commented Sep 1, 2011

I'll try the new patch when I get the chance.

Maybe I should try to get a non universal Makefile submitted back to FreeImage that is less fragile with OS upgrades.

Please do this---we try to get patches pushed back into upstream if possible. Thanks for all the effort!

@adamv
Copy link
Contributor

adamv commented Nov 27, 2011

Freeimage is now at 3.15.1 in Homebrew.

@adamv adamv closed this Nov 27, 2011
@jrminter
Copy link

hate to say this, but the patch now fails when i try to upgrade freeiamge:

==> Downloading http://downloads.sourceforge.net/project/freeimage/Source%20Dist
File already downloaded in /Users/jrminter/Library/Caches/Homebrew
==> Patching
patching file Makefile.gnu
Hunk #4 FAILED at 58.
1 out of 4 hunks FAILED -- saving rejects to file Makefile.gnu.rej
patching file Makefile.fip
Error: Failure while executing: /usr/bin/patch -f -p1 -i 001-homebrew.diff

@Sharpie
Copy link
Contributor

Sharpie commented Nov 29, 2011

hate to say this, but the patch now fails when i try to upgrade freeiamge:

Hmm... the patch isn't commented at all, so I have no idea what it does, why it is needed or how to fix it.

@dwalters

Looks like you were the original author of this patch---any ideas?

@dwalters-zz
Copy link
Contributor

Wow, that's a long time ago! Don't be harsh, I'm 99% sure I just did a direct port of what macports decided was necessary to do at the time.

Looks like things have improved, but the distributed Makefile.osx still contains a lot of things pertaining to building fat libs with ppc+i386+x86_64 support, specific OSX SDK versions, ignoring all of homebrew's optimization flags, etc., so I'd say it's still best to use the Makefile.gnu with some minor tweaks to accomodate linking on OSX (vs Linux.)

My quick version of bringing it up to date would be the following formula: https://gist.github.com/1403082

I don't know anything about freeimageplus, but imagine it's trivial, though.

@krisselden
Copy link
Author

The FreeImage Makefile.mac hardcodes paths to the system libraries that are OS version specific in order to build a fat binary for the binary dist.

The patch modifies the generic unix version of the makefile for the mac to avoid the hardcoded system paths so it works across OS versions and doesn't try to generate a fat binary.

When I first sent a pull request, my patch had whitespace issues, which I had thought I had addressed is the second version. The Makefile has windows new lines, and the unzip command line arg to deal with that is -aa not -a as it was in the original but maybe that is version specific to the unzip command?

@Sharpie
Copy link
Contributor

Sharpie commented Nov 29, 2011

I'm 99% sure I just did a direct port of what macports decided was necessary to do at the time.

Awesome! Thanks for the info. I don't see any patchfiles attached to FreeImage over on MacPorts:

https://trac.macports.org/browser/trunk/dports/graphics/freeimage/Portfile

So, was this patch generated by applying the reinplace changes they make?

@Homebrew Homebrew locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants