make_fw.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. sed -e "s/%REVISION%/$_OPENWRT/g" -e "s/%VERSION%/$_VERSION/g" $_COMMON/etc/banner > $_TARGET.tmp/etc/banner
  33. echo $_VERSION > $_TARGET.tmp/etc/superglue_version
  34. cd $_IMAGEBUILDER && make clean
  35. 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 &&
  36. ln -s $_BUILDS/$_VERSION/$_TARGET/openwrt/openwrt-*-factory.bin $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-$_VERSION-$(echo $_TARGET | tr [:upper:] [:lower:])-factory.bin
  37. ln -s $_BUILDS/$_VERSION/$_TARGET/openwrt/openwrt-*-sysupgrade.bin $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-$_VERSION-$(echo $_TARGET | tr [:upper:] [:lower:])-sysupgrade.bin
  38. cd $_BUILDS/$_VERSION/$_TARGET
  39. md5sum *.bin > md5sums
  40. cd -
  41. if [[ $? -eq 0 ]]; then
  42. echo -e "\n$_TARGET build completed\n"
  43. else
  44. _ERR=$?
  45. rm -Rf $_BUILDS/$_VERSION/$_TARGET
  46. fi
  47. echo 'Cleaning up..'
  48. make clean
  49. cd $_PWD
  50. rm -Rf $_TARGET.tmp
  51. done
  52. if [[ $_ERR -eq 0 ]]; then
  53. ## if build succeeded bump revision
  54. echo $_MINOR > sg_$_MAJOR.revision
  55. echo -e "\nSUCCESS\n"
  56. ## create symlinks to latest
  57. [[ -e $_BUILDS/latest ]] && touch $_BUILDS/latest || mkdir $_BUILDS/latest
  58. for _TARGET in $_TARGETS; do
  59. [[ -e $_BUILDS/latest/$_TARGET ]] && rm -f $_BUILDS/latest/$_TARGET/* || mkdir $_BUILDS/latest/$_TARGET
  60. ln -sf $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-*-factory.bin $_BUILDS/latest/$_TARGET/superglue-firmware-latest-$(echo $_TARGET | tr [:upper:] [:lower:])-factory.bin
  61. ln -sf $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-*-sysupgrade.bin $_BUILDS/latest/$_TARGET/superglue-firmware-latest-$(echo $_TARGET | tr [:upper:] [:lower:])-sysupgrade.bin
  62. done
  63. else
  64. echo -e "\nFAILED\n"
  65. fi
  66. exit $_ERR