diff --git a/update b/update index 605ff69..ad42ed5 100755 --- a/update +++ b/update @@ -17,36 +17,40 @@ source "$(dirname "$0")/variables" -echo -e "Language: $RED$LCODE$ENDCOLOR" +echo -e "Language: ${RED}${LCODE}${ENDCOLOR}" for BRANCH in $BRANCHES; do - echo -e "Checking out files from $BLUE$BRANCH$ENDCOLOR" - if [ ! -e "$BRANCH" ]; then - mkdir "$BRANCH" - fi - "$GIT" archive --remote "$REPO" --prefix="$BRANCH-temp/" --format=tar "$BRANCH:po" | tar x - for dir in $(ls "$BRANCH-temp/wesnoth"* -d); do - echo "Processing $(basename "$dir" | sed s/wesnoth-//).$LCODE.po" - file="$BRANCH/$(basename "$dir" | sed s/wesnoth-//).$LCODE.po" - if [ -f "$dir""/$LCODE"".po" ]; then - if [ -f "$file" ]; then - echo -e "${BLUE}Merging:$ENDCOLOR" - $MSGMERGE -U -v "$file" "$dir/$(basename "$dir").pot" - rm -f "$file~" - else - echo -e "${RED}Copying:$ENDCOLOR" - cp "$dir/$LCODE.po" "$file" - fi - else - if [ ! -f "$file" ]; then - echo -e "${RED}No po file in repository. Running msginit.$ENDCOLOR" - echo "$dir" - "$MSGINIT" -i "$dir/$(basename "$dir").pot" -o "$file" - else - echo -e "${RED}No po file in repository. Found file in workspace.$ENDCOLOR" - fi - fi - echo "" - done - rm -rf "$BRANCH-temp" + echo -e "Checking out files from ${BLUE}${BRANCH}${ENDCOLOR}" + if [ ! -e "$BRANCH" ]; then + CURRENT_DIR="$PWD" + ( + cd $LOCAL_REPO + git worktree add "${CURRENT_DIR}/${BRANCH}" "$BRANCH" + ) + fi + git archive --remote "$REPO" --prefix="${BRANCH}-temp/" --format=tar "${BRANCH}:po" | tar x + for dir in $(ls "${BRANCH}-temp/wesnoth"* -d); do + echo "Processing $(basename "$dir" | sed s/wesnoth-//).${LCODE}.po" + file="${BRANCH}/$(basename "$dir" | sed s/wesnoth-//).${LCODE}.po" + if [ -f "${dir}/${LCODE}.po" ]; then + if [ -f "$file" ]; then + echo -e "$BLUE""Merging:$ENDCOLOR" + msgmerge -U -v "$file" "${dir}/$(basename "$dir").pot" + rm -f "$file~" + else + echo -e "${RED}Copying:${ENDCOLOR}" + cp "${dir}/${LCODE}.po" "$file" + fi + else + if [ ! -f "$file" ]; then + echo -e "${RED}No po file in repository. Running msginit.${ENDCOLOR}" + echo "$dir" + msginit -i "$dir/$(basename "$dir").pot" -o "$file" + else + echo -e "${RED}No po file in repository. Found file in workspace.${ENDCOLOR}" + fi + fi + echo "" + done + rm -rf "${BRANCH}-temp" done -echo -e "${GREEN}Finished.$ENDCOLOR" +echo -e "${GREEN}Finished.${ENDCOLOR}" diff --git a/variables b/variables index 16f924d..f9a59c4 100644 --- a/variables +++ b/variables @@ -1,6 +1,6 @@ #!/bin/bash # You would probably need to make some adjustments to variables. -# Copyright (C) 2008 Andrius Štikonas +# Copyright (C) 2008 Andrius Štikonas # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,7 +17,8 @@ # Repositories REPO="~/repositories/wesnoth" # preferably local clone but remote should work as well -BRANCHES="master" # one or multiple branches separated by space. +LOCAL_REPO="git" # should be bare repository +BRANCHES="1.8 1.10 1.12 1.14 master" # one or multiple branches separated by space. # Options LCODE="lt" # Language code. Only 1 language is supported. @@ -26,14 +27,14 @@ LCODE="lt" # Language code. Only 1 language is supported. MDIR="mo" # Binaries. Don't forget to install them before usign these scripts. -GIT=$(command -v git 2> /dev/null) -MSGFMT=$(command -v msgfmt 2> /dev/null) -MSGMERGE=$(command -v msgmerge 2> /dev/null) -MSGINIT=$(command -v msginit 2> /dev/null) -ISUTF8=$(command -v isutf8 2> /dev/null) -TAR=$(command -v tar 2> /dev/null) -BZIP=$(command -v bzip2 2> /dev/null) -DIFF=$(command -v diff 2> /dev/null) +GIT=$(which git 2> /dev/null) +MSGFMT=$(which msgfmt 2> /dev/null) +MSGMERGE=$(which msgmerge 2> /dev/null) +MSGINIT=$(which msginit 2> /dev/null) +ISUTF8=$(which isutf8 2> /dev/null) +TAR=$(which tar 2> /dev/null) +BZIP=$(which bzip2 2> /dev/null) +DIFF=$(which diff 2> /dev/null) # Colors RED="\033[1;31m"