Mail archive
alpine-aports

[alpine-aports] [PATCH] testing/ocaml-gettext: new aport

From: Fernando Casas Schössow <casasfernando_at_outlook.com>
Date: Thu, 7 Feb 2019 22:52:44 +0000

https://github.com/gildor478/ocaml-gettext
OCaml library for i18n
---
 ...tracking-and-printing-untranslated-s.patch | 109 ++++++++++++++++++
 ...text-stop-printing-extracted-strings.patch |  26 +++++
 ...d-more-generated-files-to-.gitignore.patch |  44 +++++++
 testing/ocaml-gettext/APKBUILD                |  52 +++++++++
 .../ocaml-gettext-0.3.4-use-ocamlopt-g.patch  |  33 ++++++
 5 files changed, 264 insertions(+)
 create mode 100644 testing/ocaml-gettext/0001-pr_gettext-stop-tracking-and-printing-untranslated-s.patch
 create mode 100644 testing/ocaml-gettext/0002-pr_gettext-stop-printing-extracted-strings.patch
 create mode 100644 testing/ocaml-gettext/0003-add-more-generated-files-to-.gitignore.patch
 create mode 100644 testing/ocaml-gettext/APKBUILD
 create mode 100644 testing/ocaml-gettext/ocaml-gettext-0.3.4-use-ocamlopt-g.patch
diff --git a/testing/ocaml-gettext/0001-pr_gettext-stop-tracking-and-printing-untranslated-s.patch b/testing/ocaml-gettext/0001-pr_gettext-stop-tracking-and-printing-untranslated-s.patch
new file mode 100644
index 0000000000..511eb3b4a8
--- /dev/null
+++ b/testing/ocaml-gettext/0001-pr_gettext-stop-tracking-and-printing-untranslated-s.patch
_at_@ -0,0 +1,109 @@
+From 35d2d7381c7101bb73d0b7f00fea06442c7b2ab8 Mon Sep 17 00:00:00 2001
+From: Pino Toscano <ptoscano_at_redhat.com>
+Date: Tue, 29 Aug 2017 18:29:34 +0200
+Subject: [PATCH 1/3] pr_gettext: stop tracking (and printing) untranslated
+ strings
+
+Do not collect anymore the information of untranslated strings, since it
+is only used to print all of them at the end of the message extraction.
+
+While I understand the reason why this was done (i.e. to discover
+potentially untranslated user strings), this is something that just
+causes lots of output in complex projects, since strings are basically
+used for many non-UI tasks (say Str, Sys.command, etc), so the actual
+result is that there are lots of false positive.  Also, this is not
+something xgettext (from GNU gettext) does.
+---
+ libgettext-ocaml/pr_gettext.ml | 44 ------------------------------------------
+ 1 file changed, 44 deletions(-)
+
+diff --git a/libgettext-ocaml/pr_gettext.ml b/libgettext-ocaml/pr_gettext.ml
+index c44933f..d78cf21 100644
+--- a/libgettext-ocaml/pr_gettext.ml
++++ b/libgettext-ocaml/pr_gettext.ml
+_at_@ -71,17 +71,10 @@ struct
+   module Loc = Syntax.Loc
+   module Ast = Syntax.Ast
+ 
+-  type untranslated_t = 
+-      {
+-        str:        string; (* Real string, not OCaml one *)
+-        locations:  (string * int) list; (* Location in the file *)
+-      }
+-
+   type t = 
+       {
+         po_content:   po_content;
+         translated:   SetString.t;
+-        untranslated: untranslated_t MapString.t;
+       }
+ 
+   let string_of_ocaml_string str =
+_at_@ -91,29 +84,6 @@ struct
+       "%S"
+       (fun s -> s)
+ 
+-  let string_not_translated t ocaml_str = 
+-    not (SetString.mem ocaml_str t.translated)
+-
+-  let add_untranslated t loc ocaml_str = 
+-    let cur = 
+-      try 
+-        MapString.find ocaml_str t.untranslated 
+-      with Not_found ->
+-        {
+-          str = string_of_ocaml_string ocaml_str;
+-          locations = [];
+-        }
+-    in
+-    let untranslated =
+-      MapString.add 
+-        ocaml_str 
+-        {cur with 
+-             locations = 
+-               (Loc.file_name loc, Loc.start_line loc) :: cur.locations}
+-        t.untranslated
+-    in
+-      {t with untranslated = untranslated}
+-
+ 
+   let add_translation t loc ocaml_singular plural_opt domain =
+     let filepos = 
+_at_@ -164,15 +134,6 @@ struct
+         | Some f -> open_out f
+         | None -> stdout
+     in
+-      MapString.iter
+-        (fun _ {str = str; locations = locs} ->
+-           List.iter
+-             (fun (fn, lineno) ->
+-                Printf.eprintf 
+-                  "%s:%d String %S not translated\n%!"
+-                  fn lineno str)
+-             locs)
+-        t.untranslated;
+       Marshal.to_channel fd t.po_content []
+ 
+   (* Check if the given node belong to the given functions *)
+_at_@ -197,7 +158,6 @@ struct
+     val t = 
+       {
+         po_content   = empty_po;
+-        untranslated = MapString.empty;
+         translated   = SetString.empty;
+       }
+ 
+_at_@ -234,10 +194,6 @@ struct
+       (* Add a plural / defined domain string *)
+       {< t = add_translation t loc singular (Some plural) (Some domain) >}
+ 
+-    | <:expr_at_loc<$str:str$>> when
+-        string_not_translated t str ->
+-      {< t = add_untranslated t loc str >}
+-
+     | e -> super#expr e
+ 
+   end
+-- 
+2.13.2
+
diff --git a/testing/ocaml-gettext/0002-pr_gettext-stop-printing-extracted-strings.patch b/testing/ocaml-gettext/0002-pr_gettext-stop-printing-extracted-strings.patch
new file mode 100644
index 0000000000..6d656d9bc6
--- /dev/null
+++ b/testing/ocaml-gettext/0002-pr_gettext-stop-printing-extracted-strings.patch
_at_@ -0,0 +1,26 @@
+From 3f4fc73c2a0315c2da16dee7db0fcb2766f55d3c Mon Sep 17 00:00:00 2001
+From: Pino Toscano <ptoscano_at_redhat.com>
+Date: Tue, 29 Aug 2017 18:36:10 +0200
+Subject: [PATCH 2/3] pr_gettext: stop printing extracted strings
+
+They are written in the pot file already, no need to print them to
+stderr (even though they are not errors).
+---
+ libgettext-ocaml/pr_gettext.ml | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/libgettext-ocaml/pr_gettext.ml b/libgettext-ocaml/pr_gettext.ml
+index d78cf21..47d93e5 100644
+--- a/libgettext-ocaml/pr_gettext.ml
++++ b/libgettext-ocaml/pr_gettext.ml
+_at_@ -78,7 +78,6 @@ struct
+       }
+ 
+   let string_of_ocaml_string str =
+-    prerr_endline str;
+     Scanf.sscanf 
+       (Printf.sprintf "\"%s\"" str)
+       "%S"
+-- 
+2.13.2
+
diff --git a/testing/ocaml-gettext/0003-add-more-generated-files-to-.gitignore.patch b/testing/ocaml-gettext/0003-add-more-generated-files-to-.gitignore.patch
new file mode 100644
index 0000000000..00b410c5f2
--- /dev/null
+++ b/testing/ocaml-gettext/0003-add-more-generated-files-to-.gitignore.patch
_at_@ -0,0 +1,44 @@
+From 202bf1e00eaa533e133c29b509d77cdfb7c13f5e Mon Sep 17 00:00:00 2001
+From: Pino Toscano <ptoscano_at_redhat.com>
+Date: Tue, 29 Aug 2017 18:55:37 +0200
+Subject: [PATCH 3/3] add more generated files to .gitignore
+
+Make sure all the files generated during a build are properly ignored
+from the git status.
+---
+ .gitignore | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/.gitignore b/.gitignore
+index d853d40..87821c3 100644
+--- a/.gitignore
++++ b/.gitignore
+_at_@ -1,3 +1,12 @@
++*.a
++*.cma
++*.cmi
++*.cmo
++*.cmx
++*.cmxa
++*.o
++*.so
++*_parser.output
+ /_build/
+ /setup.data
+ /setup.log
+_at_@ -7,6 +16,12 @@
+ /configure
+ /libgettext-ocaml/META
+ /libgettext-ocaml/gettextConfig.ml
++/libgettext-ocaml/gettextPo_parser.mli
+ /config.log
+ /config.status
++/po/*.mo
+ /po/fr.po.bak
++/doc/*.1
++/doc/*.5
++/ocaml-gettext/ocaml-gettext
++/ocaml-gettext/ocaml-xgettext
+-- 
+2.13.2
+
diff --git a/testing/ocaml-gettext/APKBUILD b/testing/ocaml-gettext/APKBUILD
new file mode 100644
index 0000000000..f64d3816ca
--- /dev/null
+++ b/testing/ocaml-gettext/APKBUILD
_at_@ -0,0 +1,52 @@
+# Contributor: Fernando Casas Schossow <casasfernando_at_outlook.com>
+# Maintainer: Fernando Casas Schossow <casasfernando_at_outlook.com>
+pkgname=ocaml-gettext
+pkgver=0.3.7
+pkgrel=0
+pkgdesc="OCaml library for i18n"
+url="https://github.com/gildor478/ocaml-gettext"
+arch="all"
+license="LGPL-2.1-or-later-WITH-linking-exception"
+makedepends="ocaml ocaml-ocamldoc ocaml-camlp4-dev ocaml-fileutils ocaml-fileutils-dev ocaml-findlib-dev chrpath autoconf automake libxml2 libxslt docbook-xsl gettext-dev"
+subpackages="$pkgname-dev $pkgname-doc"
+source="${pkgname}-${pkgver}.tar.gz::https://github.com/gildor478/$pkgname/archive/$pkgver.tar.gz
+	0001-pr_gettext-stop-tracking-and-printing-untranslated-s.patch
+	0002-pr_gettext-stop-printing-extracted-strings.patch
+	0003-add-more-generated-files-to-.gitignore.patch
+	ocaml-gettext-0.3.4-use-ocamlopt-g.patch"
+builddir="$srcdir/$pkgname-$pkgver"
+options="!check" # there is no test suite/unit tests since tests requires camomile
+
+build() {
+	cd "$builddir"
+	autoreconf -i
+	unset MAKEFLAGS
+	export OCAMLPARAM="safe-string=0,_"
+	sed -i 's/_at_OCAMLDOC@/_at_OCAMLDOC@ -unsafe-string/g' ConfMakefile.in
+	./configure --prefix=/usr --disable-camomile --with-docbook-stylesheet=/usr/share/xml/docbook/xsl-stylesheets-1.79.1 --with-stub-ldflags=-lintl
+	make all
+}
+
+check() {
+	cd "$builddir"
+}
+
+package() {
+	cd "$builddir"
+	export DESTDIR="$pkgdir"
+	export OCAMLFIND_DESTDIR="$DESTDIR/usr/lib/ocaml"
+	mkdir -p "$OCAMLFIND_DESTDIR" "$OCAMLFIND_DESTDIR/stublibs"
+	find _build -name '*.o' -exec rm {} \;
+	ocamlfind install gettext _build/lib/gettext/*
+	ocamlfind install gettext-stub _build/lib/gettext-stub/*
+	install -D -m644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
+	install -D -m 0755 _build/bin/ocaml-gettext "$pkgdir/usr/bin/ocaml-gettext"
+	install -D -m 0755 _build/bin/ocaml-xgettext "$pkgdir/usr/bin/ocaml-xgettext"
+	chrpath --delete $OCAMLFIND_DESTDIR/stublibs/dll*.so
+}
+
+sha512sums="1358320359b9d2f3fd97a47d69b2a619942a65605c1e5cbf25e33ef42a10273167b526bca15e6c9523b87d8ea9dfd3215334050ad8eb84a8c41d4feef880a27a  ocaml-gettext-0.3.7.tar.gz
+430e67b9e228d36eae6d1a1378c40d3203799d04c05962d25be4703483418400d71c392c2d84baa434f5e7aab19e7925e08971392b969ff472e3baf81546ca6d  0001-pr_gettext-stop-tracking-and-printing-untranslated-s.patch
+69f9e5a000cd29b5f6e7ee1b3ce0691ba4a7fdff456c76ce271daa76a74cf422aa8769f94cac46dbceb92dcdcdaecfbc65e255f61748bd52e7ccf7e88cc04bac  0002-pr_gettext-stop-printing-extracted-strings.patch
+6cab63660875ec9f6314631ae0730870b714b5a1bc456d97a04c928f287feb82aae623b8361b6b56075901f2d9cd5716e27305cda4334ac0e61a40ce02bab599  0003-add-more-generated-files-to-.gitignore.patch
+b169f864194459db388ee8aa9db4cf97441419cb6b93c1b72854cca3fbbdcab8745a802326f967b8786853ec136aca41847799100216d6f9272e6a56dc80d169  ocaml-gettext-0.3.4-use-ocamlopt-g.patch"
diff --git a/testing/ocaml-gettext/ocaml-gettext-0.3.4-use-ocamlopt-g.patch b/testing/ocaml-gettext/ocaml-gettext-0.3.4-use-ocamlopt-g.patch
new file mode 100644
index 0000000000..f8f05b5c0c
--- /dev/null
+++ b/testing/ocaml-gettext/ocaml-gettext-0.3.4-use-ocamlopt-g.patch
_at_@ -0,0 +1,33 @@
+--- ocaml-gettext-0.3.4/TopMakefile.old	2013-09-14 08:54:04.713986462 +0100
++++ ocaml-gettext-0.3.4/TopMakefile	2013-09-14 08:54:18.319006115 +0100
+_at_@ -102,7 +102,7 @@
+ %.cmxa %.a %.so:
+ 	$(if $(STUBSOBJS),                            \
+ 	 $(OCAMLMKLIB)  -o $* $^ $(OCAMLMKLIB_FLAGS), \
+-	 $(OCAMLOPT) -a -o $*.cmxa $^                 \
++	 $(OCAMLOPT) -g -a -o $*.cmxa $^                 \
+ 	)
+ 
+ %.cma %.a %.so:
+_at_@ -161,7 +161,7 @@
+ OLIBS = $(addsuffix .cmxa,$(LIBS))
+ 
+ install-buildprog-opt: $(CMX)
+-	$(OCAMLOPT) -o $(NAME) $(INCLUDES) -package "$(REQUIRES)" -linkpkg \
++	$(OCAMLOPT) -g -o $(NAME) $(INCLUDES) -package "$(REQUIRES)" -linkpkg \
+ 	-predicates "$(PREDICATES)" $(OLIBS) $(CMX)
+ 	$(INSTALL) -d $(BUILDBIN) 
+ 	$(INSTALL_SCRIPT) -t $(BUILDBIN) $(NAME) 
+_at_@ -300,10 +300,10 @@
+ 	$(OCAMLC) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
+ 
+ .ml.o:
+-	$(OCAMLOPT) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
++	$(OCAMLOPT) -g $(INCLUDES) $(CLI_OCAMLFIND) -c $<
+ 	
+ .ml.cmx:
+-	$(OCAMLOPT) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
++	$(OCAMLOPT) -g $(INCLUDES) $(CLI_OCAMLFIND) -c $<
+ 	
+ .mll.ml:
+ 	$(OCAMLLEX) $<
-- 
2.20.1
---
Unsubscribe:  alpine-aports+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-aports+help_at_lists.alpinelinux.org
---
Received on Thu Feb 07 2019 - 22:52:44 UTC