From 465749f377ff9d9e950f6ffdda8d159a976f1fdd Mon Sep 17 00:00:00 2001
From: Nico Schottelius <nico@bento.schottelius.org>
Date: Mon, 14 Oct 2013 21:38:47 +0900
Subject: [PATCH] use localedef - locale-gen is a bad wrapper script

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
---
 cdist/conf/type/__locale/gencode-remote       | 40 +++----------------
 .../type/__locale/parameter/default/state     |  1 -
 cdist/conf/type/__locale/parameter/optional   |  1 -
 .../type/__locale/parameter/required_multiple |  1 -
 cdist/conf/type/__locale/singleton            |  0
 5 files changed, 5 insertions(+), 38 deletions(-)
 delete mode 100644 cdist/conf/type/__locale/parameter/default/state
 delete mode 100644 cdist/conf/type/__locale/parameter/optional
 delete mode 100644 cdist/conf/type/__locale/parameter/required_multiple
 delete mode 100644 cdist/conf/type/__locale/singleton

diff --git a/cdist/conf/type/__locale/gencode-remote b/cdist/conf/type/__locale/gencode-remote
index aa03b46c..ed8052a8 100644
--- a/cdist/conf/type/__locale/gencode-remote
+++ b/cdist/conf/type/__locale/gencode-remote
@@ -1,37 +1,7 @@
-cat << eof
 
-archive="/usr/lib/locale/locale-archive"
+locale=$__object_id
+input=$(echo $locale | cut -d . -f 1)
+charmap=$(echo $locale | cut -d . -f 2)
+alias=/usr/share/locale/locale.alias
 
-regen=no
-
-if [ -f "$archive" ]; then
-    config_time=\$(stat --format "%Z" /etc/locale.gen)
-    archive_time=\$(stat --format "%Z" \"\$archive\")
-
-    if [ "$config_time" -gt "$archive_time" ]; then
-        regen=yes
-    fi
-else
-    regen=yes
-fi
-    
-if [ "\$regen" = yes ]; then
-    locale-gen
-fi
-
-eof
-
-
-## probably not needed, it seems to be /usr/lib/locale/locale-archive
-## everwhere!
-
-# tmp=\$(mktemp /tmp/cdist.XXXXXXXX)
-# find /usr/lib/locale -mindepth 1 > \$tmp
-# while read archive; do
-#     archive_time=\$(stat --format "%Z" "\$archive\")
-# 
-#     if [ "\$config_time" -gt "\$archive_time" ]; then
-#         regen=yes
-#         break
-#     fi
-# done < "$\tmp"
+echo localedef -A "$alias" -f "$charmap" -i "$input"
diff --git a/cdist/conf/type/__locale/parameter/default/state b/cdist/conf/type/__locale/parameter/default/state
deleted file mode 100644
index e7f6134f..00000000
--- a/cdist/conf/type/__locale/parameter/default/state
+++ /dev/null
@@ -1 +0,0 @@
-present
diff --git a/cdist/conf/type/__locale/parameter/optional b/cdist/conf/type/__locale/parameter/optional
deleted file mode 100644
index ff72b5c7..00000000
--- a/cdist/conf/type/__locale/parameter/optional
+++ /dev/null
@@ -1 +0,0 @@
-state
diff --git a/cdist/conf/type/__locale/parameter/required_multiple b/cdist/conf/type/__locale/parameter/required_multiple
deleted file mode 100644
index f121bdbf..00000000
--- a/cdist/conf/type/__locale/parameter/required_multiple
+++ /dev/null
@@ -1 +0,0 @@
-name
diff --git a/cdist/conf/type/__locale/singleton b/cdist/conf/type/__locale/singleton
deleted file mode 100644
index e69de29b..00000000