Permalink
Browse files

Add formula for unac.

unac is a C library and command that removes accents from a string. For instance the string été will become ete. It provides a command line interface that removes accents from a input flow or a string given in argument (unaccent command).

This package is what I would consider to be extremely stable. Even though the project was somewhat abandoned in the 2002-2004 timeframe, Debian has continued to ensure the package works. The formula gets the code and patches from them, then makes local patches in order to compile properly under Mac OS.
  • Loading branch information...
1 parent c5d69ae commit 0a0cad381bfccf9d7d286f8d76c0d2fed792dbbe @smgoller committed Oct 4, 2012
Showing with 49 additions and 0 deletions.
  1. +49 −0 Library/Formula/unac.rb
View
@@ -0,0 +1,49 @@
+require 'formula'
+
+class Unac < Formula
+ homepage ''
+ url 'http://ftp.de.debian.org/debian/pool/main/u/unac/unac_1.8.0.orig.tar.gz'
+ sha1 '3e779bb7f3b505880ac4f43b48ee2f935ef8aa36'
+
+ depends_on 'gettext' => :build
+ depends_on 'autoconf' => :build
+ depends_on 'automake' => :build
@adamv

adamv Oct 4, 2012

autoconf and automake should use :symbol syntax too I think?

+ depends_on :libtool => :build
+
+ def patches
+ {
+ :p0 => ["http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=patch-libunac1.txt;att=1;bug=623340",
+ "http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=10;filename=patch-unaccent.c.txt;att=1;bug=623340"],
+ :p1 => ["http://ftp.de.debian.org/debian/pool/main/u/unac/unac_1.8.0-6.diff.gz",
+ DATA]
@adamv

adamv Oct 4, 2012

Please document the DATA patch.

+ }
+ end
+
+ def install
+ system "chmod","+x","./configure"
+ touch "config.rpath"
+ inreplace "autogen.sh", "libtool", "glibtool"
+ system "./autogen.sh"
+ system "./configure", "--disable-debug", "--disable-dependency-tracking",
+ "--prefix=#{prefix}"
+ system "make install"
+ end
+
+ def test
+ `#{bin}/unaccent utf-8 fóó`.chomp == 'foo'
@adamv

adamv Oct 4, 2012

Does this...break ruby?

@smgoller

smgoller Oct 4, 2012

Owner

Does it? I got the test from mistym, who knows way more about ruby than I do. I didn't write it.

@mistydemeo

mistydemeo Oct 4, 2012

Ruby 1.8 doesn't care because all chars are just bytes; it has no concept of encoding. Ruby 1.9 would throw a fit though.

@mistydemeo

mistydemeo Oct 4, 2012

Add this line as the very first in the line and it works on Ruby 1.9 too:

# -*- coding: utf-8 -*-

+ end
+end
+
+__END__
+diff --git a/configure.ac b/configure.ac
+index 4a4eab6..9f25d50 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -49,6 +49,7 @@ AM_MAINTAINER_MODE
+
+ AM_ICONV
+
++LIBS="$LIBS -liconv"
+ AC_CHECK_FUNCS(iconv_open,,AC_MSG_ERROR([
+ iconv_open not found try to install replacement from
+ http://www.gnu.org/software/libiconv/

0 comments on commit 0a0cad3

Please sign in to comment.