#!/bin/bash # # Additional functions for the OpenOffice.org build script. # # Czech Native-Lang team (http://cs.openoffice.org/) # # # (c) Pavel Janík , 2003-2004 # (c) Josef Cacek , 2003-2004 # # # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # Apply patch and exit in case of error # # Syntax: ApplyPatch ApplyPatch () { APPLYPATCHARGS=-p1 [ "x$2" != "x" ] && APPLYPATCHARGS=$2 if [ -f ${BUILD}/$1 ] then APPLYPATCH=${BUILD}/$1 else APPLYPATCH=${PATCHES}/${VERSION}/$1 fi # First test if the patch is OK ${PATCH} --dry-run ${APPLYPATCHARGS} <${APPLYPATCH} || { echo "patch $1 not applied correctly, please fix it and press Enter to continue!" read } # If it is, apply it! ${PATCH} ${APPLYPATCHARGS} <${APPLYPATCH} } # Apply patch from child workspace # # Syntax: ApplyCWSPatch module patch # ApplyCWSPatch () { cd $1 ApplyPatch $2 -p0 cd .. } # Apply child workspace changes # # Syntax: ApplyCWS cwsname # ApplyCWS () { CWS=$1 for module in `ls -1 ${PATCHES}/${VERSION}/CWS-${CWS}*|sed "s#.diff##"|sed "s#.*CWS-${CWS}-##"` do ApplyCWSPatch $module CWS-${CWS}-$module.diff done } # Unpack gpc # # Syntax: UnpackGPC # UnpackGPC () { ( cd external/gpc ${TAR} xvfz ${SOURCES}/gpc231.tar.Z mv gpc231/* . rmdir gpc231 ) } # Prepare ccache # # Syntax: PrepareCCache # PrepareCCache () { # FIXME: check for system ccache # which ccache on MacOS X returns 0 even if there is no ccache ;-) ${TAR} xfz ${SOURCES}/ccache-${CCACHEVERSION}.tar.gz ( cd ccache-${CCACHEVERSION} ./configure --prefix=${BUILD} make make install ) } # Prepare dpkg # # Syntax: PrepareDpkg # PrepareDpkg () { ${TAR} xfz ${SOURCES}/dpkg_${DPKGVERSION}.tar.gz ( cd dpkg-${DPKGVERSION} ./configure --prefix=${BUILD} --disable-nls --without-sgml-doc make make install ) } # Prepare translate tools # # Syntax: PrepareTranslate # PrepareTranslate () { ${TAR} xfz ${SOURCES}/translate-toolkit-${TRANSLATEVERSION}.tar.gz ( cd translate-toolkit-${TRANSLATEVERSION} ./setup.py install --home=${BUILD} ) } # Prepare Ant # # Syntax: PrepareAnt # PrepareAnt () { unzip -q ${SOURCES}/apache-ant-${ANTVERSION}-bin.zip chmod 755 apache-ant-${ANTVERSION}/bin/ant } # Prepare localization tools # # Syntax: PrepareLocalizeTool # PrepareLocalizeTool () { ( cd transex3 build.pl --all || { date echo "Can't prepare localize tool, fix the bug above." read } deliver.pl ) } # Prepare debug GSI file from normal GSI files # # Syntax: PrepareDebugGSI # PrepareDebugGSI () { if [ $DEVEL == "no" ] then for gsi in ${FILES}/GSI_*.txt do awk -F' ' 'BEGIN{OFS=" "; NUMBER=0} {if ($10 != "1" && $1 != "officecfg") {$11=NUMBER ":" $11; $12=NUMBER ":" $12; $13=NUMBER ":" $13; $14=NUMBER ":" $14}; print; if ($10 != "1") NUMBER++}' <$gsi >${BUILD}/debug_`basename $gsi` done else for gsi in ${FILES}/2.0/GSI_*.sdf do awk -F' ' 'BEGIN{OFS=" "; NUMBER=0} {if ($10 != "en-US") {$11=NUMBER ":" $11; $12=NUMBER ":" $12; $13=NUMBER ":" $13; $14=NUMBER ":" $14}; print; if ($10 != "en-US") NUMBER++}' <$gsi >${BUILD}/debug_`basename $gsi` done fi } # Merge GSI file to sources # # Syntax: MergeGSI 42 cs czech [debug] # MergeGSI () { LANGUAGECODE=$1 LANGUAGESHORT=$2 LANGUAGE=$3 DEBUG=$4 LOCALIZE=localize [ ${OOO_BUILD_SYSTEM} = "Windows" ] && LOCALIZE="guw.pl -env ${LOCALIZE}" if [ "x$DEBUG" = "xdebug" ] then GSI=${BUILD}/debug_GSI_${LANGUAGE}.txt else GSI=${FILES}/GSI_${LANGUAGE}.txt fi [ ! -r ${GSI} ] && { echo "GSI file ${GSI} is not readable, fix it!" exit } ${LOCALIZE} -m -i ${LANGUAGESHORT} -l ${LANGUAGECODE} -f ${GSI} } # Merge development version GSI file to sources # # Syntax: MergeDevelGSI cs [debug] # MergeDevelGSI () { ISOCODE=$1 DEBUG=$2 LOCALIZE=localize if [ "x$DEBUG" = "xdebug" ] then GSI=${BUILD}/debug_GSI_${ISOCODE}.sdf else GSI=${BUILD}/GSI_${ISOCODE}.sdf fi [ ! -r ${GSI} ] && { echo "GSI file ${GSI} is not readable, fix it!" exit } ${LOCALIZE} -m -x -l ${ISOCODE} -f ${GSI} mkdir -p ${BUILD_OUTPUT_DIRECTORY}/build [ -f ${GSI}.err ] && cp ${GSI}.err ${BUILD_OUTPUT_DIRECTORY}/build } # Unpack all helpcontent files available # # Syntax: UnpackHelpContent # UnpackHelpContent () { if [ ${OOO_BUILD_SYSTEM} != "Windows" ] then for package in ${FILES}/helpcontent_*.tgz do ${TAR} xfz ${package} -C solver/${BUILD_NUMBER}/${OOOUTPATH}.pro/pck done else for package in ${FILES}/helpcontent_*.zip do unzip -q -o ${package} -d solver/${BUILD_NUMBER}/${OOOUTPATH}.pro/pck done fi } # Create installation set # # Syntax: CreateInstallationSet 42 czech cs [debug] # CreateInstallationSet () { LANGUAGECODE=$1 LANGUAGE=$2 LOCALE=$3 DEBUG=$4 # The name of installation set (according to # http://development.openoffice.org/releases/filenames.html) INSTALLSET=OOo_${VERSION}_${OOARCHENVIRONMENT}_install [ ! -z $DEBUG ] && INSTALLSET=${INSTALLSET}_debug [ ! -z $LOCALE ] && INSTALLSET=${INSTALLSET}_${LOCALE} ( if [ $DEVEL == "no" ] then cd ${LANGUAGECODE} || return else [ -z $LOCALE ] && LOCALE=en-US cd ${LOCALE} || return fi mv normal ${INSTALLSET} # If FAQ, setup guide or flyer exist, use it for file in faq.html SETUP_GUIDE.pdf OOoFlyer.pdf do [ -f ${FILES}/${LANGUAGE}_${file} ] && cp ${FILES}/${LANGUAGE}_${file} ${INSTALLSET}/${file} done if [ ${OOO_BUILD_SYSTEM} != "Windows" ] then ${TAR} cvfz ${BUILD_OUTPUT_DIRECTORY}/${INSTALLSET}.tar.gz ${INSTALLSET} else zip -r ${BUILD_OUTPUT_DIRECTORY}/${INSTALLSET}.zip ${INSTALLSET} fi ) } # Create native language packages # # Syntax: CreateNativeLangPacks [debug] # CreateNativeLangPacks () { # Do not remove RPM packages for language packs (see #i36837#) export DONT_REMOVE_PACKAGE="yes" # Create the directory where language packs will be copied LANGPACKSDIRECTORY=${BUILD_OUTPUT_DIRECTORY}/OOo_${VERSION}_native_${OOARCHENVIRONMENT}_langpacks [ "x$1" != "x" ] && LANGPACKSDIRECTORY=${LANGPACKSDIRECTORY}_$1 ( cd instsetoo_native/util dmake ooolanguagepack ) # Remove useless shell scripts. rm -rf instsetoo_native/${OOOUTPATH}.pro/OpenOffice_languagepack/install/*/{RPMS,packages}/*sh if [ ${OOO_BUILD_SYSTEM} == "Windows" ] then mkdir -p ${LANGPACKSDIRECTORY} ( cd instsetoo_native/${OOOUTPATH}.pro/OpenOffice_languagepack/install/ for LANGUAGE in ${SUPPORTEDLANGUAGES} do [ -d ${LANGUAGE}_download ] && mv ${LANGUAGE}_download/*.exe ${LANGPACKSDIRECTORY} [ -d en-US_${LANGUAGE}_download ] && mv en-US_${LANGUAGE}_download/*.exe ${LANGPACKSDIRECTORY} done ) elif [ ${OOO_BUILD_SYSTEM} == "Linux" -o ${OOO_BUILD_SYSTEM} == "Linux64" ] then mkdir -p ${LANGPACKSDIRECTORY}_rpm cp -r instsetoo_native/${OOOUTPATH}.pro/OpenOffice_languagepack/install/*/RPMS/* ${LANGPACKSDIRECTORY}_rpm mkdir -p ${LANGPACKSDIRECTORY}_deb # FIXME: pack them in one tar.gz... cp -r instsetoo_native/${OOOUTPATH}.pro_DEBIAN/OpenOffice_languagepack/install/*/DEBS/*.deb ${LANGPACKSDIRECTORY}_deb elif [ ${OOO_BUILD_SYSTEM} == "Solaris" ] then mkdir -p ${LANGPACKSDIRECTORY} # FIXME: verify! tar.gz pack packages? cp -r instsetoo_native/${OOOUTPATH}.pro/OpenOffice_languagepack/install/*/packages/* ${LANGPACKSDIRECTORY} elif [ ${OOO_BUILD_SYSTEM} == "MacOSX" ] then mkdir -p ${LANGPACKSDIRECTORY} ( cd instsetoo_native/${OOOUTPATH}.pro/OpenOffice_languagepack/install/ for i in ${SUPPORTEDLANGUAGES} do [ $i == "log" ] && continue cd $i/darwin-*-powerpc # FIXME: verify! tar.gz pack packages? tar cvfz ${LANGPACKSDIRECTORY}/openofficeorg-$i.tar.gz * cd ../.. done ) fi } # Create native packages for installers # # Syntax: CreateNativeInstallers # CreateNativeInstallers () { INSTSETSDIR=instsetoo_native/${OOOUTPATH}.pro/OpenOffice/install INSTSETSDIRDEB=instsetoo_native/${OOOUTPATH}.pro_DEBIAN/OpenOffice/install if [ ${OOO_BUILD_SYSTEM} = "Windows" ] then ( cd ${INSTSETSDIR} for LANGUAGE in ${SUPPORTEDLANGUAGES} do mv ${LANGUAGE}_download/*.exe ${BUILD_OUTPUT_DIRECTORY} [ -d en-US_${LANGUAGE}_download ] && mv en-US_${LANGUAGE}_download/*.exe ${BUILD_OUTPUT_DIRECTORY} done ) elif [ ${OOO_BUILD_SYSTEM} == "Linux" -o ${OOO_BUILD_SYSTEM} == "Linux64" ] then # RPM packages ( # Save user installation scripts to copy them back to instsets later cp -r solver/${BUILD_NUMBER}/${OOOUTPATH}.pro/bin/userscripts/* ${BUILD_OUTPUT_DIRECTORY} cd ${INSTSETSDIR} for LANGUAGE in ${SUPPORTEDLANGUAGES} do cd $LANGUAGE cp -r ${BUILD_OUTPUT_DIRECTORY}/{install,uninstall} . tar cvfz ${BUILD_OUTPUT_DIRECTORY}/OOo_${VERSION}_${LANGUAGE}_native_${OOARCHENVIRONMENT}_install_rpm.tar.gz \ RPMS install uninstall rm -rf RPMS cd .. done rm ${BUILD_OUTPUT_DIRECTORY}/{install,uninstall} ) ( cd ${INSTSETSDIRDEB} for LANGUAGE in * do [ ! -d $LANGUAGE/DEBS ] && continue cd $LANGUAGE tar cvfz ${BUILD_OUTPUT_DIRECTORY}/OOo_${VERSION}_${LANGUAGE}_native_${OOARCHENVIRONMENT}_install_deb.tar.gz DEBS rm -rf DEBS cd .. done ) elif [ ${OOO_BUILD_SYSTEM} = "Solaris" ] then ( # VERIFY: complete installations packaging... cp -r solver/${BUILD_NUMBER}/${OOOUTPATH}.pro/bin/userscripts/* ${BUILD_OUTPUT_DIRECTORY} cd ${INSTSETSDIR} for LANGUAGE in * do [ $LANGUAGE == "log" ] && continue cd $LANGUAGE cp -r ${BUILD_OUTPUT_DIRECTORY}/{install,uninstall,admin} . # FIXME: test! /usr/bin/tar cvfE - packages install uninstall admin | gzip -c > ${BUILD_OUTPUT_DIRECTORY}/OOo_${VERSION}_${LANGUAGE}_native_${OOARCHENVIRONMENT}_install.tar.gz cd .. done rm ${BUILD_OUTPUT_DIRECTORY}/{admin,install,uninstall} ) elif [ ${OOO_BUILD_SYSTEM} = "MacOSX" ] then ( cd ${INSTSETSDIR} for LANGUAGE in ${SUPPORTEDLANGUAGES} do [ $LANGUAGE == "log" ] && continue cd $LANGUAGE/darwin-*-powerpc tar cvfz ${BUILD_OUTPUT_DIRECTORY}/OOo_${VERSION}_${LANGUAGE}_native_${OOARCHENVIRONMENT}_install.tar.gz * cd ../.. done ) fi } # Copy URE packages # # Syntax: CreateURE # CreateURE () { INSTSETSDIR=instsetoo_native/${OOOUTPATH}.pro/URE/install INSTSETSDIRDEB=instsetoo_native/${OOOUTPATH}.pro_DEBIAN/URE/install UREDESTDIR=${BUILD_OUTPUT_DIRECTORY}/URE mkdir -p ${UREDESTDIR} if [ ${OOO_BUILD_SYSTEM} = "Windows" ] then mv ${INSTSETSDIR}/en-US_download/*.exe ${UREDESTDIR} elif [ ${OOO_BUILD_SYSTEM} == "Linux" -o ${OOO_BUILD_SYSTEM} == "Linux64" ] then mv ${INSTSETSDIR}/en-US/RPMS/*.rpm ${UREDESTDIR} mv ${INSTSETSDIRDEB}/en-US/DEBS/*.deb ${UREDESTDIR} elif [ ${OOO_BUILD_SYSTEM} = "Solaris" ] then # FIXME echo FIXME elif [ ${OOO_BUILD_SYSTEM} = "MacOSX" ] then # FIXME echo FIXME fi } # Create SDK archive # # Syntax: CreateSDK # CreateSDK() { ( cd sdk_oo build.pl if [ ${OOO_BUILD_SYSTEM} != "Windows" ] then cp ${OOOUTPATH}*/bin/OpenOffice.org*_SDK.tar.gz ${BUILD_OUTPUT_DIRECTORY}/OOo_${VERSION}_${OOARCHENVIRONMENT}_sdk.tar.gz else cp ${OOOUTPATH}*/bin/OpenOffice.org*_SDK.zip ${BUILD_OUTPUT_DIRECTORY}/OOo_${VERSION}_${OOARCHENVIRONMENT}_sdk.zip fi ) } # Strip all binaries in the solver tree. # # Syntax: StripEverything # StripEverything () { # TEMP: exceptions (see Issue #i19570#) # FIXME: isn't this fixed in new deliver.pl? strip solver/${BUILD_NUMBER}/${OOOUTPATH}.pro/bin/{loader.bin,gnomeint,javaldx,pagein,msfontextract,ooovirg} rm -rf instsetoo/${OOOUTPATH}* ( cd instsetoo/util dmake strip=true ) } # # This function extracts GSI files for all supported languages # ExtractGSI () { LOCALIZE=localize [ ${OOO_BUILD_SYSTEM} = "Windows" ] && LOCALIZE="guw.pl -env ${LOCALIZE}" GSIOUT=${BUILD}/GSI mkdir -p ${GSIOUT} # FIXME: Use $alllanguages from postset.mk somehow? for language in 01:en-US 03:pt 07:ru 10:eu 26:ns 27:af 28:zu 29:tn 30:el 31:nl 33:fr 34:es 35:fi 36:hu 37:ca 38:gl 39:it 42:cs 43:sk 45:da 46:sv 47:nb 48:pl 49:de 50:sl 53:cy 55:pt-BR 58:lt 66:th 77:et 79:nn 81:ja 82:ko 86:zh-CN 88:zh-TW 90:tr 91:hi-IN 93:kn 96:ar 97:he do LANGNR=`echo $language|awk -F: '{print $1}'` LANGCODE=`echo $language|awk -F: '{print $2}'` if [ $DEVEL == "no" ] then ${LOCALIZE} -e -i ${LANGCODE} -l 01,${LANGNR}=01 -f ${GSIOUT}/GSI-${VERSION}-${LANGCODE}.txt else ${LOCALIZE} -e -l en-US,${LANGCODE}=en-US -f ${GSIOUT}/${LANGCODE}.sdf fi done } # # This function extracts PO files for all supported languages # ExtractPO () { unset PYTHONHOME export PYTHONPATH=${BUILD}/lib/python mkdir -p ${BUILD_OUTPUT_DIRECTORY}/PO # FIXME: $alllanguages? for language in 01:en-US 03:pt 07:ru 10:eu 26:ns 27:af 28:zu 29:tn 30:el 31:nl 33:fr 34:es 35:fi 36:hu 37:ca 38:gl 39:it 42:cs 43:sk 45:da 46:sv 47:nb 48:pl 49:de 50:sl 53:cy 55:pt-BR 58:lt 66:th 77:et 79:nn 81:ja 82:ko 86:zh-CN 88:zh-TW 90:tr 91:hi-IN 93:kn 96:ar 97:he do LANGNR=`echo $language|awk -F: '{print $1}'` LANGCODE=`echo $language|awk -F: '{print $2}'` # Do not generate PO files for English and German [ $LANGCODE = "en-US" ] && continue [ $LANGCODE = "de" ] && continue mkdir -p ${LANGCODE} # FIXME: still produces error messages when there is only one entry for string (en-US only) ${BUILD}/bin/oo2po ${BUILD_OUTPUT_DIRECTORY}/GSI/${LANGCODE}.sdf ${LANGCODE} tar cvfz ${BUILD_OUTPUT_DIRECTORY}/PO/OpenOffice.org-${VERSION}-PO-${LANGCODE}.tar.gz ${LANGCODE} rm -rf ${LANGCODE} # FIXME: command to convert PO files to GSI file # ${BUILD}/bin/po2oo -l cs -t cs.sdf PO GSI_cs.txt # localize -m -l cs -f GSI_cs.txt done } # # This function extracts POT files # ExtractPOT () { LOCALIZE=localize [ ${OOO_BUILD_SYSTEM} = "Windows" ] && LOCALIZE="guw.pl -env ${LOCALIZE}" GSIOUT=${BUILD}/GSI mkdir -p ${GSIOUT} echo "Generating English (US) GSI/SDF file..." ${LOCALIZE} -e -l en-US -f ${GSIOUT}/en-US.sdf unset PYTHONHOME export PYTHONPATH=${BUILD}/lib/python mkdir -p pot ${BUILD_OUTPUT_DIRECTORY} echo "Generating English (US) POT files..." ${BUILD}/bin/oo2po -P ${GSIOUT}/en-US.sdf pot cp ${GSIOUT}/en-US.sdf . tar cvfz ${BUILD_OUTPUT_DIRECTORY}/OpenOffice.org-${VERSION}-POT.tar.gz pot en-US.sdf rm -rf pot } # # This function extracts all README.html files for all supported languages # ExtractREADME () { ( for i in AFRIK ARAB BASQUE CAT CHINSIM CHINTRAD CZECH DAN DTCH ENUS ESTONIAN FINN FREN GAL GREEK HEBREW HUNG ITAL JAPN KANNADA KOREAN LITHUANIAN NORBOK NORNYN NSOTHO POL PORT PORTBR RUSS SLOVAK SLOVENIAN SPAN SWED TSWANA TURK WELSH ZULU do export RES_$i=TRUE done cd readlicense_oo build.pl ) mkdir READMEs cp `find readlicense_oo/${OOOUTPATH}.pro -name readme*.html` READMEs }