LoginSignup
3
3

More than 5 years have passed since last update.

homebrewでmapserverをインストールしたときのエラー

Posted at

homebrewを利用して、mapserverをインストールしようとしたところ、以下のようなエラーが発生した。

$ brew install mapserver --with-cairo --with-fastcgi --with-geos --with-php --with-postgresql

・・・
==> Downloading http://download.osgeo.org/mapserver/mapserver-6.2.2.tar.gz
Already downloaded: /Library/Caches/Homebrew/mapserver-6.2.2.tar.gz
==> Patching
patching file mapscript/python/setup.py
Hunk #1 FAILED at 32.
Hunk #2 FAILED at 149.
2 out of 3 hunks FAILED -- saving rejects to file mapscript/python/setup.py.rej
Error: Failure while executing: /usr/bin/patch -g 0 -f -p1

毎度のことながら、サクッと一発でインストールできないものかと。。。ただ、こういったエラーに遭遇することは、自分のスキルアップのきっかけにもなるので、前向きに向き合うことに。

まずはエラーメッセージを確認

どうもpatchを適用しようとして、エラーになっている節が見受けられる。
この時点では、何が何やらさっぱり訳がわからなかったので、まずはmapserverのformula(:ビルド手順)を確認することにした。

なお、mapserverのformulaは、以下のコマンドで確認できる。 

$ brew edit mapserver

mapserverのformulaを見てみると

気になる箇所を一箇所見つけた!!

class Mapserver < Formula
  desc "Publish spatial data and interactive mapping apps to the web"
  homepage 'http://mapserver.org/'
  url 'http://download.osgeo.org/mapserver/mapserver-6.2.2.tar.gz'
  sha256 '79b81286dde030704f59a668a19e5b01af27bb35d05b3daf91cefe06ca29ffd9'
・・・
  # This patch can be removed when this is merged https://github.com/mapserver/mapserver/pull/5113
  patch :DATA

  def install
    args = [
      "--prefix=#{prefix}",
      "--with-proj",
      "--with-gdal",
      "--with-ogr",
      "--with-wfs",
    ]
・・・

注目したいのは、この箇所

# This patch can be removed when this is merged https://github.com/mapserver/mapserver/pull/5113
patch :DATA

コメントを確認すると、https://github.com/mapserver/mapserver/pull/5113がマージされたときは、このパッチは削除して良いよと書いてある。

で実際に、そのサイトを辿って確認すると

This fixes build with homebrew. It should probably be also applied to 6.4 and 7.0.

多分、mapserverのVer6.0かV7.0に適用したほうが良いんじゃないかと書いている。

mapserverのバージョン確認

2015/07/18現在、homebrewでインストールできるmapserverのバージョンを調べてみると、

$ brew info mapserver
mapserver: stable 6.2.2 (bottled)
・・・

ん? 6.2.2がインストールされる?
ということは、今回のパッチは適用しなくても良いのだろうか???

試しに、mapserverのformulaを以下のように変更して、再度インストールを試みてみた。

# This patch can be removed when this is merged https://github.com/mapserver/mapserver/pull/5113
#patch :DATA // 今回コメントアウトした。

結果として

以下の結果の通り。うまくインストールできた。

$ brew install mapserver --with-cairo --with-fastcgi --with-geos --with-php --with-postgresql
==> Downloading http://download.osgeo.org/mapserver/mapserver-6.2.2.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/mapserver/6.2.2 --with-proj --with-gdal --with-ogr --with-wfs --with-geos --with-php=/usr/bin/php
==> make
==> make install PHP_EXT_DIR=/usr/local/Cellar/mapserver/6.2.2
==> Caveats
The Mapserver CGI executable is /usr/local/Cellar/mapserver/6.2.2/bin/mapserv

If you built the PHP option:
  * Add the following line to php.ini:
    extension="/usr/local/Cellar/mapserver/6.2.2/php_mapscript.so"
  * Execute "php -m"
  * You should see MapScript in the module list

==> Summary
🍺  /usr/local/Cellar/mapserver/6.2.2: 17 files, 2.1M, built in 29 seconds

patchをコメントアウトした影響については、よく分かっていないが、僕的にはphpでmapscriptとpostgresqlへの接続が上手くいけば、ひとまずは用足りるので、これで進めることにした。

3
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3