makedistsmall.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/bin/bash
  2. #set -v
  3. # Script to produce a small source/header only package (with CMake support)
  4. # Run this script from the wolfSSL root as `./scripts/makedistsmall.sh`.
  5. # Package requires building with:
  6. # cmake .. -DWOLFSSL_EXAMPLES=no -DWOLFSSL_FILESYSTEM=no
  7. if [ "$1" == "keep" ]; then KEEP="yes"; else KEEP="no"; fi
  8. WOLFSSL_TEMPDIR=$(mktemp -d) || exit $?
  9. WOLFSSL_BRANCH=$(git symbolic-ref --short HEAD)
  10. function cleanup_on_exit() {
  11. if [ "$KEEP" == "no" ];
  12. then
  13. echo "Removing tmp directory"
  14. rm -rf "$WOLFSSL_TEMPDIR"
  15. else
  16. echo "tmp directory ${WOLFSSL_TEMPDIR} left in place."
  17. fi
  18. }
  19. trap cleanup_on_exit EXIT
  20. WOLFSSL_VERSION=$(grep -Eo '[0-9]\.[0-9]\.[0-9]+' wolfssl/version.h)
  21. if [ -n "$WOLFSSL_VERSION" ]; then
  22. echo "Detected wolfSSL Version $WOLFSSL_VERSION"
  23. else
  24. echo "Couldn't detect wolfSSL version."
  25. exit 1
  26. fi
  27. # generate a wolfSSL archive with minimum sources
  28. echo "Setting up work directory..."
  29. git clone -q -n --shared . "$WOLFSSL_TEMPDIR" || exit $?
  30. pushd "$WOLFSSL_TEMPDIR" >/dev/null || exit $?
  31. git checkout -q "$WOLFSSL_BRANCH"
  32. # cleanup example directories
  33. echo "Removing files not needed..."
  34. rm -rf -- ./.git*
  35. rm -rf ./build-aux
  36. rm -rf ./certs
  37. rm -rf ./ctaocrypt
  38. rm -rf ./cyassl
  39. rm -rf ./doc
  40. rm -rf ./Docker
  41. # these use test.h, which are not portable
  42. rm -rf ./examples
  43. rm -rf ./IDE
  44. rm -rf ./IPP
  45. rm -rf ./lib
  46. rm -rf ./linuxkm
  47. rm -rf ./m4
  48. rm -rf ./mcapi
  49. rm -rf ./mplabx
  50. rm -rf ./mqx
  51. rm -rf ./rpm
  52. rm -rf ./RTOS
  53. rm -rf ./scripts
  54. rm -rf ./sslSniffer
  55. rm -rf ./swig
  56. rm -rf ./tests
  57. rm -rf ./testsuite
  58. rm -rf ./tirtos
  59. rm -rf ./wolfcrypt/user-crypto
  60. rm -rf ./wrapper
  61. rm -f -- *.rc *.supp *.ac *.am *.conf *.sh *.cproject *.project *.pl
  62. rm -f Vagrantfile SCRIPTS-LIST quit input resource.h
  63. find . -name "*.am" -delete
  64. find . -name "*.vcxproj" -delete
  65. find . -name "*.vcproj" -delete
  66. find . -name "*.sln" -delete
  67. # TLS/Compatiblity layer
  68. #rm -rf ./src
  69. #rm -rf ./wolfssl/openssl
  70. # wolfCrypt
  71. #rm -f ./wolfcrypt/src/*.i
  72. #rm -f ./wolfcrypt/src/*.S
  73. #rm -f ./wolfcrypt/src/*.asm
  74. #rm -f ./wolfcrypt/src/arc4.c
  75. #rm -f ./wolfcrypt/src/async.c
  76. #rm -f ./wolfcrypt/src/blake*
  77. #rm -f ./wolfcrypt/src/camellia.c
  78. #rm -f ./wolfcrypt/src/chacha*
  79. #rm -f ./wolfcrypt/src/compress.c
  80. #rm -f ./wolfcrypt/src/cpuid.c
  81. #rm -f ./wolfcrypt/src/curve*
  82. #rm -f ./wolfcrypt/src/cryptocb.c
  83. #rm -f ./wolfcrypt/src/dsa.c
  84. #rm -f ./wolfcrypt/src/ed*
  85. #rm -f ./wolfcrypt/src/evp.c
  86. #rm -f ./wolfcrypt/src/fe*
  87. #rm -f ./wolfcrypt/src/ge*
  88. #rm -f ./wolfcrypt/src/md*.c
  89. #rm -f ./wolfcrypt/src/pkcs*
  90. #rm -f ./wolfcrypt/src/poly*
  91. #rm -f ./wolfcrypt/src/pwdbased.c
  92. #rm -f ./wolfcrypt/src/rc2.c
  93. #rm -f ./wolfcrypt/src/ripemd.c
  94. #rm -f ./wolfcrypt/src/rabbit.c
  95. #rm -f ./wolfcrypt/src/signature.c
  96. #rm -f ./wolfcrypt/src/srp.c
  97. #rm -f ./wolfcrypt/src/wc_dsp.c
  98. #rm -f ./wolfcrypt/src/wolfevent.c
  99. #rm -f ./wolfcrypt/src/wc_encrypt.c
  100. #rm -f ./wolfcrypt/src/wc_pkcs11.c
  101. # SP Math files
  102. #rm -f ./wolfcrypt/src/sp_arm32.c
  103. #rm -f ./wolfcrypt/src/sp_arm64.c
  104. #rm -f ./wolfcrypt/src/sp_armthumb.c
  105. #rm -f ./wolfcrypt/src/sp_cortexm.c
  106. #rm -f ./wolfcrypt/src/sp_dsp32.c
  107. #rm -f ./wolfcrypt/src/sp_x86_64.c
  108. # wolfCrypt Ports
  109. rm -rf ./wolfcrypt/src/port
  110. rm -rf ./wolfssl/wolfcrypt/port
  111. # Setup blank options.h
  112. cp ./wolfssl/options.h.in ./wolfssl/options.h || exit $?
  113. cp ./wolfcrypt/test/test_paths.h.in ./wolfcrypt/test/test_paths.h || exit $?
  114. popd >/dev/null || exit $?
  115. echo "Generating wolfssl-${WOLFSSL_VERSION}-small.tar.gz..."
  116. tar zcf "wolfssl-${WOLFSSL_VERSION}-small.tar.gz" -C "$WOLFSSL_TEMPDIR" . || exit $?
  117. echo "Done"