Createrpk.sh

From Ninerpedia
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
#!/bin/bash

# Procedure to build layout file and to pack the rpk
layout() {
  # P1 is a marker; cat is used here to copy the contents between the P1 markers to a file
  cat > layout.xml << P1
<?xml version="1.0" encoding="utf-8"?>
<romset version="1.0">
  <resources>
P1
if [ -f $1"g.bin" ]
then
  cat >> layout.xml << P2
     <rom id="gromimage" file="$1g.bin"/>
P2
fi
if [ -f $1"c.bin" ]
then
  cat >> layout.xml << P3
     <rom id="romimage" file="$1c.bin"/>
P3
fi
if [ -f $1"d.bin" ]
then
  cat >> layout.xml << P4
     <rom id="rom2image" file="$1d.bin"/>
P4
fi
if [ $2 = "minimem" ]
then
  cat >> layout.xml << P5
     <ram id="bufferedram" file="$1.nv" type="persistent" length="4096"/>
P5
fi
if [ $2 = "mbx" ]
then
  cat >> layout.xml << P6
     <ram id="bufferedram" file="$1.nv" type="persistent" length="1024"/>
P6
fi
cat >> layout.xml << P7
  </resources>
  <configuration>
      <pcb type="$2">
P7

if [ -f $1"g.bin" ]
then
  cat >> layout.xml << P8
         <socket id="grom_socket" uses="gromimage"/>
P8
fi
if [ -f $1"c.bin" ]
then
  cat >> layout.xml << P9
         <socket id="rom_socket" uses="romimage"/>
P9
fi
if [ -f $1"d.bin" ]
then
  cat >> layout.xml << P10
         <socket id="rom2_socket" uses="rom2image"/>
P10
fi
if [ -f $1"m.bin" -o -f $1"b.bin" ]
then
  cat >> layout.xml << P11
         <socket id="ram_socket" uses="bufferedram"/>
P11
fi
cat >> layout.xml << P12
      </pcb>
  </configuration>
</romset>
P12
echo Creating $1.rpk
zip -m $1.rpk layout.xml $1?.bin
} 

 
for myfile in *g.bin
do
  ismbx=`grep -q "MBX CONSOLE" $myfile; echo $?`
  ismini=`grep -q "MINI MEMORY" $myfile; echo $?`

  # cut off the suffix including g
  part=${myfile%%g.bin}

  # if there is a file called (what is left)c.bin...
  if [ -f $part"c.bin" ]
  then
     if [ -f $part"d.bin" ]
     then
        layout $part paged
     else
        if [ $ismini -eq 0 ]
        then
           layout $part minimem
        else
           if [ $ismbx -eq 0 ]
           then
              layout $part mbx
           else
              layout $part standard
           fi
        fi
     fi
  else
     if [ $ismbx -eq 0 ]
     then
         layout $part mbx
     else
         layout $part standard
     fi
  fi
done

# See what's left
for myfile in *c.bin
do
  part=${myfile%%c.bin}
  ismbx=`grep -q "MBX CONSOLE" $myfile; echo $?`
  if [ -f $part"d.bin" ]
    then
       layout $part paged
    else
       if [ $ismbx -eq 0 ]
       then
           layout $part mbx
       else
           layout $part standard
       fi
    fi
done