Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

updateBundledPlugins.sh 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. # updateBundledPlugins.sh <jar>
  3. #
  4. # Reads the version of each bundled plugin in the specified jar, and writes
  5. # the names and versions to the jar's version.config file.
  6. # Find out where we are
  7. BASEDIR=$(cd "${0%/*}" 2>/dev/null; echo $PWD)
  8. if [ -e "${BASEDIR}/build-functions.sh" ]; then
  9. . "${BASEDIR}/build-functions.sh"
  10. else
  11. echo "Unable to find build-functions.sh. '${BASEDIR}/build-functions.sh'"
  12. exit 1;
  13. fi;
  14. jar=$1
  15. dir=`safe_mktemp ${jar##*/}`
  16. config="$dir/com/dmdirc/version.config"
  17. CHECKJAR=`echo "${jar}" | sed 's#^/##'`
  18. if [ "${CHECKJAR}" = "$jar" ]; then
  19. jar="`pwd`/$jar"
  20. fi;
  21. cd $dir
  22. # Read the jar's version.config out
  23. jar -xf $jar
  24. # Check for previous data
  25. startOffset=`grep -n "Begin updateBundledPlugins.sh" $config | head -n 1 | cut -f 1 -d ':'`
  26. endOffset=`grep -n "End updateBundledPlugins.sh" $config | tail -n 1 | cut -f 1 -d ':'`
  27. if [ -n "$startOffset" -a -n "$endOffset" ]; then
  28. # Previous data found, let's get rid of it
  29. head -n $(($startOffset-2)) $config >> $config.tmp;
  30. tail -n +$(($endOffset+1)) $config >> $config.tmp;
  31. mv $config.tmp $config;
  32. fi;
  33. # Add our new sections
  34. echo "" >> $config;
  35. echo "# --- Begin updateBundledPlugins.sh (`date`) --- " >> $config
  36. echo "keysections:" >> $config;
  37. echo " bundledplugins_versions" >> $config;
  38. echo "" >> $config;
  39. echo "bundledplugins_versions:" >> $config;
  40. # For each plugin in the jar...
  41. for plugin in `ls plugins/* | cut -f 2 -d '/'`; do
  42. pluginName=${plugin%.jar}
  43. # Extract it to our temporary dir (can't extract zip files from stdin)
  44. jar -xf plugins/$plugin;
  45. # Read the plugin.config file and parse out the version number
  46. version=`cat META-INF/plugin.config | grep -1 version: | grep number= | cut -f 2 -d '='`;
  47. # And add the version to our version.config
  48. echo " $pluginName=$version" >> $config;
  49. done;
  50. echo "# --- End updateBundledPlugins.sh --- " >> $config;
  51. # Update the version in the jar
  52. jar uf $jar -C $dir com/dmdirc/version.config;
  53. # Remove the temporary directory
  54. cd ..
  55. rm -rf $dir;