From e35817d5bf04ddd95283e64be06be46058892683 Mon Sep 17 00:00:00 2001
From: DeaDDooMER <deaddoomer@deadsoftware.ru>
Date: Sat, 11 Mar 2017 19:21:19 +0300
Subject: [PATCH] Generate JAD automatically

---
 .gitignore               |  2 ++
 BUGS                     |  1 +
 make.sh                  | 36 ++++++++++++++++++++++++++++++++++++
 res/META-INF/MANIFEST.MF |  9 ---------
 4 files changed, 39 insertions(+), 9 deletions(-)
 delete mode 100644 res/META-INF/MANIFEST.MF

diff --git a/.gitignore b/.gitignore
index 86ac337..2e8e4a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
 fs/
 mp3CC
 *.jar
+*.jad
 *.class
 *.bsf
+MANIFEST.MF
diff --git a/BUGS b/BUGS
index 29fcd09..dfd5505 100644
--- a/BUGS
+++ b/BUGS
@@ -34,3 +34,4 @@
 После удаления всех сохранений кнопки остаются на вид активными
 Даже в четвёртой альфе грибы генерировались в пещерах! Нужно вернуть!
 + Текстурпаки вроде как не работают
++ Нужно автоматически генерировать манифест и jad
diff --git a/make.sh b/make.sh
index db833cc..7236ef0 100755
--- a/make.sh
+++ b/make.sh
@@ -1,5 +1,11 @@
 #!/bin/sh
 
+NAM=CaveCraft
+VER=1.9.0
+VEN=DeaDSoftWare
+URL=https://deadsoftware.ru
+ICO=/title/icon.png
+
 # MPC="/home/deaddoomer/work/mp3CC-linux/mpc/mp3CC"
 # MPS="/home/deaddoomer/work/mp3CC-linux/mps/stubs"
 # MPL="/home/deaddoomer/work/mp3CC-linux/mpl"
@@ -41,10 +47,40 @@ do
 	mp3cc "$I"
 done
 
+mkdir -p $OBJ/META-INF
+cat > $OBJ/META-INF/MANIFEST.MF <<!
+Manifest-Version: 1.0
+MIDlet-1: $NAM, $ICO, FW
+MIDlet-Name: $NAM
+MIDlet-Vendor: $VEN
+MIDlet-Version: $VER
+MicroEdition-Configuration: CLDC-1.0
+MicroEdition-Profile: MIDP-2.0
+MIDlet-Icon: $ICO
+Created-By: $VEN
+!
+
 echo "===> Package binary"
 
 jar cfM bin.jar \
     $(printJarClass $MPS) \
     $(printJarClass $OBJ) \
     $(printJarClass $LIB) \
+    -C $OBJ META-INF \
     -C $RES .
+
+# http://www.oracle.com/technetwork/systems/index-156899.html
+
+cat > bin.jad <<!
+Manifest-Version: 1.0
+MIDlet-1: $NAM, $ICO, FW
+MIDlet-Name: $NAM
+MIDlet-Vendor: $VEN
+MIDlet-Jar-URL: $URL
+MIDlet-Jar-Size: $(stat -c %s bin.jar)
+MIDlet-Version: $VER
+MicroEdition-Configuration: CLDC-1.0
+MicroEdition-Profile: MIDP-2.0
+MIDlet-Icon: $ICO
+Created-By: $VEN
+!
diff --git a/res/META-INF/MANIFEST.MF b/res/META-INF/MANIFEST.MF
deleted file mode 100644
index 4ab2654..0000000
--- a/res/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,9 +0,0 @@
-Manifest-Version: 1.0
-MIDlet-1: CaveCraft, /title/icon.png, FW
-MIDlet-Name: CaveCraft
-MIDlet-Vendor: DeaDSoftWare
-MIDlet-Version: 1.9.0
-MicroEdition-Configuration: CLDC-1.0
-MicroEdition-Profile: MIDP-2.0
-MIDlet-Icon: /title/icon.png
-Created-By: DeaDSoftWare
-- 
2.29.2