2
0

make.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2018-2023 Ruilin Peng (Nick) <[email protected]>.
  4. #
  5. # smartdns is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # smartdns is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. CURR_DIR=$(cd $(dirname $0);pwd)
  18. VER="`date +"1.%Y.%m.%d-%H%M"`"
  19. SMARTDNS_DIR=$CURR_DIR/../../
  20. PO2LMO=
  21. showhelp()
  22. {
  23. echo "Usage: make [OPTION]"
  24. echo "Options:"
  25. echo " -o output directory."
  26. echo " --arch archtecture."
  27. echo " --ver version."
  28. echo " -h show this message."
  29. }
  30. build_tool()
  31. {
  32. make -C $ROOT/tool/po2lmo -j
  33. PO2LMO="$ROOT/tool/po2lmo/src/po2lmo"
  34. }
  35. clean_tool()
  36. {
  37. make -C $ROOT/tool/po2lmo clean
  38. }
  39. build()
  40. {
  41. ROOT=/tmp/luci-app-smartdns
  42. rm -fr $ROOT
  43. mkdir -p $ROOT
  44. cp $CURR_DIR/* $ROOT/ -af
  45. cd $ROOT/
  46. build_tool
  47. mkdir $ROOT/root/usr/lib/lua/luci -p
  48. mkdir $ROOT/root/usr/share/rpcd/acl.d/ -p
  49. cp $ROOT/files/luci/i18n $ROOT/root/usr/lib/lua/luci/ -avf
  50. #Generate Language
  51. $PO2LMO $ROOT/files/luci/i18n/smartdns.zh-cn.po $ROOT/root/usr/lib/lua/luci/i18n/smartdns.zh-cn.lmo
  52. rm $ROOT/root/usr/lib/lua/luci/i18n/smartdns.zh-cn.po
  53. cp $ROOT/files/root/* $ROOT/root/ -avf
  54. INST_SIZE="`du -sb $ROOT/root/ | awk '{print $1}'`"
  55. sed -i "s/^Architecture.*/Architecture: all/g" $ROOT/control/control
  56. sed -i "s/Version:.*/Version: $VER/" $ROOT/control/control
  57. if [ ! -z "$INST_SIZE" ]; then
  58. echo "Installed-Size: $INST_SIZE" >> $ROOT/control/control
  59. fi
  60. cd $ROOT/control
  61. chmod +x *
  62. tar zcf ../control.tar.gz ./
  63. cd $ROOT
  64. tar zcf $ROOT/data.tar.gz -C root .
  65. tar zcf $OUTPUTDIR/luci-app-smartdns.$VER.$FILEARCH.ipk ./control.tar.gz ./data.tar.gz ./debian-binary
  66. rm -fr $ROOT/
  67. }
  68. main()
  69. {
  70. OPTS=`getopt -o o:h --long arch:,ver:,filearch: \
  71. -n "" -- "$@"`
  72. if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
  73. # Note the quotes around `$TEMP': they are essential!
  74. eval set -- "$OPTS"
  75. while true; do
  76. case "$1" in
  77. --arch)
  78. ARCH="$2"
  79. shift 2;;
  80. --filearch)
  81. FILEARCH="$2"
  82. shift 2;;
  83. --ver)
  84. VER="$2"
  85. shift 2;;
  86. -o )
  87. OUTPUTDIR="$2"
  88. shift 2;;
  89. -h | --help )
  90. showhelp
  91. return 0
  92. shift ;;
  93. -- ) shift; break ;;
  94. * ) break ;;
  95. esac
  96. done
  97. if [ -z "$ARCH" ]; then
  98. echo "please input arch."
  99. return 1;
  100. fi
  101. if [ -z "$FILEARCH" ]; then
  102. FILEARCH=$ARCH
  103. fi
  104. if [ -z "$OUTPUTDIR" ]; then
  105. OUTPUTDIR=$CURR_DIR;
  106. fi
  107. build
  108. }
  109. main $@
  110. exit $?