Last active
March 7, 2019 06:36
-
-
Save tuupola/3749a9fc873cf3504b1283dbc420a5ba to your computer and use it in GitHub Desktop.
Avoid Error: node08: Unsupported special dependency :python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node08 < Formula | |
desc "Platform built on V8 to build network applications" | |
homepage "https://nodejs.org/" | |
url "https://nodejs.org/dist/v0.8.28/node-v0.8.28.tar.gz" | |
sha256 "50e9a4282a741c923bd41c3ebb76698edbd7b1324024fe70cedc1e34b782d44f" | |
bottle do | |
sha256 "f6bd80020b36c6558891c3046978b863e4252f5308d006e697e040a2827a7757" => :el_capitan | |
sha256 "3f6e33df20eece207138af79b7fb323c41ef91d38d97f096f749fafa557cd8af" => :yosemite | |
sha256 "e4fa19c0d05ba11914f8faac32bf5b990f015e55e5ee60be7fb4145c96798b36" => :mavericks | |
end | |
option "with-debug", "Build with debugger hooks" | |
option "without-npm", "npm will not be installed" | |
option "with-system-zlib", "Use the system zlib rather than the bundled" | |
deprecated_option "enable-debug" => "with-debug" | |
depends_on "python@2" => :build | |
depends_on "pkg-config" => :build | |
depends_on "openssl" | |
depends_on "v8" => :optional | |
fails_with :llvm do | |
build 2326 | |
end | |
resource "npm" do | |
url "https://registry.npmjs.org/npm/-/npm-2.14.4.tgz" | |
sha256 "c8b602de5d51f956aa8f9c34d89be38b2df3b7c25ff6588030eb8224b070db27" | |
end | |
conflicts_with "node", | |
:because => "Differing versions of the same formulae." | |
def install | |
# Lie to `xcode-select` for now to work around a GYP bug that affects | |
# CLT-only systems: | |
# | |
# https://code.google.com/p/gyp/issues/detail?id=292 | |
# joyent/node#3681 | |
ENV["DEVELOPER_DIR"] = "#{OS::Mac.active_developer_dir}/usr/bin" unless MacOS::Xcode.installed? | |
args = %W[--prefix=#{prefix} --without-npm --shared-openssl] | |
args << "--shared-v8" if build.with? "v8" | |
args << "--shared-zlib" if build.with? "system-zlib" | |
args << "--debug" if build.with? "debug" | |
system "./configure", *args | |
system "make", "install" | |
if build.with? "npm" | |
resource("npm").stage buildpath/"npm_install" | |
# make sure npm can find node | |
ENV.prepend_path "PATH", bin | |
# make sure user prefix settings in $HOME are ignored | |
ENV["HOME"] = buildpath/"home" | |
# set log level temporarily for npm's `make install` | |
ENV["NPM_CONFIG_LOGLEVEL"] = "verbose" | |
cd buildpath/"npm_install" do | |
system "./configure", "--prefix=#{libexec}/npm" | |
system "make", "install" | |
end | |
end | |
end | |
def post_install | |
return if build.without? "npm" | |
node_modules = HOMEBREW_PREFIX/"lib/node_modules" | |
node_modules.mkpath | |
npm_exec = node_modules/"npm/bin/npm-cli.js" | |
# Kill npm but preserve all other modules across node updates/upgrades. | |
rm_rf node_modules/"npm" | |
cp_r libexec/"npm/lib/node_modules/npm", node_modules | |
# This symlink doesn't hop into homebrew_prefix/bin automatically so | |
# remove it and make our own. This is a small consequence of our bottle | |
# npm make install workaround. All other installs **do** symlink to | |
# homebrew_prefix/bin correctly. We ln rather than cp this because doing | |
# so mimics npm's normal install. | |
ln_sf npm_exec, "#{HOMEBREW_PREFIX}/bin/npm" | |
# Let's do the manpage dance. It's just a jump to the left. | |
# And then a step to the right, with your hand on rm_f. | |
["man1", "man3", "man5", "man7"].each do |man| | |
# Dirs must exist first: https://github.com/Homebrew/homebrew/issues/35969 | |
mkdir_p HOMEBREW_PREFIX/"share/man/#{man}" | |
rm_f Dir[HOMEBREW_PREFIX/"share/man/#{man}/{npm.,npm-,npmrc.}*"] | |
ln_sf Dir[libexec/"npm/lib/node_modules/npm/man/#{man}/npm*"], HOMEBREW_PREFIX/"share/man/#{man}" | |
end | |
npm_root = node_modules/"npm" | |
npmrc = npm_root/"npmrc" | |
npmrc.atomic_write("prefix = #{HOMEBREW_PREFIX}\n") | |
end | |
def caveats | |
s = "" | |
if build.without? "npm" | |
s += <<-EOS.undent | |
Homebrew has NOT installed npm. If you later install it, you should supplement | |
your NODE_PATH with the npm module folder: | |
#{HOMEBREW_PREFIX}/lib/node_modules | |
EOS | |
end | |
s | |
end | |
test do | |
path = testpath/"test.js" | |
path.write "console.log('hello');" | |
output = `#{bin}/node #{path}`.strip | |
assert_equal "hello", output | |
assert_equal 0, $?.exitstatus | |
if build.with? "npm" | |
# make sure npm can find node | |
ENV.prepend_path "PATH", opt_bin | |
assert_equal which("node"), opt_bin/"node" | |
assert (HOMEBREW_PREFIX/"bin/npm").exist?, "npm must exist" | |
assert (HOMEBREW_PREFIX/"bin/npm").executable?, "npm must be executable" | |
system "#{HOMEBREW_PREFIX}/bin/npm", "--verbose", "install", "npm@latest" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment