make_fw.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/bash
  2. _PWD=$(pwd)
  3. _IMAGEBUILDER="$_PWD/../../../openwrt/OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64"
  4. _BUILDS="$_PWD/../../../sg-builds"
  5. ## dirs with platform specific files
  6. _TARGETS='DIR505A1 TLWR710'
  7. #_TARGETS='DIR505A1'
  8. ## dir with common files
  9. _COMMON='common'
  10. _MAJOR='0.1' ## bump that on major changes
  11. #_SUFFIX='git' ## could be 'beta', 'rc', etc
  12. _SUFFIX='testing' ## could be 'beta', 'rc', etc
  13. ## read build serial, incremented on every successful build
  14. if [[ -e sg_$_MAJOR.revision ]]; then
  15. read _MINOR < sg_$_MAJOR.revision
  16. let _MINOR++
  17. else _MINOR=0
  18. fi
  19. ## get OpenWRT verison
  20. _OPENWRT=$(fgrep -m1 'REVISION:=' $_IMAGEBUILDER/include/version.mk || echo 'r00000')
  21. _OPENWRT=${_OPENWRT/REVISION:=/}
  22. echo $_OPENWRT > openwrt.revision
  23. _VERSION="$_MAJOR"."$_MINOR"-"$_SUFFIX"
  24. echo "About to start building version: $_VERSION"
  25. echo -e "Targets for this build: $_TARGETS\n"
  26. echo 'Removing temporary dirs (if any)'
  27. find -maxdepth 1 -name *.tmp -exec rm -Rf {} \;
  28. for _TARGET in $_TARGETS; do
  29. [[ -e $_TARGET.tmp ]] && rm -Rf $_TARGET.tmp
  30. cp -Ra $_COMMON $_TARGET.tmp
  31. cp -Ra $_TARGET/* $_TARGET.tmp/
  32. echo $_VERSION > $_TARGET.tmp/etc/superglue_version
  33. cd $_IMAGEBUILDER && make clean
  34. make image PROFILE=$_TARGET PACKAGES="bash gawk sudo procps-ps haserl lighttpd lighttpd-mod-access lighttpd-mod-cgi lighttpd-mod-compress lighttpd-mod-accesslog lighttpd-mod-rewrite lighttpd-mod-auth lighttpd-mod-alias lighttpd-mod-setenv blkid kmod-fs-ext4 kmod-fs-vfat kmod-fs-btrfs btrfs-progs block-mount mini-sendmail kmod-usb-storage kmod-scsi-generic mount-utils kmod-nls-cp437 kmod-nls-iso8859-1 kmod-nls-utf8 kmod-nls-base coreutils-stat mini-httpd-htpasswd" FILES=$_PWD/$_TARGET.tmp BIN_DIR=$_BUILDS/$_VERSION/$_TARGET/openwrt &&
  35. ln -s $_BUILDS/$_VERSION/$_TARGET/openwrt/openwrt-*-factory.bin $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-$_VERSION-$(echo $_TARGET | tr [:upper:] [:lower:])-factory.bin
  36. ln -s $_BUILDS/$_VERSION/$_TARGET/openwrt/openwrt-*-sysupgrade.bin $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-$_VERSION-$(echo $_TARGET | tr [:upper:] [:lower:])-sysupgrade.bin
  37. cd $_BUILDS/$_VERSION/$_TARGET
  38. md5sum *.bin > md5sums
  39. cd -
  40. if [[ $? -eq 0 ]]; then
  41. echo -e "\n$_TARGET build completed\n"
  42. else
  43. _ERR=$?
  44. rm -Rf $_BUILDS/$_VERSION/$_TARGET
  45. fi
  46. echo 'Cleaning up..'
  47. make clean
  48. cd $_PWD
  49. rm -Rf $_TARGET.tmp
  50. done
  51. if [[ $_ERR -eq 0 ]]; then
  52. ## if build succeeded bump revision
  53. echo $_MINOR > sg_$_MAJOR.revision
  54. echo -e "\nSUCCESS\n"
  55. ## create symlinks to latest
  56. [[ -e $_BUILDS/latest ]] && touch $_BUILDS/latest || mkdir $_BUILDS/latest
  57. for _TARGET in $_TARGETS; do
  58. [[ -e $_BUILDS/latest/$_TARGET ]] && rm -f $_BUILDS/latest/$_TARGET/* || mkdir $_BUILDS/latest/$_TARGET
  59. ln -sf $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-*-factory.bin $_BUILDS/latest/$_TARGET/superglue-firmware-latest-$(echo $_TARGET | tr [:upper:] [:lower:])-factory.bin
  60. ln -sf $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-*-sysupgrade.bin $_BUILDS/latest/$_TARGET/superglue-firmware-latest-$(echo $_TARGET | tr [:upper:] [:lower:])-sysupgrade.bin
  61. done
  62. else
  63. echo -e "\nFAILED\n"
  64. fi
  65. exit $_ERR