/os/tools/zipdownload.sh

https://github.com/Samsung/TizenRT · Shell · 172 lines · 111 code · 32 blank · 29 comment · 19 complexity · f0c79c5246c6e3a90d8e9a7b10c30d84 MD5 · raw file

  1. #!/bin/bash
  2. ###########################################################################
  3. #
  4. # Copyright 2018 Samsung Electronics All Rights Reserved.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing,
  13. # software distributed under the License is distributed on an
  14. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
  15. # either express or implied. See the License for the specific
  16. # language governing permissions and limitations under the License.
  17. #
  18. ###########################################################################
  19. # Usages
  20. USAGE="
  21. USAGE: ${0} [-d] [FILE-NAME]
  22. Zip binary, debug files like elf and map and flash tool files
  23. -d include debug files, elf and map into zip file
  24. FILE-NAME zip file name
  25. when not configured, "TizenRT_\<board-name\>_\<commit_hash\>.tar" used
  26. "
  27. # Parsing arguments
  28. unset DEBUG
  29. unset FILENAME
  30. while [ ! -z "$1" ]; do
  31. case "$1" in
  32. --help )
  33. echo "$USAGE"
  34. exit 0
  35. ;;
  36. -d )
  37. DEBUG=y
  38. ;;
  39. *)
  40. if [ ! -z "${FILENAME}" ]; then
  41. echo ""
  42. echo "File name defined twice"
  43. echo "$USAGE"
  44. exit 1
  45. fi
  46. FILENAME=$1
  47. ;;
  48. esac
  49. shift
  50. done
  51. # Zip command & option
  52. TAR=tar
  53. TAROPT=-cf
  54. # Get folder path
  55. OSTOOLDIR=`test -d ${0%/*} && cd ${0%/*}; pwd`
  56. TOPDIR="${OSTOOLDIR}/../.."
  57. OSDIR="${TOPDIR}/os"
  58. BUILDDIR="${TOPDIR}/build"
  59. BINDIR="${BUILDDIR}/output/bin"
  60. # Get fixed file
  61. CONFIG=${OSDIR}/.config
  62. if [ ! -f ${CONFIG} ]; then
  63. echo "No .config file"
  64. exit 1
  65. fi
  66. MAKEFILES="${OSDIR}/Makefile ${OSDIR}/Makefile.unix ${OSDIR}/Makefile.win ${OSDIR}/Directories.mk ${OSDIR}/FlatLibs.mk ${OSDIR}/LibTargets.mk ${OSDIR}/Make.defs ${OSDIR}/tools/Config.mk"
  67. DOWNLOADSCRIPTS="${OSDIR}/tools/download.sh ${OSDIR}/tools/download.bat"
  68. unset ROMFSIMG
  69. if [ -f "${BINDIR}/romfs.img" ]; then
  70. ROMFSIMG="${BINDIR}/romfs.img"
  71. fi
  72. unset ELF
  73. unset MAP
  74. if [ "${DEBUG}" == "y" ]; then
  75. ELF=${BINDIR}/tinyara
  76. MAP=${BINDIR}/tinyara.map
  77. fi
  78. # Get configuration
  79. source ${CONFIG}
  80. BOARD=${CONFIG_ARCH_BOARD}
  81. # Get file according to .config
  82. BOARDSCRIPT="${BUILDDIR}/configs/${BOARD}"
  83. TOOLCHAINDEFS="${OSDIR}/arch/${CONFIG_ARCH}/src/${CONFIG_ARCH_FAMILY}/Toolchain.defs"
  84. # Get GIT information (if not provided on the command line)
  85. if [ -z "${FILENAME}" ]; then
  86. GITINFO=`git log 2>/dev/null | head -1`
  87. if [ -z "${GITINFO}" ]; then
  88. echo "GIT version information is not available"
  89. BUILD=NA
  90. else
  91. BUILD=`echo ${GITINFO} | cut -d' ' -f2`
  92. BUILD=`echo ${BUILD:0:7}`
  93. if [ -z "${BUILD}" ]; then
  94. echo "GIT build information not found"
  95. BUILD=NA
  96. fi
  97. fi
  98. FILENAME=tizenrt_${BOARD}_${BUILD}.tar
  99. fi
  100. # Board specific
  101. unset FLASHTOOLDIR
  102. BOARDBAT=${OSDIR}/tools/board.bat
  103. if [ "${BOARD}" == "artik05x" ]; then
  104. FLASHTOOLDIR="${BUILDDIR}/tools/openocd"
  105. if [ "${CONFIG_ARCH_BOARD_ARTIK053S}" == "y" ]; then
  106. BOARDSCRIPT+=" ${BUILDDIR}/configs/artik053s"
  107. BOARDBIN="${BINDIR}/tinyara_head.bin-signed"
  108. echo "set BOARD=artik053s" > ${BOARDBAT}
  109. elif [ "${CONFIG_ARCH_BOARD_ARTIK055S}" == "y" ]; then
  110. BOARDSCRIPT+=" ${BUILDDIR}/configs/artik055s"
  111. BOARDBIN="${BINDIR}/tinyara_head.bin-signed"
  112. echo "set BOARD=artik055s" > ${BOARDBAT}
  113. else
  114. BOARDSCRIPT+=" ${BUILDDIR}/configs/artik053"
  115. BOARDBIN="${BINDIR}/tinyara_head.bin"
  116. echo "set BOARD=artik053" > ${BOARDBAT}
  117. fi
  118. # make partition_map.cfg
  119. ${BUILDDIR}/configs/${BOARD}/scripts/partition_gen.sh
  120. elif [ "${BOARD}" == "cy4390x" ]; then
  121. BOARDBIN="${BINDIR}/tinyara_master_strip"
  122. echo "set BOARD=cy4390x" > ${BOARDBAT}
  123. fi
  124. if [ ! -f "${BOARDBIN}" ]; then
  125. echo "Fail!! ${BOARDBIN} is not existed"
  126. exit 1
  127. fi
  128. unset OTABIN
  129. if [ -f "${BINDIR}/ota.bin" ]; then
  130. OTABIN="${BINDIR}/ota.bin"
  131. fi
  132. # Execute
  133. BINARIES="${BOARDBIN} ${ROMFSIMG} ${OTABIN}"
  134. DEBUGFILES="${ELF} ${MAP}"
  135. TINYARAFILES="${CONFIG} ${MAKEFILES} ${DOWNLOADSCRIPTS} ${TOOLCHAINDEFS}"
  136. BOARDSPECIFIC="${BOARDSCRIPT}"
  137. ${TAR} ${TAROPT} ${FILENAME} ${TINYARAFILES} ${BINARIES} ${DEBUGFILES} ${FLASHTOOLDIR} ${BOARDSPECIFIC} ${BOARDBAT} || exit 1
  138. rm ${BOARDBAT}
  139. echo "${FILENAME} zipped!"
  140. exit 0