adding jadmaker
This commit is contained in:
parent
b25d8cc3fb
commit
3557bbfe1e
1 changed files with 43 additions and 0 deletions
43
shell/jadmaker.sh
Executable file
43
shell/jadmaker.sh
Executable file
|
|
@ -0,0 +1,43 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Given a J2ME midlet jarball, create a JAD for it
|
||||
# Usage: ./jadmaker.sh <filename>
|
||||
#
|
||||
# for ii in *.jar; do ./jadmaker.sh $ii; done;
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
FILE=$1
|
||||
if [ ! -f "${FILE}" ]; then
|
||||
echo "Input file '${FILE}' missing, exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JAD="${FILE%.*}.jad"
|
||||
if [ -f "${JAD}" ]; then
|
||||
echo "${JAD} already exists, overwrite? (y/N)"
|
||||
read -r tmpans
|
||||
answer=$(echo "$tmpans" | tr '[:upper:]' '[:lower:]')
|
||||
if [ "$answer" != "y" ] && [ "$answer" != "yes" ]; then
|
||||
echo "Not overwriting ${JAD}, exiting."
|
||||
exit 1
|
||||
else
|
||||
rm -f "${JAD}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# unzip the internal manifest, changing line endings to our local OS
|
||||
# the sed action removes blank lines, with or without spaces/tabs
|
||||
unzip -aa -j -p "${FILE}" "META-INF/MANIFEST.MF" | sed -e '/^[ \t]*$/d' > "${JAD}"
|
||||
|
||||
# generic variables
|
||||
echo "MIDlet-Jar-URL: ${FILE}" >> "${JAD}"
|
||||
echo "MIDlet-Info-URL: http://" >> "${JAD}"
|
||||
|
||||
# actual jarball size
|
||||
FILESIZE=$(stat -c%s "${FILE}")
|
||||
echo "MIDlet-Jar-Size: ${FILESIZE}" >> "${JAD}"
|
||||
|
||||
# weee
|
||||
echo "Created ${JAD}."
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue