make_fw.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. ## read build serial, incremented on every successful build
  13. if [[ -e sg_$_MAJOR.revision ]]; then
  14. read _MINOR < sg_$_MAJOR.revision
  15. let _MINOR++
  16. else _MINOR=0
  17. fi
  18. ## get OpenWRT verison
  19. _OPENWRT=$(fgrep -m1 'REVISION:=' $_IMAGEBUILDER/include/version.mk || echo 'r00000')
  20. _OPENWRT=${_OPENWRT/REVISION:=/}
  21. echo $_OPENWRT > openwrt.revision
  22. _VERSION="$_MAJOR"."$_MINOR"-"$_SUFFIX"
  23. echo "About to start building version: $_VERSION"
  24. echo -e "Targets for this build: $_TARGETS\n"
  25. echo 'Removing temporary dirs (if any)'
  26. find -maxdepth 1 -name *.tmp -exec rm -Rf {} \;
  27. for _TARGET in $_TARGETS; do
  28. [[ -e $_TARGET.tmp ]] && rm -Rf $_TARGET.tmp
  29. cp -Ra $_COMMON $_TARGET.tmp
  30. cp -Ra $_TARGET/* $_TARGET.tmp/
  31. echo $_VERSION > $_TARGET.tmp/etc/superglue_version
  32. cd $_IMAGEBUILDER && make clean
  33. make image PROFILE=$_TARGET PACKAGES="bash gawk sudo procps-ps 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 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 &&
  34. cp $_BUILDS/$_VERSION/$_TARGET/openwrt/openwrt-*-factory.bin $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-$(echo $_TARGET | tr [:upper:] [:lower:])-$_VERSION-factory.bin
  35. cp $_BUILDS/$_VERSION/$_TARGET/openwrt/openwrt-*-sysupgrade.bin $_BUILDS/$_VERSION/$_TARGET/superglue-firmware-$(echo $_TARGET | tr [:upper:] [:lower:])-$_VERSION-sysupgrade.bin
  36. cd $_BUILDS/$_VERSION/$_TARGET
  37. md5sum *.bin > md5sums
  38. cd -
  39. [[ $? -eq 0 ]] && echo -e "\n$_TARGET build completed\n" || _ERR=$?
  40. echo 'Cleaning up..'
  41. make clean
  42. cd $_PWD
  43. rm -Rf $_TARGET.tmp
  44. done
  45. if [[ $_ERR -eq 0 ]]; then
  46. ## if build succeeded bump revision
  47. echo $_MINOR > sg_$_MAJOR.revision
  48. echo -e "\nSUCCESS\n"
  49. else
  50. echo -e "\nFAILED\n"
  51. fi
  52. exit $_ERR