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

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