multibuild.sh 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. # Copyright 2013-2017 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+)$/$1/ or $_=""' <<<"$cfn")"
  47. test -n "$plat" ||
  48. continue
  49. if [[ $plat =~ _pkgs$ ]]; then
  50. plat="${plat::-5}"
  51. else
  52. plat="$(perl -ple 's/_.*//' <<<"$plat")"
  53. fi
  54. platlist+=("$plat")
  55. cp -v "$vcfgdir/$cfn" .config
  56. yes '' | make oldconfig
  57. make {tools,toolchain}/install package/bfgminer/{clean,compile} V=s
  58. mkdir "$reporoot/$plat" -pv
  59. files=$(ls bin/"$plat"/packages/{*/,}bfgminer*_${plat}*.ipk bin/packages/"$plat"/{*/,}bfgminer*_${plat}*.ipk || true)
  60. if test -z "${files}"; then
  61. echo "Cannot find built packages"
  62. exit 1
  63. fi
  64. cp -v ${files} "$reporoot/$plat/"
  65. if [ -n "${BITSTREAM_PKG_PATH}" ]; then
  66. (
  67. test -d "$reporoot/${BITSTREAM_PKG_PATH}"
  68. cd "$reporoot/$plat"
  69. for bs in ${BITSTREAMS[@]}; do
  70. ln -vfs "../${BITSTREAM_PKG_PATH}/bitstream-${bs}_all.ipk" .
  71. done
  72. )
  73. fi
  74. (
  75. cd "$reporoot/$plat/"
  76. PATH="${openwrt_root}/staging_dir/host/bin/:${PATH}" \
  77. "${openwrt_root}/scripts/ipkg-make-index.sh" .
  78. ) > "$reporoot/$plat/Packages"
  79. gzip -9 < "$reporoot/$plat/Packages" > "$reporoot/$plat/Packages.gz"
  80. done