make_linux_package.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # Run this script in the top nanopb directory to create a binary package
  3. # for Linux users.
  4. # Requires: protobuf, python-protobuf, pyinstaller
  5. set -e
  6. set -x
  7. VERSION=`git describe --always`-linux-x86
  8. DEST=dist/$VERSION
  9. rm -rf $DEST
  10. mkdir -p $DEST
  11. # Export the files from newest commit
  12. git archive HEAD | tar x -C $DEST
  13. # Rebuild the Python .proto files and .pyc
  14. ( cd $DEST/generator; python3 nanopb_generator.py ||: )
  15. # Package the Python libraries
  16. ( cd $DEST/generator; python3 -m PyInstaller nanopb_generator.py )
  17. ( cd $DEST/generator; python3 -m PyInstaller protoc )
  18. mv $DEST/generator/dist/nanopb_generator $DEST/generator-bin
  19. cp $DEST/generator/dist/protoc/protoc $DEST/generator-bin
  20. # Include Google's descriptor.proto and nanopb.proto
  21. cp -pr $(python3 -c 'import grpc_tools, os.path; print(os.path.dirname(grpc_tools.__file__))')/_proto $DEST/generator-bin/grpc_tools/
  22. cp -pr $DEST/generator/proto $DEST/generator-bin/proto
  23. # Remove temp files
  24. rm -rf $DEST/generator/dist $DEST/generator/build $DEST/generator/nanopb_generator.spec
  25. # Make the nanopb generator available as a protoc plugin
  26. cp $DEST/generator-bin/nanopb_generator $DEST/generator-bin/protoc-gen-nanopb
  27. # Remove debugging symbols to reduce size of package
  28. ( cd $DEST/generator-bin; strip *.so* )
  29. # Tar it all up
  30. ( cd dist; tar -czf $VERSION.tar.gz $VERSION )