make_dist.sh 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env bash
  2. # BlueSCSI - Copyright (c) 2025 Eric Helgeson
  3. #
  4. # BlueSCSI file is licensed under the GPL version 3 or any later version.
  5. #
  6. # https://www.gnu.org/licenses/gpl-3.0.html
  7. # ----
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
  21. cd "$SCRIPT_DIR/.." || exit 1
  22. OUT_DIR=./dist
  23. mkdir -p $OUT_DIR || exit 1
  24. DATE=$(date +%Y-%m-%d)
  25. VERSION=$(git rev-parse --short HEAD)
  26. for file in .pio/build/*/firmware.bin .pio/build/*/firmware.elf .pio/build/*/firmware.uf2
  27. do
  28. BUILD_ENV=$(echo "$file" | cut -d'/' -f3)
  29. if [[ "$BUILD_ENV" == *"Pico_2"* ]]; then
  30. BOARD="Pico2"
  31. elif [[ "$BUILD_ENV" == *"Pico"* ]]; then
  32. BOARD="Pico1"
  33. else
  34. echo "Warning: Could not determine board for $file"
  35. continue
  36. fi
  37. VARIANT=""
  38. if [[ "$BUILD_ENV" == *"DaynaPORT"* ]]; then
  39. VARIANT="_DaynaPORT"
  40. fi
  41. EXT="${file##*.}"
  42. RENAME="BlueSCSI_${BOARD}${VARIANT}_${DATE}_${VERSION}.${EXT}"
  43. echo "$file to $OUT_DIR/$RENAME"
  44. cp "$file" "$OUT_DIR/$RENAME"
  45. done
  46. set -e
  47. set -x
  48. ls -1 "$OUT_DIR"
  49. # Zip up elf/uf2 files for each board variant
  50. zip -j "$OUT_DIR/dev-BlueSCSI_${DATE}_${VERSION}.zip" "$OUT_DIR"/*.elf "$OUT_DIR"/*.uf2
  51. rm "$OUT_DIR/"*.elf
  52. # Create universal UF2 by combining the Pico1 and Pico2 UF2 files;
  53. cat "$OUT_DIR/BlueSCSI_Pico1_DaynaPORT_${DATE}_${VERSION}.uf2" \
  54. "$OUT_DIR/BlueSCSI_Pico2_DaynaPORT_${DATE}_${VERSION}.uf2" > "$OUT_DIR/BlueSCSI_Universal_${DATE}_${VERSION}.uf2"
  55. # Remove unused UF2 files
  56. #rm "$OUT_DIR/BlueSCSI_Pico1_${DATE}_${VERSION}.uf2"
  57. #rm "$OUT_DIR/BlueSCSI_Pico2_${DATE}_${VERSION}.uf2"
  58. rm "$OUT_DIR/BlueSCSI_Pico1_DaynaPORT_${DATE}_${VERSION}.uf2"
  59. rm "$OUT_DIR/BlueSCSI_Pico2_DaynaPORT_${DATE}_${VERSION}.uf2"
  60. # Rename bins for SD Card update.
  61. mv "$OUT_DIR/BlueSCSI_Pico1_DaynaPORT_${DATE}_${VERSION}.bin" "$OUT_DIR/BlueSCSI_Pico1_${DATE}_${VERSION}.bin"
  62. mv "$OUT_DIR/BlueSCSI_Pico2_DaynaPORT_${DATE}_${VERSION}.bin" "$OUT_DIR/BlueSCSI_Pico2_${DATE}_${VERSION}.bin"
  63. # Make a zip file with all the pico1 and pico2 files together by variant such as DaynaPORT
  64. #zip -j "dist/BlueSCSI-Universal-DaynaPORT-${DATE}-${VERSION}.zip" dist/BlueSCSI-Pico*-DaynaPORT-${DATE}-${VERSION}.*
  65. #find dist/ -maxdepth 1 -type f -name "BlueSCSI-Pico*-${DATE}-${VERSION}.*" ! -name "*-DaynaPORT-*" -print0 | xargs -0 zip -j "dist/BlueSCSI-Universal-${DATE}-${VERSION}.zip"