Navigation Menu

Skip to content

Commit

Permalink
Use Ruby to download MeCab
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 18, 2015
1 parent 939df8d commit 359454a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/source/Makefile.am
Expand Up @@ -43,6 +43,6 @@ files/$(PACKAGE)-$(VERSION)$(SUFFIX).tar.gz: $(abs_top_builddir)/$(PACKAGE)-$(VE
files/$(PACKAGE)-$(VERSION)$(SUFFIX).zip: files/$(PACKAGE)-$(VERSION)$(SUFFIX).tar.gz
rm -rf $(PACKAGE)-$(VERSION)$(SUFFIX)
tar xzf files/$(PACKAGE)-$(VERSION)$(SUFFIX).tar.gz
cd $(PACKAGE)-$(VERSION)$(SUFFIX)/vendor && ./download_mecab.sh
cd $(PACKAGE)-$(VERSION)$(SUFFIX)/vendor && $(RUBY) download_mecab.rb
zip -r $@ $(PACKAGE)-$(VERSION)$(SUFFIX)
rm -rf $(PACKAGE)-$(VERSION)$(SUFFIX)
3 changes: 2 additions & 1 deletion vendor/Makefile.am
Expand Up @@ -8,7 +8,8 @@ SUBDIRS = \
EXTRA_DIST = \
$(NGINX_DIR) \
CMakeLists.txt \
plugins/CMakeLists.txt
plugins/CMakeLists.txt \
download_mecab.rb

dist-hook:
rm -rf $(distdir)/$(NGINX_DIR)/objs/
Expand Down
34 changes: 34 additions & 0 deletions vendor/download_mecab.rb
@@ -0,0 +1,34 @@
#!/usr/bin/env ruby

require "pathname"
require "fileutils"
require "open-uri"

base_dir = Pathname.new(__FILE__).expand_path.dirname.parent

mecab_version = (base_dir + "bundled_mecab_version").read.strip
mecab_naist_jdic_version = (base_dir + "bundled_mecab_naist_jdic_version").read.strip

mecab_base = "mecab-#{mecab_version}"
mecab_naist_jdic_base = "mecab-naist-jdic-#{mecab_naist_jdic_version}"

def download(url, base)
tar = "#{base}.tar"
tar_gz = "#{tar}.gz"
open(url) do |remote_tar_gz|
File.open(tar_gz, "wb") do |local_tar_gz|
local_tar_gz.print(remote_tar_gz.read)
end
end
FileUtils.rm_rf(base)
system("7z", "x", tar_gz)
system("7z", "x", tar)
FileUtils.rm_rf(tar)
FileUtils.rm_rf(tar_gz)
end

download("https://drive.google.com/uc?export=download&id=0B4y35FiV1wh7cENtOXlicTFaRUE",
mecab_base)

download("http://osdn.dl.sourceforge.jp/naist-jdic/48487/#{mecab_naist_jdic_base}.tar.gz",
mecab_naist_jdic_base)
28 changes: 0 additions & 28 deletions vendor/download_mecab.sh

This file was deleted.

0 comments on commit 359454a

Please sign in to comment.