Translation update done using Pootle.
[gammu.git] / utils / jadmaker
blob99de15ec213cd20d009eec530cf8ca2ae281895d
1 #!/bin/bash
2 # JAD file generator
3 # Copyright © 2008 - 2009 Michal Čihař <michal@cihar.com>
4 # vim: expandtab sw=4 ts=4 sts=4:
6 # Defaults
7 DEFURL=http://www.gammu.org/
9 # Parameters
10 FORCE=0
11 URL="$DEFURL"
13 usage() {
14 echo "Usage: jadmaker [-f] <filename.jar>..."
18 help() {
19 usage
20 echo
21 echo "-h / --help Show this help"
22 echo "-f / --force Force rewriting JAD file"
23 echo "-u / --url URL URL to include in JAR (default=$DEFULR)"
24 echo
27 makejad() {
28 if [ ! -f "$1" ] ; then
29 echo "File $1 does not exist!"
30 exit 1
32 JAD="${1%.*}.jad"
33 if [ "$FORCE" -eq 0 -a -f "$JAD" ] ; then
34 read -p "File $JAD already exists, overwrite? (y/N)" res
35 case "$res" in
36 y|Y|yes|YES)
37 rm -f "$JAD"
40 echo "Not overwriting $JAD"
41 exit
43 esac
46 # Extract manifest as text file (convert end of lines) and delete empty lines
47 unzip -aa -p "$1" "META-INF/MANIFEST.MF" \
48 | sed '/^[[:space:]]*$/d' \
49 > "$JAD"
51 # Some needed variables
52 echo "MIDlet-Jar-Size: $(stat -c%s "$1")" >> "$JAD"
53 echo "MIDlet-Jar-URL: $(basename "$1")" >> "$JAD"
54 echo "MIDlet-Info-URL: $URL" >> "$JAD"
56 echo "File $JAD created"
60 while [ "$#" -gt 0 ] ; do
61 case "$1" in
62 -?|-h|--help)
63 help
64 exit
66 -f|--force)
67 FORCE=1
69 -u|--url)
70 if [ $# -lt 2 ] ; then
71 echo "Missing parameter for URL!"
72 exit 1
74 shift
75 URL="$1"
78 makejad "$1"
79 if [ $? -ne 0 ] ; then
80 exit 1
83 esac
84 shift
85 done