[PC-BSD Commits] r3607 - pbibuild/pbi-source/PBCsource

svn at pcbsd.org svn at pcbsd.org
Fri Mar 6 12:58:30 PST 2009


Author: kris
Date: 2009-03-06 12:58:30 -0800 (Fri, 06 Mar 2009)
New Revision: 3607

Modified:
   pbibuild/pbi-source/PBCsource/addpbimime.sh
Log:

Updated addpbimime.sh to not rely on bash anymore, not necessary



Modified: pbibuild/pbi-source/PBCsource/addpbimime.sh
===================================================================
--- pbibuild/pbi-source/PBCsource/addpbimime.sh	2009-03-06 20:56:23 UTC (rev 3606)
+++ pbibuild/pbi-source/PBCsource/addpbimime.sh	2009-03-06 20:58:30 UTC (rev 3607)
@@ -18,6 +18,9 @@
 # First update the mime database to ensure we have an updated globs file
 update-mime-database ${BASE}/share/mime >/dev/null 2>/dev/null
 
+# Unset the EXTENSION variable
+EXTENSION=""
+
 i=1
 while
 z=1
@@ -26,8 +29,8 @@
  then
    break
  else
-   EXTENSIONS[${i}]="`echo ${EXTLIST} | cut -d ';' -f ${i} | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print}'`"
-   echo "Found: ${EXTENSIONS[${i}]}"
+   EXTENSIONS="${EXTENSIONS} `echo ${EXTLIST} | cut -d ';' -f ${i} | awk '{gsub(/^[ \t]+|[ \t]+$/,"");print}'`"
+   #echo "Found: ${EXTENSIONS[${i}]}"
  fi
 
  echo ${EXTLIST} | grep ';' >/dev/null 2>/dev/null
@@ -39,61 +42,40 @@
  i="`expr ${i} + 1`"
 done
 
-# Our extension counter which are already in the globs file
-x=0
-# Our extension counter for exts which are not in the globs file
-y=0
+EXTGLOB=""
+EXTNOBLOB=""
 
 # Reset our counter
-i=1
-while 
-z=1
+for j in $EXTENSIONS
 do
-  # Check if we are at the end of available exentions and break
-  if [ -z "${EXTENSIONS[${i}]}" ]
-  then
-     break
-  else
       # First parse ${BASE}/share/mime/globs to see if we have this ext
-      grep "${EXTENSIONS[${i}]}" ${BASE}/share/mime/globs >/dev/null 2>/dev/null
+      grep "${j}" ${BASE}/share/mime/globs >/dev/null 2>/dev/null
       if [ "$?" = "0" ]
       then
          # This ext is in the globs file, save it as such
-         EXTGLOB[${x}]="${EXTENSIONS[${i}]}"
-         x="`expr ${x} + 1`"
+         EXTGLOB="${EXTGLOB} ${j}"
       else
          # This ext is not in the globs file, save it as such
-         EXTNOGLOB[${y}]="${EXTENSIONS[${i}]}"
-         y="`expr ${y} + 1`"
+         EXTNOGLOB="${EXTNOGLOB} ${j}"
       fi
-     
-  fi
-
-  # Increment our counter
-  i="`expr ${i} + 1`"
 done
 
 
 # Check if we have any extensions that are already in the glob which
 # need to be made, and do so now
-if [ $x -ge 1 ]
+if [ ! -z "${EXTGLOB}" ]
 then
-  # Reset our handy counter
-  i=0;
+
+  # Set our counter
+  i=0
+
   # Start our loop to go through each ext
-  while
-  z=0
+  for j in ${EXTGLOB}
   do
+    
 
-    if [ -z "${EXTGLOB[${i}]}" ]
-    then
-      break
-    fi 
-
-    #echo "EXTIN: ${EXTGLOB[${i}]}"  
-
     # Lets get the mime entry in the glob for this extension
-    MIMESTRING=`grep "${EXTGLOB[${i}]}" ${BASE}/share/mime/globs | cut -d ':' -f 1`
+    MIMESTRING=`grep "${j}" ${BASE}/share/mime/globs | cut -d ':' -f 1`
   
 
     # Now lets create the .desktop file for this type
@@ -116,27 +98,21 @@
     fi
 
     # Now add our entry for this mime type
-    echo "${MIMESTRING}=${PROGNAME}-${i}a.desktop;" >> ${BASE}/share/applications/mimeapps.list
+    echo "${MIMESTRING}=${PROGNAME}-${i}a.desktop" >> ${BASE}/share/applications/mimeapps.list
 
     i="`expr ${i} + 1`"
   done
 fi
 
 # Check if we have any extensions which are *not* in the glob and add them
-if [ $y -ge 1 ]
+if [ ! -z "${EXTNOGLOB}" ]
 then
   # Reset our handy counter
   i=0;
   # Start our loop to go through each ext
-  while
-  z=0
+  for j in ${EXTNOGLOB}
   do
 
-    if [ -z "${EXTNOGLOB[${i}]}" ]
-    then
-      break
-    fi 
-
     MIMESTRING="application/`echo \"${PROGNAME}${i}\" | sed 's/ //'`"
     echo "$MIMESTRING" > /tmp/output
 
@@ -145,7 +121,7 @@
 <mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">
   <mime-type type=\"${MIMESTRING}\">
          <comment xml:lang=\"en\">${PROGNAME} File</comment>
-         <glob pattern=\"${EXTNOGLOB[${i}]}\"/>
+         <glob pattern=\"${j}\"/>
          <desktop>${PROGNAME}-${i}b.desktop</desktop>
   </mime-type>
 </mime-info>" >"${BASE}/share/mime/packages/${PROGNAME}-${i}b.xml"



More information about the Commits mailing list