Cleanup comments etc. in src
[gimp-lqr-plugin.git] / zippo
blob94a7df51fc500fad6523754551bf3b3250e1e0b7
1 #! /bin/bash
3 # Functions
4 #{{{
5 function usage() {
6 cat << EOF
7 Usage: $(basename $0) [ options ]
9 Create zip file with .po files
11 Options:
12 -f, --force force overwriting existing files
13 -h, --help this help
14 EOF
17 function err_mess() {
18 echo "$(basename $0): error: $1" > /dev/stderr;
20 #}}}
22 # Init costants & parameters
23 #{{{
24 FORCE=0
25 #}}}
27 # Parse command line
28 #{{{
29 PARAMETERS=$(getopt -a -o "hf" -l "help, force" -- "$@")
31 [[ $? -ne 0 ]] && { usage; exit 1; }
33 eval set -- "$PARAMETERS"
35 while true
37 case "$1" in
38 --force)
39 FORCE=1
40 shift
42 --)
43 shift;
44 break;
46 -h|--help)
47 usage;
48 exit 0;
51 usage;
52 exit 1;
54 esac
55 done
57 [[ -n "$1" ]] && { err_mess "extra arguments in the command line"; usage; exit 1; }
58 #}}}
60 # Complete (and check) parameter initialization
61 #{{{
63 cd "$(dirname $0)"
65 [[ -f "Makefile" ]] || { echo "error: makefile not found"; exit 1; }
66 [[ -f "configure.ac" ]] || { echo "error: configure.ac not found"; exit 1; }
68 NAME=$(head -n 50 configure.ac | grep "m4_define(\[plugin_name\], \[.*\])" | sed "s/m4_define(\[plugin_name\], \[\(.*\)\])/\1/")
69 MAJOR_VER=$(head -n 50 configure.ac | grep "m4_define(\[plugin_major_version\], \[.*\])" | sed "s/m4_define(\[plugin_major_version\], \[\(.*\)\])/\1/")
70 MINOR_VER=$(head -n 50 configure.ac | grep "m4_define(\[plugin_minor_version\], \[.*\])" | sed "s/m4_define(\[plugin_minor_version\], \[\(.*\)\])/\1/")
71 MICRO_VER=$(head -n 50 configure.ac | grep "m4_define(\[plugin_micro_version\], \[.*\])" | sed "s/m4_define(\[plugin_micro_version\], \[\(.*\)\])/\1/")
73 VER="${MAJOR_VER}.${MINOR_VER}.${MICRO_VER}"
74 ZIP_NAME="po_${VER}.zip"
76 [[ $FORCE -eq 0 ]] && [[ -f "$ZIP_NAME" ]] && { err_mess "file ${ZIP_NAME} exists, use --force to force writing"; exit 1; }
78 [[ -d "po" ]] || { err_mess "po directory not found"; exit 1; }
80 which zip > /dev/null || { err_mess "zip command not found"; exit 1; }
82 #}}}
84 # Main
85 #{{{
87 rm -f "${ZIP_NAME}"
88 zip "${ZIP_NAME}" po po/*.po po/*.pot || exit 1
90 #}}}