How to Create a new Locale in OpenSolaris
By Jan Lana on Sep 30, 2009
In the last blog I shortly described the history of locales and the reason why a a new workspace for locales has been created. Now I am going to show you how to work with the locale workspace and how to create a new UTF-8 locale.
The following instructions are for OpenSolaris 2009.06 (and later). Building in older versions of Solaris/OpenSolaris is possible, but there would be differences in installation of the build tools.
To be able to build the workspace we need build tools. All necessary build tools are part of OpenSolaris, but not installed by default. So, we need to install them:
$ pfexec pkg install SUNWmercurial SUNWgmake SUNWant sunstudio $ export CC=/opt/sunstudio12.1/bin/cc
We need to clone the workspace to our machine:
$ hg clone ssh://firstname.lastname@example.org//hg/nv-g11n/locale
OpenSolaris is installed from IPS packages. IPS packages do not have a disk file representation, the packages exist only in IPS server. To be able to test the new locales you need an IPS server. A local IPS server is a part of each OpenSolaris installation, but it is disabled by default. First you need to enable the service
$ pfexec svcadm restart pkg/serverand setup the server as a primary authority
$ pfexec pkg set-publisher -P -O http://localhost local
Now everything is ready for compilation
$ make or $ make all
To install the new packages you first need to send them to the IPS server
$ make PKG_REPO=http://localhost:80 ipsThe compilation of all locales takes ~4.5 hours (Intel Core 2 3GHz, 'make -j2 ...'). Or you can compile just one package
$ make PKG_REPO=http://localhost:80 PKGS=SUNWlang-xx ips
Now you can install the new package:
$ pfexec pkg install SUNWlang-xx@1-1
Each package in IPS server has an unique FMRI identifier. The FMRI includes the name, version and a timestamp for the package. The builded packages have version @1-1. For existing packages it is usually in collision with package entire, which is installed by default. The package depends on specific version of the SUNWlang-\* packages (entire is metapackage and is used for upgrade purposes). Because version required by the entire package is changing with each build, there is not simple solution of the this conflict.
One way is to modify the locale/mk/pkgs.mk:cmd_pkgsend command and change '@1-1' to the same version like your 'entire' has:
$ pkg info entire|grep FMRI FMRI: pkg://email@example.com,5.11-0.111:20090518T052643Z $ sed -ie 's/@firstname.lastname@example.org/' misc/mk/pkgs.mk
Another solution is to uninstall 'entire' package:
$ pfexec pkg uninstall entire
First way needs to modify the build scripts after solaris upgrade, the second could make upgrade problems.
It could happen that the
@1-1 version of your package is in confilict with package
entire. You can modify
locale/mk/pkgs.mk: cmd_pkgsend to build the same version like
entire needs or uninstall the
We are able to compile existing locales. Now it is time to create a new one. The simpliest situation is when you need to to add a new UTF-8 locale and at the same time you are satisfied with the CLDR data. Each locale has its own specification file locale/locale/<locale>.spec
The file contains definitions, or otherwise say attributes, of the locale. List of all possible attributes and default values is in the file locale/README. If an attribute is missing in the file, there will be used a default value.
For our new locale we will use only default values of all attributes, so it is enough to create an empty file
$ touch locale/locale/xx_YY.UTF-8.spec
Now you can install the new locale
$ make PKG_REPO=http://localhost:80 PKGS=SUNWlang-xx ips $ pfexec pkg install SUNWlang-xx@1-1
and the game is over - enjoy your new locale :)
Next week I am going to write about how to modify the locale.