#!/bin/bash
# no patch generated as of now.  No need to use this now but ...
####################################################################
# rough outline of use
# To use this script to update the /po/*.po files, you need to extract *.po files
# in the ibus-xkb-1.5.*.tar.gz provided by the Fedora package and 
# place them under the debian/po/ directory first.
#
# cp path/to/*.po debian/po/
#
# invoke this as "debian/update-po"
#
set -e -x

dquilt() {
quilt --quiltrc=${HOME}/.quiltrc-dpkg "$@"
}

dquilt push -a
dquilt new 999-update-po.patch
dquilt add po/*.po

POS=$(cd ./debian/po >/dev/null; ls *.po)

for PO in $POS; do
    echo "Update: $PO"
    msgcat --use-first po/$PO debian/po/$PO -o po/$PO
done

# The modification to the /po/*.po files should be recorded as the quilt patch in
# the debian/patches/ directory for use with the Debian package.
dquilt refresh
dquilt pop -a
rm -rf .pc
git add po/*.po debian/patches/999-update-po.patch debian/patches/series
git commit -m "update PO from ibus-xkb-1.5.*.tar.gz"

# Upon running this script, the /debian/po/*.po files are erased and the /po/*.po
# files are updated.

echo "Remove debian/po/*"
rm -rf debian/po

# This generated quilt patch corresponds to the following SPEC file.
# === pertinent part of SPEC file ===
# # Actual path is https://github.com/.../%%{ibus_xkb_version}.tar.gz
# # Renamed %%{ibus_xkb_version}.tar.gz to ibus-xkb-%%{ibus_xkb_version}.tar.gz
# Source3:        https://github.com/ibus/ibus-xkb/archive/ibus-xkb-%{ibus_xkb_version}.tar.gz
# 
# zcat %SOURCE3 | tar xf -
# POS=`(cd ibus-xkb-%ibus_xkb_version/po; ls *.po)`
# for PO in $POS
# do
#   cp po/$PO po/$PO.orig
#   msgcat --use-first po/$PO ibus-xkb-%ibus_xkb_version/po/$PO -o po/$PO
# done
# ====================

