From cc46daa1acc384f282bd53b3188ee6ebe6c3edee Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Thu, 8 Nov 2012 06:16:04 -0800 Subject: [PATCH] Rebase history add packaging no examples add packaging gz -> bz2 resetting manifest requested domain to floor Update changelog Fix RPMLINT Add BuildRequire to enable iconv support Update changelog Upgrade to 0.18.3.2 Change-Id: I8108fbce3ea8a238a33252af92c74e9845c05fd5 Signed-off-by: DongHun Kwak --- gettext-tools/Makefile.am | 2 +- packaging/gettext.changes | 17 ++ packaging/gettext.manifest | 5 + packaging/gettext.spec | 202 +++++++++++++++++++++++ packaging/msghack.py | 399 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 624 insertions(+), 1 deletion(-) create mode 100644 packaging/gettext.changes create mode 100644 packaging/gettext.manifest create mode 100644 packaging/gettext.spec create mode 100644 packaging/msghack.py diff --git a/gettext-tools/Makefile.am b/gettext-tools/Makefile.am index 567b7ca..0d78d18 100644 --- a/gettext-tools/Makefile.am +++ b/gettext-tools/Makefile.am @@ -19,7 +19,7 @@ AUTOMAKE_OPTIONS = 1.5 gnu no-dependencies ACLOCAL_AMFLAGS = -I m4 -I ../gettext-runtime/m4 -I ../m4 -I gnulib-m4 -I libgrep/gnulib-m4 -I libgettextpo/gnulib-m4 -SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4 tests gnulib-tests examples its +SUBDIRS = doc intl gnulib-lib libgrep src libgettextpo po projects styles misc man m4 tests gnulib-tests EXTRA_DIST = misc/DISCLAIM MOSTLYCLEANFILES = core *.stackdump diff --git a/packaging/gettext.changes b/packaging/gettext.changes new file mode 100644 index 0000000..2724c91 --- /dev/null +++ b/packaging/gettext.changes @@ -0,0 +1,17 @@ +* Mon Feb 10 2014 Maciej Wereski upstream/0.18.3.2 +- Upgrade to 0.18.3.2 + +* Mon Feb 10 2014 Karol Lewandowski +- Add BuildRequire to enable iconv support +- Fix RPMLINT + +* Tue Nov 19 2013 Ronan Le Martret fe945ec +- packaging: create a directory to fix %reconfigure (DEVT-123) + +* Fri Jun 28 2013 Alexandru Cornea 85c26f5 +- resetting manifest requested domain to floor + +* Thu Nov 8 2012 Anas Nashif 3351151 +- add packaging +- Imported Upstream version 0.18.1.1 + diff --git a/packaging/gettext.manifest b/packaging/gettext.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/packaging/gettext.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/gettext.spec b/packaging/gettext.spec new file mode 100644 index 0000000..c10ad89 --- /dev/null +++ b/packaging/gettext.spec @@ -0,0 +1,202 @@ +# The split of gettext into two packages is suggested by upstream (see +# the PACKAGING file). Here we name gettext-runtime as +# gettext-lib. Please be noted that gettext-runtime is LGPL while the +# others parts are of GPL. You should be careful of the license when +# adding files into these sub-packages. + + +%define enable_testing 0 + +Name: gettext +Version: 0.18.3.2 +Release: 1 +License: GPL-3.0+ and LGPL-2.0+ +Summary: GNU libraries and utilities for producing multi-lingual messages +Url: http://www.gnu.org/software/gettext/ +Group: Development/Tools +Source: ftp://ftp.gnu.org/gnu/gettext/%{name}-%{version}.tar.gz +Source2: msghack.py +Source1001: gettext.manifest + +BuildRequires: autoconf >= 2.5 +BuildRequires: bison +# need expat for xgettext on glade +BuildRequires: expat-devel +BuildRequires: gcc-c++ +BuildRequires: libtool +#needed for ANSI to UTF8 conversion using msgconn +BuildRequires: libunistring +BuildRequires: glibc-locale + +%description +The GNU gettext package provides a set of tools and documentation for +producing multi-lingual messages in programs. Tools include a set of +conventions about how programs should be written to support message +catalogs, a directory and file naming organization for the message +catalogs, a runtime library which supports the retrieval of translated +messages, and stand-alone programs for handling the translatable and +the already translated strings. Gettext provides an easy to use +library and tools for creating, using, and modifying natural language +catalogs and is a powerful and simple method for internationalizing +programs. + +MeeGo's gettext is split into two packages: gettext-libs and +gettext-devel. gettext-libs is an LGPLv2+ package that contains +libraries and runtime needed by i18n programs; gettext-devel is used +only for development and building -- and shouldn't be needed by end +users. This gettext package is a meta-package that depends on +gettext-devel for transition. + +%package tools +License: GPL-3.0+ +Summary: Development files for %{name} +Group: Development/Tools +Requires: %{name}-runtime = %{version} +Obsoletes: gettext-devel <= 0.18.1.1-1.15 +Provides: gettext-devel + +%description tools +This package contains all development related files necessary for +developing or compiling applications/libraries that needs +internationalization capability. You also need this package if you +want to add gettext support for your project. + +%package runtime +License: LGPL-2.0+ +Summary: Libraries for %{name} +Group: System/Libraries +Obsoletes: gettext-libs <= 0.18.1.1-1.15 +Provides: gettext-libs + +%description runtime +This package contains libraries used internationalization support. + +%prep +%setup -q + + +%build +cp %{SOURCE1001} . +[ -f %{_datadir}/automake/depcomp ] && cp -f %{_datadir}/automake/{depcomp,ylwrap} . + +%ifarch %arm +# We add a compile flag for ARM to deal with a bug in qemu (msgmerge using pthread/gomp) +# msgmerge will lockup during execution. +%define addconfflag --without-libpth-prefix --disable-openmp +%else +%endif + +mkdir -p gettext-tools/intl + +%reconfigure --without-included-gettext --enable-nls --disable-static \ + --enable-shared --with-pic-=yes --disable-csharp --without-libpth-prefix --disable-openmp +make %{?_smp_mflags} GCJFLAGS="-findirect-dispatch" + +%check +make check + +%install +make install DESTDIR=%{buildroot} INSTALL="install -p" \ + lispdir=%{_datadir}/emacs/site-lisp \ + aclocaldir=%{_datadir}/aclocal EXAMPLESFILES="" + +install -pm 755 %{SOURCE2} %{buildroot}%{_bindir}/msghack + +# make preloadable_libintl.so executable +chmod 755 %{buildroot}%{_libdir}/preloadable_libintl.so + +rm -f %{buildroot}%{_infodir}/dir + +# doc relocations +for i in gettext-runtime/man/*.html; do + rm %{buildroot}%{_datadir}/doc/gettext/`basename $i` +done +rm -r %{buildroot}%{_datadir}/doc/gettext/javadoc* + +rm -rf %{buildroot}%{_datadir}/doc/gettext/examples + +rm -rf htmldoc +mkdir htmldoc +mv %{buildroot}%{_datadir}/doc/gettext/* %{buildroot}%{_datadir}/doc/libasprintf/* htmldoc +rm -r %{buildroot}%{_datadir}/doc/libasprintf +rm -r %{buildroot}%{_datadir}/doc/gettext + +# remove unpackaged files from the buildroot +rm -rf %{buildroot}%{_datadir}/emacs +rm %{buildroot}%{_libdir}/lib*.la + + +%find_lang %{name}-runtime +%find_lang %{name}-tools +cat %{name}-*.lang > %{name}.lang + +%docs_package + +%post runtime -p /sbin/ldconfig + +%postun runtime -p /sbin/ldconfig + +%post tools -p /sbin/ldconfig + +%postun tools -p /sbin/ldconfig + +%files tools -f %{name}.lang +%manifest %{name}.manifest +%defattr(-,root,root,-) +%license COPYING +%{_datadir}/%{name}/projects/* +%{_datadir}/%{name}/config.rpath +%{_datadir}/%{name}/*.h +%{_datadir}/%{name}/intl +%{_datadir}/%{name}/po +%{_datadir}/%{name}/msgunfmt.tcl +%{_datadir}/aclocal/* +%{_includedir}/* +%{_libdir}/libasprintf.so +%{_libdir}/libgettextpo.so +%{_libdir}/libgettextlib*.so +%{_libdir}/libgettextsrc*.so +%{_libdir}/preloadable_libintl.so +%{_libdir}/gettext/hostname +%{_libdir}/gettext/project-id +%{_libdir}/gettext/urlget +%{_libdir}/gettext/user-email +%{_libdir}/libgettextpo.so.* +%{_datadir}/%{name}/javaversion.class +%{_datadir}/%{name}/archive*.tar.xz +%{_datadir}/%{name}/styles +%{_bindir}/autopoint +%{_bindir}/gettextize +%{_bindir}/msgattrib +%{_bindir}/msgcat +%{_bindir}/msgcmp +%{_bindir}/msgcomm +%{_bindir}/msgconv +%{_bindir}/msgen +%{_bindir}/msgexec +%{_bindir}/msgfilter +%{_bindir}/msgfmt +%{_bindir}/msggrep +%{_bindir}/msghack +%{_bindir}/msginit +%{_bindir}/msgmerge +%{_bindir}/msgunfmt +%{_bindir}/msguniq +%{_bindir}/recode-sr-latin +%{_bindir}/xgettext + +# Don't include language files here since that may inadvertently +# involve unneeded files. If you need to include a file in -libs, list +# it here explicitly +%files runtime +%manifest %{name}.manifest +%defattr(-,root,root,-) +# Files listed here should be of LGPL license only, refer to upstream +# statement in PACKAGING file +%license gettext-runtime/intl/COPYING* +%doc %{_datadir}/gettext/ABOUT-NLS +%{_bindir}/gettext +%{_bindir}/ngettext +%{_bindir}/envsubst +%{_bindir}/gettext.sh +%{_libdir}/libasprintf.so.* diff --git a/packaging/msghack.py b/packaging/msghack.py new file mode 100644 index 0000000..64cd6f8 --- /dev/null +++ b/packaging/msghack.py @@ -0,0 +1,399 @@ +#!/usr/bin/python +## -*- coding: utf-8 -*- +## Copyright (C) 2001 Red Hat, Inc. +## Copyright (C) 2001 Trond Eivind Glomsrød + +## v0.2 - 2001-08-21 + +## This program 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 2 of the License, or +## (at your option) any later version. + +## This program 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 this program; if not, write to the Free Software +## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +""" +A msghack replacement +""" + +import string +import sys + +class GTMessage: + """ + A class containing a message, its msgid and various references pointing at it + """ + + def __init__(self,id=None,message=None,refs=[]): + """ + The constructor for the GTMessage class + @self The object instance + @message The message + @id The messageid associated with the object + """ + self._message=string.strip(message) + self._id=string.strip(id) + self._refs=[] + for ref in refs: + self._refs.append(ref) + + def __str__(self): + """ + Return a string representation of the object + @self The object instance + """ + res="" + for ref in self._refs: + res=res+ref+"\n" + res=res+"msgid %s\nmsgstr %s\n" % (self._id,self._message) + return res + + def invertedStrings(self): + """ + Returns a string representation, but with msgid and msgstr inverted. + Note: Don't invert the "" string + @self The object instance + """ + res="" + for ref in self._refs: + res=res+ref+"\n" + if not self._id=="\"\"": + res=res+"msgid %s\nmsgstr %s\n" % (self._message,self._id) + else: + res=res+"msgid %s\nmsgstr %s\n" % (self._id,self._message) + return res + + def emptyMsgStrings(self): + """ + Return a string representation of the object, but leave the msgstr + empty - create a pot file from a po file + Note: Won't remove the "" string + @self The object instance + """ + res="" + for ref in self._refs: + res=res+ref+"\n" + if not self._id=="\"\"": + res=res+"msgid %s\nmsgstr \"\"\n" % (self._id) + else: + res=res+"msgid %s\nmsgstr %s\n" % (self._id,self._message) + return res + + def compareMessage(self,msg): + """ + Return if the messages have identical msgids, 0 otherwise + @self The object instance + @msg The message to compare to + """ + + if self._id == msg._id: + return 1 + return 0 + + +class GTMasterMessage: + """ + A class containing a message, its msgid and various references pointing at it + The difference between GTMessage and GTMasterMessage is that this class + can do less operations, but is able to store multiple msgstrs with identifiers + (usually language, like 'msgst(no)' + """ + + def __init__(self,id=None,refs=[]): + """ + The constructor for the GTMessage class + @self The object instance + @id The messageid associated with the object + """ + self._id=id + self._refs=[] + self._messages=[] + for ref in refs: + self._refs.append(ref) + + def addMessage(self,message,identifier): + """ + Add a new message and identifier to the GTMasterMessage object + @self The object instance + @message The message to append + @identifier The identifier of the message + """ + self._messages.append((identifier,message)) + + def __str__(self): + """ + Return a string representation of the object + @self The object instance + """ + res="" + for ref in self._refs: + res=res+ref+"\n" + res=res+"msgid %s\n" % self._id + for message in self._messages: + res=res+"msgstr(%s) %s\n" %(message[0],message[1]) + res=res+"\n" + return res + +class GTFile: + """ + A class containing the GTMessages contained in a file + """ + + def __init__(self,filename): + """ + The constructor of the GTMFile class + @self The object instance + @filename The file to initialize from + """ + self._filename=filename + self._messages=[] + self.readFile(filename) + + def __str__(self): + """ + Return a string representation of the object + @self The object instance + """ + res="" + for message in self._messages: + res=res+str(message)+"\n" + return res + + def invertedStrings(self): + """ + Return a string representation of the object, with msgid and msgstr + swapped. Will remove duplicates... + @self The object instance + """ + + msght={} + msgar=[] + + for message in self._messages: + if message._id=='""' and len(msgar)==0: + msgar.append(GTMessage(message._id,message._message,message._refs)) + continue + msg=GTMessage(message._message,message._id,message._refs) + if not msght.has_key(msg._id): + msght[msg._id]=msg + msgar.append(msg) + else: + msg2=msght[msg._id] + for ref in msg._refs: + msg2._refs.append(ref) + res="" + for message in msgar: + res=res+str(message)+"\n" + return res + + def msgidDupes(self): + """ + Search for duplicates in the msgids. + @self The object instance + """ + msgids={} + res="" + for message in self._messages: + msgid=message._id + if msgids.has_key(msgid): + res=res+"Duplicate: %s\n" % (msgid) + else: + msgids[msgid]=1 + return res + + def getMsgstr(self,msgid): + """ + Return the msgstr matching the given id. 'None' if missing + @self The object instance + @msgid The msgid key + """ + + for message in self._messages: + if msgid == message._id: + return message._message + return None + + def emptyMsgStrings(self): + """ + Return a string representation of the object, but leave the msgstr + empty - create a pot file from a po file + @self The object instance + """ + + res="" + for message in self._messages: + res=res+message.emptyMsgStrings()+"\n" + return res + + + def append(self,B): + """ + Append entries from dictionary B which aren't + already present in this dictionary + @self The object instance + @B the dictionary to append messages from + """ + + for message in B._messages: + if not self.getMsgstr(message._id): + self._messages.append(message) + + + def readFile(self,filename): + """ + Read the contents of a file into the GTFile object + @self The object instance + @filename The name of the file to read + """ + + file=open(filename,"r") + msgid="" + msgstr="" + refs=[] + lines=[] + inmsgid=0 + inmsgstr=0 + templines=file.readlines() + for line in templines: + lines.append(string.strip(line)) + for line in lines: + pos=string.find(line,'"') + pos2=string.rfind(line,'"') + if line and line[0]=="#": + refs.append(string.strip(line)) + if inmsgstr==0 and line[:6]=="msgstr": + msgstr="" + inmsgstr=1 + inmsgid=0 + if inmsgstr==1: + if pos==-1: + inmsgstr=0 + #Handle entries with and without "" consistently + if msgid[:2]=='""' and len(msgid)>4: + msgid=msgid[2:] + if msgstr[:2]=='""' and len(msgstr)>4: + msgstr=msgstr[2:] + message=GTMessage(msgid,msgstr,refs) + self._messages.append(message) + msgstr="" + msgid="" + refs=[] + else: + msgstr=msgstr+line[pos:pos2+1]+"\n" + if inmsgid==0 and line[:5]=="msgid": + msgid="" + inmsgid=1 + if inmsgid==1: + if pos==-1: + inmsgid=0 + else: + msgid=msgid+line[pos:pos2+1]+"\n" + if msgstr and msgid: + message=GTMessage(msgid,msgstr,refs) + self._messages.append(message) + + +class GTMaster: + """ + A class containing a master catalogue of gettext dictionaries + """ + + def __init__(self,dicts): + """ + The constructor for the GTMaster class + @self The object instance + @dicts An array of dictionaries to merge + """ + self._messages=[] + self.createMaster(dicts) + + def createMaster(self,dicts): + """ + Create the master catalogue + @self The object instance + @dicts An array of dictionaries to merge + """ + + self._master=dicts[0] + self._dicts=dicts[1:] + + for message in self._master._messages: + gtm=GTMasterMessage(message._id,message._refs) + gtm.addMessage(message._message,self._master._filename[:-3]) + for dict in self._dicts: + res=dict.getMsgstr(message._id) + if(res): + gtm.addMessage(res,dict._filename[:-3]) + self._messages.append(gtm) + + def __str__(self): + """ + Return a string representation of the object + @self The object instance + """ + res="" + for message in self._messages: + res=res+str(message)+"\n" + return res + + +if __name__=="__main__": + output=None + res=None + if("-o") in sys.argv: + output=sys.argv[sys.argv.index("-o")+1] + sys.argv.remove("-o") + sys.argv.remove(output) + if("--invert") in sys.argv: + file=sys.argv[sys.argv.index("--invert")+1] + gtf=GTFile(file) + res1=gtf.msgidDupes() + if res1: + sys.stderr.write(res1) + sys.exit(1) + res=str(gtf.invertedStrings()) + elif("--empty") in sys.argv: + file=sys.argv[sys.argv.index("--empty")+1] + gtf=GTFile(file) + res=str(gtf.emptyMsgStrings()) + elif("--master") in sys.argv: + loc=sys.argv.index("--master")+1 + gtfs=[] + for file in sys.argv[loc:]: + gtfs.append(GTFile(file)) + master=GTMaster(gtfs) + res=str(master) + elif("--append") in sys.argv: + file=sys.argv[sys.argv.index("--append")+1] + file2=sys.argv[sys.argv.index("--append")+2] + gtf=GTFile(file) + gtf2=GTFile(file2) + gtf.append(gtf2) + res=str(gtf) + else: + #print "Not implemented: "+str(sys.argv) + print "\ +Usage: ", str(sys.argv[0])," [OPTION] file.po [ref.po]\n\ +This program can be used to alter .po files in ways no sane mind would think about.\n\ + -o result will be written to FILE\n\ + --invert invert a po file by switching msgid and msgstr\n\ + --master join any number of files in a master-formatted catalog\n\ + --empty empty the contents of the .po file, creating a .pot\n\ + --append append entries from ref.po that don't exist in file.po\n\ +\n\ +Note: It is just a replacement of msghack for backward support.\n\ +" + sys.exit(1) + if not output: + print res + else: + file=open(output,"w") + file.write(res) + sys.exit(0) -- 2.7.4