post_process_dist.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #! /bin/sh
  2. # This script takes the result of "make dist" and:
  3. # 1) Unpacks it.
  4. # 2) Ensures all contents are user-writable. Some version control systems
  5. # keep code read-only until you explicitly ask to edit it, and the normal
  6. # "make dist" process does not correct for this, so the result is that
  7. # the entire dist is still marked read-only when unpacked, which is
  8. # annoying. So, we fix it.
  9. # 3) Convert MSVC project files to MSVC 2005, so that anyone who has version
  10. # 2005 *or* 2008 can open them. (In version control, we keep things in
  11. # MSVC 2008 format since that's what we use in development.)
  12. # 4) Uses the result to create .tar.gz, .tar.bz2, and .zip versions and
  13. # deposites them in the "dist" directory. In the .zip version, all
  14. # non-testdata .txt files are converted to Windows-style line endings.
  15. # 5) Cleans up after itself.
  16. if [ "$1" == "" ]; then
  17. echo "USAGE: $0 DISTFILE" >&2
  18. exit 1
  19. fi
  20. if [ ! -e $1 ]; then
  21. echo $1": File not found." >&2
  22. exit 1
  23. fi
  24. set -ex
  25. LANGUAGES="cpp csharp java js objectivec python ruby php all"
  26. BASENAME=`basename $1 .tar.gz`
  27. VERSION=${BASENAME:9}
  28. # Create a directory called "dist", copy the tarball there and unpack it.
  29. mkdir dist
  30. cp $1 dist
  31. cd dist
  32. tar zxvf $BASENAME.tar.gz
  33. rm $BASENAME.tar.gz
  34. # Set the entire contents to be user-writable.
  35. chmod -R u+w $BASENAME
  36. cd $BASENAME
  37. for LANG in $LANGUAGES; do
  38. # Build the dist again in .tar.gz
  39. ./configure DIST_LANG=$LANG
  40. make dist-gzip
  41. mv $BASENAME.tar.gz ../protobuf-$LANG-$VERSION.tar.gz
  42. done
  43. # Convert all text files to use DOS-style line endings, then build a .zip
  44. # distribution.
  45. todos *.txt */*.txt
  46. for LANG in $LANGUAGES; do
  47. # Build the dist again in .zip
  48. ./configure DIST_LANG=$LANG
  49. make dist-zip
  50. mv $BASENAME.zip ../protobuf-$LANG-$VERSION.zip
  51. done
  52. cd ..
  53. rm -rf $BASENAME