diff --git a/utils/archive.sh b/utils/archive.sh index 4bc6a8ea..20da85b4 100755 --- a/utils/archive.sh +++ b/utils/archive.sh @@ -22,6 +22,8 @@ options: -a keep 'auto.sh' scripts for missions that have one -t keep 'test.sh' scripts for missions that have one -z keep tgz archive + + -v show the list of mission directories as they are being processed EOH } @@ -52,8 +54,9 @@ GENERATE_MO=1 # KEEP_PO=1 # this is set to 1 if we generate .mo files. Setting it to 1 here # (or before generating .mo files) will keep the .po files LANGUAGES="" +VERBOSE= -while getopts ":hp:N:atPzL:E" opt +while getopts ":hp:N:atPzL:Ev" opt do case $opt in h) @@ -86,6 +89,9 @@ do KEEP_PO=0 GENERATE_MO=0 ;; + v) + VERBOSE=1 + ;; *) echo "invalid option: '-$OPTARG'" >&2 exit 1 @@ -115,7 +121,13 @@ cp -RPp "$GSH_ROOT/start.sh" "$GSH_ROOT/bin" "$GSH_ROOT/utils" "$GSH_ROOT/lib" " # copy missions mkdir "$TMP_DIR/$NAME/missions" -echo "copy missions" +if [ -z "$VERBOSE" ] +then + printf "copying missions: " +else + echo "copying missions" +fi + if ! make_index "$@" > "$TMP_DIR/$NAME/missions/index.txt" then echo "Error: archive.sh, couldn't make index.txt" @@ -123,23 +135,45 @@ then exit 1 fi +NB_MISSIONS=0 +NB_DUMMY=0 cat "$TMP_DIR/$NAME/missions/index.txt" | while read MISSION_DIR do + DUMMY= case $MISSION_DIR in "" | "#"* ) continue ;; "!"*) MISSION_DIR=$(echo "$MISSION_DIR" | cut -c2-) + NB_DUMMY=$((NB_DUMMY + 1)) + DUMMY=1 ;; esac - echo " -> copy $MISSION_DIR" + NB_MISSIONS=$((NB_MISSIONS + 1)) + if [ -z "$VERBOSE" ] + then + if [ -z "$DUMMY" ] + then + printf "." + else + printf "!" + fi + else + if [ -z "$DUMMY" ] + then + echo " - $MISSION_DIR" + else + echo " ! $MISSION_DIR (dummy)" + fi + fi mkdir -p "$TMP_DIR/$NAME/missions/$MISSION_DIR" ARCHIVE_MISSION_DIR=$TMP_DIR/$NAME/missions/$MISSION_DIR # NOTE: macOS' cp doesn't have '--archive', and '-a' is not POSIX. # use POSIX options to make sure it is portable cp -RPp "$GSH_MISSIONS/$MISSION_DIR"/* "$ARCHIVE_MISSION_DIR" done +[ -n "$VERBOSE" ] || echo # define new GSH_ROOT export GSH_ROOT="$TMP_DIR/$NAME" @@ -200,8 +234,8 @@ then PO_LANG=$(basename "$PO_FILE" .po) mkdir -p "$GSH_ROOT/locale/$PO_LANG/LC_MESSAGES" msgfmt -o "$GSH_ROOT/locale/$PO_LANG/LC_MESSAGES/$DOMAIN.mo" "$PO_FILE" - printf "." done + printf "." fi fi done < "$GSH_ROOT/missions/index.txt" @@ -220,7 +254,7 @@ echo "removing unnecessary files" find . -name "Makefile" | xargs rm -f find . -name "template.pot" | xargs rm -f [ "$KEEP_PO" -eq 0 ] && find . -name "*.po" | xargs rm -f - [ "$KEEP_TEST" -ne 1 ] && echo "remove tests" && find ./missions -name "test.sh" | xargs rm -f + [ "$KEEP_TEST" -ne 1 ] && find ./missions -name "test.sh" | xargs rm -f [ "$KEEP_AUTO" -ne 1 ] && find ./missions -name auto.sh | xargs rm -f # rm -f "$GSH_ROOT/bin/boxes-data.awk" "$GSH_ROOT/utils/archive.sh"