You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

updateBundledPlugins.sh 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. jar=$1
  7. dir=`mktemp -d`
  8. config="$dir/com/dmdirc/version.config"
  9. # Read the jar's version.config out
  10. unzip -qq $jar com/dmdirc/version.config -d $dir;
  11. # Check for previous data
  12. startOffset=`grep -n "Begin updateBundledPlugins.sh" $config | head -n 1 | cut -f 1 -d ':'`
  13. endOffset=`grep -n "End updateBundledPlugins.sh" $config | tail -n 1 | cut -f 1 -d ':'`
  14. if [ -n "$startOffset" -a -n "$endOffset" ]; then
  15. # Previous data found, let's get rid of it
  16. head -n $(($startOffset-2)) $config >> $config.tmp;
  17. tail -n +$(($endOffset+1)) $config >> $config.tmp;
  18. mv $config.tmp $config;
  19. fi;
  20. # Add our new sections
  21. echo "" >> $config;
  22. echo "# --- Begin updateBundledPlugins.sh (`date`) --- " >> $config
  23. echo "keysections:" >> $config;
  24. echo " bundledplugins_versions" >> $config;
  25. echo "" >> $config;
  26. echo "bundledplugins_versions:" >> $config;
  27. # For each plugin in the jar...
  28. for plugin in `unzip -qql $jar plugins/* | cut -f 2 -d '/'`; do
  29. pluginName=${plugin%.jar}
  30. # Extract it to our temporary dir (can't extract zip files from stdin)
  31. unzip -qqj $jar plugins/$plugin -d $dir;
  32. # Read the plugin.config file and parse out the version number
  33. version=`unzip -c $dir/$plugin META-INF/plugin.config | grep -C 1 version: | grep number= | cut -f 2 -d '='`;
  34. # And add the version to our version.config
  35. echo " $pluginName=$version" >> $config;
  36. done;
  37. echo "# --- End updateBundledPlugins.sh --- " >> $config;
  38. # Update the version in the jar
  39. jar uf $jar -C $dir com/dmdirc/version.config;
  40. # Remove the temporary directory
  41. rm -rf $dir;