2011-06-16 14:45:15 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# A script to check whether there have been any string changes.
|
|
|
|
|
|
|
|
# The script expects an environment variable FARM that
|
|
|
|
# will provide it with the location of the LyX www tree.
|
|
|
|
|
2011-06-16 15:11:02 +00:00
|
|
|
DEBUG="";
|
|
|
|
|
|
|
|
while getopts ":dh" options $ARGS; do
|
|
|
|
case $options in
|
|
|
|
d) DEBUG="echo";;
|
|
|
|
h) echo "check-po.sh [-d]"; echo "You must also point the FARM variable to LyX's www tree."; exit 0;;
|
|
|
|
esac
|
|
|
|
done
|
2011-06-16 14:45:15 +00:00
|
|
|
|
|
|
|
if [ -z "$FARM" ]; then
|
|
|
|
echo "You must set the FARM variable to run this script, e.g.:";
|
|
|
|
echo "# FARM=/cvs/lyx-www/ bash check-po.sh";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
FARM=${FARM%/};
|
|
|
|
FARM="$FARM/farm/cookbook/LyX";
|
|
|
|
# Sanity check
|
|
|
|
if [ ! -f "$FARM/i18n.php" ]; then
|
|
|
|
echo "$FARM does not look like LyX's www tree!";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get us to the root of the tree we are in.
|
|
|
|
MYDIR=${0%check-po.sh};
|
|
|
|
if [ -n "$MYDIR" ]; then
|
|
|
|
cd $MYDIR;
|
|
|
|
fi
|
|
|
|
cd ../../;
|
|
|
|
LYXROOT=$(pwd);
|
|
|
|
|
|
|
|
# Are we in trunk or branch?
|
|
|
|
TRUNK="TRUE";
|
|
|
|
if ls status.* 2>/dev/null | grep -q status; then
|
|
|
|
TRUNK="";
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Git or SVN?
|
|
|
|
VCS="";
|
|
|
|
if svn log >/dev/null 2>&1; then
|
|
|
|
VCS="svn";
|
2011-06-16 15:11:02 +00:00
|
|
|
elif git diff >/dev/null 2>&1; then
|
2011-06-16 14:45:15 +00:00
|
|
|
VCS="git";
|
|
|
|
fi
|
|
|
|
|
2011-06-16 15:11:02 +00:00
|
|
|
if [ -z "$VCS" ]; then
|
2011-06-16 14:45:15 +00:00
|
|
|
echo "Unable to determine version control system!";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Sanity check
|
|
|
|
if ! cd po/; then
|
|
|
|
echo "Cannot cd to po/ directory!";
|
|
|
|
pwd
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo Remerging...
|
|
|
|
make update-po >/dev/null 2>&1;
|
|
|
|
echo
|
|
|
|
|
|
|
|
if [ -n "$TRUNK" ]; then
|
|
|
|
I18NFILE=i18n_trunk.inc;
|
|
|
|
else
|
|
|
|
I18NFILE=i18n.inc;
|
|
|
|
fi
|
|
|
|
|
2011-06-16 15:18:08 +00:00
|
|
|
# make sure things are clean
|
|
|
|
rm -f i18n.inc;
|
|
|
|
svn revert $FARM/$I18NFILE;
|
|
|
|
|
|
|
|
echo Running make i18n.inc...
|
|
|
|
make i18n.inc >/dev/null 2>&1;
|
|
|
|
if [ -n "$TRUNK" ]; then
|
|
|
|
mv i18n.inc i18n_trunk.inc
|
|
|
|
fi
|
|
|
|
|
2011-06-16 15:11:02 +00:00
|
|
|
if diff -w -q $I18NFILE $FARM/$I18NFILE >/dev/null 2>&1; then
|
2011-06-16 14:45:15 +00:00
|
|
|
# No differences found
|
|
|
|
echo No string differences found.
|
|
|
|
if [ "$VCS" = "svn" ]; then
|
2011-06-16 15:11:02 +00:00
|
|
|
svn revert *.po;
|
2011-06-16 14:45:15 +00:00
|
|
|
else
|
2011-06-16 15:11:02 +00:00
|
|
|
git co *.po;
|
2011-06-16 14:45:15 +00:00
|
|
|
fi
|
|
|
|
exit 0;
|
|
|
|
fi
|
|
|
|
|
|
|
|
# else
|
|
|
|
if [ "$VCS" = "svn" ]; then
|
|
|
|
$DEBUG svn ci *.po;
|
|
|
|
else
|
2011-06-16 15:11:02 +00:00
|
|
|
NOTSAFE="";
|
|
|
|
if git status | grep -Pq 'Your branch is (?:ahead|behind)'; then
|
|
|
|
NOTSAFE="TRUE";
|
|
|
|
fi
|
2011-06-16 14:45:15 +00:00
|
|
|
$DEBUG git commit *.po -m "Remerge strings.";
|
2011-06-16 15:11:02 +00:00
|
|
|
if [ -n "$NOTSAFE" ]; then
|
|
|
|
echo "You will need to push changes to po files manually."
|
|
|
|
else
|
|
|
|
git svn dcommit;
|
|
|
|
fi
|
2011-06-16 14:45:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if ! cd $FARM; then
|
|
|
|
echo "Unable to cd to $FARM!";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
echo Updating the www-user tree...
|
2011-06-16 15:11:02 +00:00
|
|
|
# note that we're assuming this one is svn.
|
|
|
|
svn up;
|
2011-06-16 14:45:15 +00:00
|
|
|
|
2011-06-16 15:11:02 +00:00
|
|
|
echo Moving $I18NFILE...;
|
|
|
|
mv $LYXROOT/po/$I18NFILE .;
|
2011-06-16 14:45:15 +00:00
|
|
|
|
|
|
|
echo Committing...;
|
2011-06-16 15:11:02 +00:00
|
|
|
$DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE;
|
2011-06-16 14:45:15 +00:00
|
|
|
|
|
|
|
echo DONE!
|