forked from ungleich-public/cdist
		
	Deprecate __locale and replace with __localedef
This commit is contained in:
		
					parent
					
						
							
								fded60bd0f
							
						
					
				
			
			
				commit
				
					
						f75d477209
					
				
			
		
					 6 changed files with 159 additions and 0 deletions
				
			
		
							
								
								
									
										1
									
								
								cdist/conf/type/__locale/deprecated
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__locale/deprecated
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
This type is deprecated. Please use __localedef instead.
 | 
			
		||||
							
								
								
									
										60
									
								
								cdist/conf/type/__localedef/gencode-remote
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										60
									
								
								cdist/conf/type/__localedef/gencode-remote
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,60 @@
 | 
			
		|||
#!/bin/sh -e
 | 
			
		||||
#
 | 
			
		||||
# 2013-2019 Nico Schottelius (nico-cdist at schottelius.org)
 | 
			
		||||
#
 | 
			
		||||
# This file is part of cdist.
 | 
			
		||||
#
 | 
			
		||||
# cdist is free software: you can redistribute it and/or modify
 | 
			
		||||
# it under the terms of the GNU General Public License as published by
 | 
			
		||||
# the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
# (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
# cdist is distributed in the hope that it will be useful,
 | 
			
		||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
# GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
# You should have received a copy of the GNU General Public License
 | 
			
		||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# Let localedef do the magic
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
locale="$__object_id"
 | 
			
		||||
 | 
			
		||||
# Hardcoded, create a pull request with
 | 
			
		||||
# branching on $os in case it is at another location
 | 
			
		||||
alias=/usr/share/locale/locale.alias
 | 
			
		||||
 | 
			
		||||
input=$(echo "$locale" | cut -d . -f 1)
 | 
			
		||||
charmap=$(echo "$locale" | cut -d . -f 2)
 | 
			
		||||
 | 
			
		||||
# Adding locale? The name is de_CH.UTF-8
 | 
			
		||||
# Removing locale? The name is de_CH.utf8.
 | 
			
		||||
# W-T-F!
 | 
			
		||||
locale_remove=$(echo "$locale" | sed 's/UTF-8/utf8/')
 | 
			
		||||
 | 
			
		||||
state=$(cat "$__object/parameter/state")
 | 
			
		||||
 | 
			
		||||
os=$(cat "$__global/explorer/os")
 | 
			
		||||
 | 
			
		||||
# Nothing to be done on alpine
 | 
			
		||||
case "$os" in
 | 
			
		||||
    alpine)
 | 
			
		||||
        exit 0
 | 
			
		||||
        ;;
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
case "$state" in
 | 
			
		||||
    present)
 | 
			
		||||
        echo localedef -A "$alias" -f "$charmap" -i "$input" "$locale"
 | 
			
		||||
    ;;
 | 
			
		||||
    absent)
 | 
			
		||||
        echo localedef --delete-from-archive "$locale_remove"
 | 
			
		||||
    ;;
 | 
			
		||||
    *)
 | 
			
		||||
        echo "Unsupported state: $state" >&2
 | 
			
		||||
        exit 1
 | 
			
		||||
    ;;
 | 
			
		||||
esac
 | 
			
		||||
							
								
								
									
										55
									
								
								cdist/conf/type/__localedef/man.rst
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								cdist/conf/type/__localedef/man.rst
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,55 @@
 | 
			
		|||
cdist-type__localedef(7)
 | 
			
		||||
========================
 | 
			
		||||
 | 
			
		||||
NAME
 | 
			
		||||
----
 | 
			
		||||
cdist-type__localedef - Define and remove system locales
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
DESCRIPTION
 | 
			
		||||
-----------
 | 
			
		||||
This cdist type allows you to define locales on the system using
 | 
			
		||||
:strong:`localedef`\ (1) or remove them.
 | 
			
		||||
On systems that don't support definition of new locales, the type will raise an
 | 
			
		||||
error.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
OPTIONAL PARAMETERS
 | 
			
		||||
-------------------
 | 
			
		||||
state
 | 
			
		||||
   ``present`` or ``absent``. Defaults to ``present``.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
EXAMPLES
 | 
			
		||||
--------
 | 
			
		||||
 | 
			
		||||
.. code-block:: sh
 | 
			
		||||
 | 
			
		||||
    # Add locale de_CH.UTF-8
 | 
			
		||||
    __localedef de_CH.UTF-8
 | 
			
		||||
 | 
			
		||||
    # Same as above, but more explicit
 | 
			
		||||
    __localedef de_CH.UTF-8 --state present
 | 
			
		||||
 | 
			
		||||
    # Remove colourful British English
 | 
			
		||||
    __localedef en_GB.UTF-8 --state absent
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
SEE ALSO
 | 
			
		||||
--------
 | 
			
		||||
:strong:`locale`\ (1),
 | 
			
		||||
:strong:`localedef`\ (1),
 | 
			
		||||
:strong:`cdist-type__locale_system`\ (7)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
AUTHORS
 | 
			
		||||
-------
 | 
			
		||||
| Dennis Camera <dennis.camera--@--ssrq-sds-fds.ch>
 | 
			
		||||
| Nico Schottelius <nico-cdist--@--schottelius.org>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
COPYING
 | 
			
		||||
-------
 | 
			
		||||
Copyright \(C) 2013-2019 Nico Schottelius, 2020 Dennis Camera. Free use of this
 | 
			
		||||
software is granted under the terms of the GNU General Public License version 3
 | 
			
		||||
or later (GPLv3+).
 | 
			
		||||
							
								
								
									
										41
									
								
								cdist/conf/type/__localedef/manifest
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										41
									
								
								cdist/conf/type/__localedef/manifest
									
										
									
									
									
										Executable file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
#!/bin/sh -e
 | 
			
		||||
#
 | 
			
		||||
# 2013-2019 Nico Schottelius (nico-cdist at schottelius.org)
 | 
			
		||||
# 2015 David Hürlimann (david at ungleich.ch)
 | 
			
		||||
#
 | 
			
		||||
# This file is part of cdist.
 | 
			
		||||
#
 | 
			
		||||
# cdist is free software: you can redistribute it and/or modify
 | 
			
		||||
# it under the terms of the GNU General Public License as published by
 | 
			
		||||
# the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
# (at your option) any later version.
 | 
			
		||||
#
 | 
			
		||||
# cdist is distributed in the hope that it will be useful,
 | 
			
		||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
# GNU General Public License for more details.
 | 
			
		||||
#
 | 
			
		||||
# You should have received a copy of the GNU General Public License
 | 
			
		||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# Install required packages
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
os=$(cat "$__global/explorer/os")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
case "$os" in
 | 
			
		||||
    debian|devuan)
 | 
			
		||||
        # Debian needs a seperate package
 | 
			
		||||
        __package locales --state present
 | 
			
		||||
    ;;
 | 
			
		||||
    archlinux|suse|ubuntu|scientific|centos|alpine)
 | 
			
		||||
        :
 | 
			
		||||
    ;;
 | 
			
		||||
    *)
 | 
			
		||||
        echo "Sorry, do not know how to handle os: $os" >&2
 | 
			
		||||
        echo "Please edit the type ${__type##*/} to fix this." >&2
 | 
			
		||||
        exit 1
 | 
			
		||||
    ;;
 | 
			
		||||
esac
 | 
			
		||||
							
								
								
									
										1
									
								
								cdist/conf/type/__localedef/parameter/default/state
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__localedef/parameter/default/state
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
present
 | 
			
		||||
							
								
								
									
										1
									
								
								cdist/conf/type/__localedef/parameter/optional
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cdist/conf/type/__localedef/parameter/optional
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
state
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue