File indexing completed on 2024-05-12 16:28:26

0001 #! /bin/bash
0002 #
0003 # usage: calligra_create_releaseconfig.sh <version> <gittag>
0004 #
0005 # This script does:
0006 # - Clones the git repository int a temporary directory
0007 # - Checks out the version (tag)
0008 # - Extracts pot file names form Message.sh files
0009 # - Removes the temporary git clone
0010 # - Creates a config.ini file for create_tarball_kf5.rb script
0011 #
0012 # This means the repository will be downloaded twice, but it means we can use a standard create_tarball_kf5.rb
0013 # so we do not risk messing things up for everybody else.
0014 #
0015 if [[ $# -ne 2 ]]; then
0016     echo "Usage: calligra_create_releaseconfig.sh <version> <gittag>"
0017     echo "Ex: calligra_create_releaseconfig.sh 3.0.0 v3.0.0"
0018     exit 1
0019 fi
0020 
0021 version=$1
0022 gittag=$2
0023 
0024 gitdir="./tmp"
0025 rm -rf "$gitdir"
0026 mkdir "$gitdir"
0027 
0028 echo "Clone git repository to extract po file names..."
0029 here=$PWD
0030 cd "$gitdir"
0031 git archive --remote git://anongit.kde.org/calligra.git "$gittag" | tar -x
0032 cd "$here"
0033 
0034 #
0035 # Grab the names of generated pot files from the Messages.sh files
0036 #
0037 # The 'grep MSGCAT' treats messages in scripting (krossmoduleplan,pot, etc), which has a line like this:
0038 # ${MSGCAT} -F "$podir/${POT_CPP}" "$podir/${POT_PY}" --use-first > $podir/krossmoduleplan.pot
0039 #
0040 # The other treats all else, with a line like this:
0041 # kundo2_aware_xgettext calligra.pot $LIST
0042 #
0043 # Any deviation from these patterns will cause problems
0044 #
0045 echo "Extract po file names..."
0046 po_list=$(find $gitdir -name 'Messages.sh' | while read messagefile; do
0047     if grep -q 'MSGCAT' $messagefile
0048     then cat $messagefile | grep 'MSGCAT' | cut -d'>' -f2 | cut -d'/' -f2 | cut -d'.' -f1 | sort -f | uniq
0049     else cat $messagefile | grep '\.pot' | cut -d' ' -f2 | cut -d'.' -f1 | sort -f | uniq
0050     fi
0051 done)
0052 
0053 # replace newline with ',' to make a comma separated list
0054 po_list=${po_list//$'\n'/,}
0055 #echo $po_list
0056 if [ -z "$po_list" ]; then
0057     echo "No po file names extracted"
0058     exit 3
0059 fi
0060 
0061 # do not need this anymore
0062 rm -rf $gitdir
0063 
0064 echo "Create config.ini file..."
0065 
0066 echo "[calligra]" > config.ini
0067 echo "gitModule   = yes" >> config.ini
0068 echo "gitTag      = $gittag" >> config.ini
0069 echo "mainmodule  = calligra" >> config.ini
0070 echo "submodule   = calligra" >> config.ini
0071 echo "version     = $version" >> config.ini
0072 echo "translations= yes" >> config.ini
0073 echo "docs        = no" >> config.ini
0074 echo "kde_release = no" >> config.ini
0075 echo "custompo    = $po_list" >> config.ini
0076