multibuild.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. # Copyright 2013-2016 Luke Dashjr
  3. #
  4. # This program is free software; you can redistribute it and/or modify it
  5. # under the terms of the GNU General Public License as published by the Free
  6. # Software Foundation; either version 3 of the License, or (at your option)
  7. # any later version. See COPYING for more details.
  8. set -e
  9. set -x
  10. reporoot="$1" # .../files/bfgminer/BFGMINER_VERSION/openwrt/OPENWRT_VERSION
  11. openwrt_root="${2:-openwrt-src}"
  12. BITSTREAM_PKG_PATH="${3}" # Relative to reporoot
  13. test -n "$reporoot"
  14. reporoot="$(realpath "$reporoot")"
  15. test -n "$reporoot"
  16. cd "${openwrt_root}/"
  17. openwrt_root="$PWD"
  18. test -d "$reporoot"
  19. vcfgdir='vanilla_configs'
  20. vcfglist="$(
  21. ls -d "$vcfgdir"/*.config* |
  22. perl -ple 's[.*/][]' |
  23. sort -n
  24. )"
  25. BITSTREAMS=(
  26. fpgaminer_402-1
  27. ztex-ufm1_15b1_121126-1
  28. ztex-ufm1_15d4_121126-1
  29. ztex-ufm1_15y1_121126-1
  30. )
  31. if [ -d "${reporoot}/${BITSTREAM_PKG_PATH}" ]; then
  32. (
  33. for bs in ${BITSTREAMS[@]}; do
  34. if ! [ -r "${reporoot}/${BITSTREAM_PKG_PATH}/bitstream-${bs}_all.ipk" ]; then
  35. echo "Cannot find ${bs} bitstream package" >&2
  36. exit 1
  37. fi
  38. done
  39. )
  40. else
  41. echo 'Cannot find bitstreams directory' >&2
  42. exit 1
  43. fi
  44. plat1=''
  45. for cfn in $vcfglist; do
  46. plat="$(perl -ple 's/^(\d+)\.config\.(\w+?)_\w+$/$2/ or $_=""' <<<"$cfn")"
  47. test -n "$plat" ||
  48. continue
  49. platlist+=("$plat")
  50. cp -v "$vcfgdir/$cfn" .config
  51. yes '' | make oldconfig
  52. make {tools,toolchain}/install package/bfgminer/{clean,compile}
  53. mkdir "$reporoot/$plat" -pv
  54. files=$(ls "bin/$plat/packages/"{*/,}bfgminer*_${plat}*.ipk || true)
  55. if test -z "${files}"; then
  56. echo "Cannot find built packages"
  57. exit 1
  58. fi
  59. cp -v ${files} "$reporoot/$plat/"
  60. if [ -n "${BITSTREAM_PKG_PATH}" ]; then
  61. (
  62. test -d "$reporoot/${BITSTREAM_PKG_PATH}"
  63. cd "$reporoot/$plat"
  64. for bs in ${BITSTREAMS[@]}; do
  65. ln -vfs "../${BITSTREAM_PKG_PATH}/bitstream-${bs}_all.ipk" .
  66. done
  67. )
  68. fi
  69. (
  70. cd "$reporoot/$plat/"
  71. "${openwrt_root}/scripts/ipkg-make-index.sh" .
  72. ) > "$reporoot/$plat/Packages"
  73. gzip -9 < "$reporoot/$plat/Packages" > "$reporoot/$plat/Packages.gz"
  74. done