8

Is there a way to to recompile from an edited source code via homebrew?

I did a change on the source user.hpp of Boost which I now want to recompile Boost with. I tried --build-from-source and --enable-bar but neither works, saying that it is already installed. The only way I can recompile is by reinstall but that simply overwrites the source code I changed.

Any idea?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Yasin
  • 609
  • 1
  • 10
  • 22

2 Answers2

6

First option Download the archive, edit the files, and zip the archive as homebrew does (same name and format).

If you kept the original folder structure created by Homebrew, you can put the modified archive in ~/Library/Caches/Homebrew and then try brew install -f. (the -f is maybe not strictly necessary but it may be need for the SHA-1 mismatch.)

More info on this blog.

Second option

Pulled out from the Homebrew wiki, install the package without homebrew and then link it with brew.

./configure --prefix=/usr/local/Cellar/foo/1.2 && make && make install && brew link foo
Kirell
  • 9,228
  • 4
  • 46
  • 61
  • Not really working! I copied the unzipped the Boost bottle containing source code and did the change, I then moved the zip file out of the cache folder and instead put the unzipped folder in there. But now when I run install, it wants to download the bottle. If I put the bottle back in too then it would just unzip the bottle itself and overwrite the folder I had there. – Yasin Jul 20 '15 at 09:24
  • Try to re-zipp the files exactly as if it was download by homebrew. – Kirell Jul 20 '15 at 09:25
  • It's not allowing me, gives the following SHA mismatch error. Anyway to get them be the same? Error: SHA256 mismatch Expected: fdfc204fc33ec79c99b9a74944c3e54bd78be4f7f15e260c0e2700a36dc7d3e5 Actual: 9e9cdeb960f97bb33034f4a333edac13811b57106484ab24825f0a5020b16815 Archive: /Library/Caches/Homebrew/boost-1.58.0.tar.bz2 To retry an incomplete download, remove the file above. – Yasin Jul 20 '15 at 09:55
  • You can use the -f flag to force the install. – Kirell Jul 20 '15 at 09:58
  • Ignore it. Got them to be similar. Now compiling. – Yasin Jul 20 '15 at 09:58
  • 3
    FWIW, I had to `brew uninstall ...` (instead of `brew reinstall ...`, which caches brew installation flags I didn't want), then `brew install ...`, then copy the "expected" SHA that was output, then replace the old SHA in the formula (`brew edit ` opens the relevant file), then `brew install ...` again (`brew install -f` did not appear to ignore the SHA mismatch in my case -- in fact, I don't think the `-f`/`--force` option even exists anymore). – Braham Snyder Jul 26 '17 at 06:35
0

Another approach is to add a patch to the homebrew formula (you can edit the formula using brew edit <formula-name>): https://github.com/Homebrew/brew/blob/master/docs/Formula-Cookbook.md#patches

Braham Snyder
  • 511
  • 1
  • 6
  • 14