Add script for making linux binary package
[apps/agl-service-can-low-level.git] / tools / make_linux_package.sh
1 #!/bin/bash
2
3 # Run this script in the top nanopb directory to create a binary package
4 # for Linux users.
5
6 set -e
7 set -x
8
9 VERSION=`git describe --always`
10 DEST=dist/$VERSION
11
12 rm -rf $DEST
13 mkdir -p $DEST
14
15 # Export the files from newest commit
16 git archive HEAD | tar x -C $DEST
17
18 # Rebuild the Python .proto files
19 make -BC $DEST/generator/proto
20
21 # Package the Python libraries
22 ( cd $DEST/generator; bbfreeze nanopb_generator.py )
23 mv $DEST/generator/dist $DEST/generator-bin
24
25 # Package the protoc compiler
26 cp `which protoc` $DEST/generator-bin/protoc.bin
27 cat > $DEST/generator-bin/protoc << EOF
28 #!/bin/bash
29 SCRIPTDIR=\$(dirname \$(readlink -f \$0))
30 export LD_LIBRARY_PATH=\$SCRIPTDIR
31 export PATH=\$SCRIPTDIR:\$PATH
32 exec \$SCRIPTDIR/protoc.bin "\$@"
33 EOF
34 chmod +x $DEST/generator-bin/protoc
35
36 # Make the nanopb generator available as a protoc plugin
37 ln -s nanopb-generator $DEST/generator-bin/protoc-gen-nanopb
38