2 # A script to check whether there have been any string changes.
3 # If it finds some, it commits the new po files and then updates
6 # The script expects an environment variable FARM that will provide
7 # it with the location of the LyX www tree.
12 while getopts ":cdh" options $ARGS; do
16 h) echo "update-po.sh [-c] [-d]";
17 echo "-c: Commit any changes we find.";
18 echo "-d: Debugging mode.";
19 echo "You must also point the FARM variable to LyX's www tree.";
24 if [ -z "$FARM" ]; then
25 echo "You must set the FARM variable to run this script, e.g.:";
26 echo "# FARM=/cvs/lyx-www/ bash check-po.sh";
31 FARM="$FARM/farm/cookbook/LyX";
33 if [ ! -f "$FARM/i18n.php" ]; then
34 echo "$FARM does not look like LyX's www tree!";
38 # Get us to the root of the tree we are in.
39 MYDIR=${0%update-po.sh};
40 if [ -n "$MYDIR" ]; then
42 echo "Couldn't cd to $MYDIR!";
49 # Are we in trunk or branch?
51 if ls status.* 2>/dev/null | grep -q status; then
57 if svn log -l 5 >/dev/null 2>&1; then
59 elif git diff >/dev/null 2>&1; then
61 # We need to make sure that we have a tree without any unpushed
62 # commits. Otherwise git svn dcommit would commit more than we
64 if git status | grep -Pq 'Your branch is (?:ahead|behind)'; then
65 echo "Your git tree is not clean. Please correct the situation and re-run.";
72 if [ -z "$VCS" ]; then
73 echo "Unable to determine version control system!";
79 echo "Cannot cd to po/ directory!";
85 make update-po >/dev/null 2>&1;
88 if [ -n "$TRUNK" ]; then
89 I18NFILE=i18n_trunk.inc;
94 # make sure things are clean
96 svn revert $FARM/$I18NFILE;
98 echo Running make i18n.inc...
99 make i18n.inc >/dev/null 2>&1;
100 if [ -n "$TRUNK" ]; then
101 mv -f i18n.inc i18n_trunk.inc
104 if diff -w -q $I18NFILE $FARM/$I18NFILE >/dev/null 2>&1; then
105 echo No string differences found.
106 # So we will revert the changes to po files, which are probably
107 # just dates and such.
108 if [ "$VCS" = "svn" ]; then
116 # So there are differences.
118 if [ -z "$COMMIT" ]; then
119 echo "Differences found!";
120 diff -w $I18NFILE $FARM/$I18NFILE | less;
121 if [ "$VCS" = "svn" ]; then
129 if [ "$VCS" = "svn" ]; then
132 $DEBUG git commit *.po -m "Remerge strings.";
133 $DEBUG git svn dcommit;
139 echo "Unable to cd to $FARM!";
143 echo Updating the www-user tree...
144 # note that we're assuming this one is svn.
147 echo Moving $I18NFILE...;
148 mv $LYXROOT/po/$I18NFILE .;
151 $DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE;
153 if [ -n "$NOTSAFE" ]; then
155 echo "Your LyX tree was not clean.";
156 echo "Your will need to push changes to po files manually."