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 # We need to make sure that we have a tree without any unstaged
50 # commits. Otherwise commit will fail.
51 if git status --porcelain -uno | grep -q .; then
52 echo "Your git tree is not clean. Please correct the situation and re-run.";
54 git status --porcelain -uno;
58 # Are we in trunk or branch?
60 if ls status.* 2>/dev/null | grep -q status; then
66 echo "Cannot cd to po/ directory!";
72 make update-po >/dev/null 2>&1;
75 if [ -n "$TRUNK" ]; then
76 I18NFILE=i18n_trunk.inc;
81 # make sure things are clean
83 svn revert $FARM/$I18NFILE;
85 echo Running make i18n.inc...
86 make i18n.inc >/dev/null 2>&1;
87 if [ -n "$TRUNK" ]; then
88 mv -f i18n.inc i18n_trunk.inc
91 if diff -w -q $I18NFILE $FARM/$I18NFILE >/dev/null 2>&1; then
92 echo No string differences found.
97 # So there are differences.
98 if [ -z "$COMMIT" ]; then
99 echo "Differences found!";
100 diff -wu $FARM/$I18NFILE $I18NFILE | less;
105 $DEBUG git commit *.po -m "Remerge strings.";
106 COMMITS=$(git push -n 2>&1 | tail -n 1 | grep -v "Everything" | sed -e 's/^ *//' -e 's/ .*//');
108 if [ -z "$COMMITS" ]; then
109 echo "We seem to be missing the commit of the po files!";
115 #Do we want to go ahead?
117 echo "Do you want to push these commits?"
118 select answer in Yes No; do
119 if [ "$answer" != "Yes" ]; then
120 echo "You will need to push that commit manually, then.";
131 echo "Unable to cd to $FARM!";
135 echo Updating the www-user tree...
136 # note that we're assuming this one is svn.
139 echo Moving $I18NFILE...;
140 mv $LYXROOT/po/$I18NFILE .;
143 $DEBUG svn commit -m "* $I18NFILE: update stats" $I18NFILE;