ozone-dist-layout-stitching 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #!/usr/bin/env bash
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # project.version
  17. VERSION=$1
  18. # project.build.directory
  19. BASEDIR=$2
  20. #hdds.version
  21. HDDS_VERSION=$3
  22. function run()
  23. {
  24. declare res
  25. echo "\$ ${*}"
  26. "${@}"
  27. res=$?
  28. if [[ ${res} != 0 ]]; then
  29. echo
  30. echo "Failed!"
  31. echo
  32. exit "${res}"
  33. fi
  34. }
  35. function findfileindir()
  36. {
  37. declare file="$1"
  38. declare dir="${2:-./share}"
  39. declare count
  40. count=$(find "${dir}" -iname "${file}" | wc -l)
  41. #shellcheck disable=SC2086
  42. echo ${count}
  43. }
  44. function copyifnotexists()
  45. {
  46. declare src="$1"
  47. declare dest="$2"
  48. declare srcname
  49. declare destdir
  50. declare child
  51. declare childpath
  52. if [[ -f "${src}" ]]; then
  53. srcname=${src##*/}
  54. if [[ "${srcname}" != *.jar ||
  55. $(findfileindir "${srcname}") -eq "0" ]]; then
  56. destdir=$(dirname "${dest}")
  57. mkdir -p "${destdir}"
  58. cp -p "${src}" "${dest}"
  59. fi
  60. else
  61. for childpath in "${src}"/*; do
  62. child="${childpath##*/}"
  63. if [[ "${child}" == "doc" ||
  64. "${child}" == "webapps" ]]; then
  65. mkdir -p "${dest}/${child}"
  66. cp -r "${src}/${child}"/* "${dest}/${child}"
  67. continue;
  68. fi
  69. copyifnotexists "${src}/${child}" "${dest}/${child}"
  70. done
  71. fi
  72. }
  73. #Copy all contents as is except the lib.
  74. #for libs check for existence in share directory, if not exist then only copy.
  75. function copy()
  76. {
  77. declare src="$1"
  78. declare dest="$2"
  79. declare child
  80. declare childpath
  81. if [[ -d "${src}" ]]; then
  82. for childpath in "${src}"/*; do
  83. child="${childpath##*/}"
  84. if [[ "${child}" == "share" ]]; then
  85. copyifnotexists "${src}/${child}" "${dest}/${child}"
  86. else
  87. if [[ -d "${src}/${child}" ]]; then
  88. mkdir -p "${dest}/${child}"
  89. cp -pr "${src}/${child}"/* "${dest}/${child}"
  90. else
  91. cp -pr "${src}/${child}" "${dest}/${child}"
  92. fi
  93. fi
  94. done
  95. fi
  96. }
  97. # shellcheck disable=SC2164
  98. ROOT=$(cd "${BASEDIR}"/../..;pwd)
  99. echo
  100. echo "Current directory $(pwd)"
  101. echo
  102. run rm -rf "ozone-${HDDS_VERSION}"
  103. run mkdir "ozone-${HDDS_VERSION}"
  104. run cd "ozone-${HDDS_VERSION}"
  105. run cp -p "${ROOT}/LICENSE.txt" .
  106. run cp -p "${ROOT}/NOTICE.txt" .
  107. run cp -p "${ROOT}/README.txt" .
  108. # Copy hadoop-common first so that it have always have all dependencies.
  109. # Remaining projects will copy only libraries which are not present already in 'share' directory.
  110. run copy "${ROOT}/hadoop-common-project/hadoop-common/target/hadoop-common-${VERSION}" .
  111. # HDDS
  112. run copy "${ROOT}/hadoop-hdds/common/target/hadoop-hdds-common-${HDDS_VERSION}" .
  113. run copy "${ROOT}/hadoop-hdds/framework/target/hadoop-hdds-server-framework-${HDDS_VERSION}" .
  114. run copy "${ROOT}/hadoop-hdds/server-scm/target/hadoop-hdds-server-scm-${HDDS_VERSION}" .
  115. run copy "${ROOT}/hadoop-hdds/container-service/target/hadoop-hdds-container-service-${HDDS_VERSION}" .
  116. run copy "${ROOT}/hadoop-hdds/client/target/hadoop-hdds-client-${HDDS_VERSION}" .
  117. run copy "${ROOT}/hadoop-hdds/tools/target/hadoop-hdds-tools-${HDDS_VERSION}" .
  118. # Ozone
  119. run copy "${ROOT}/hadoop-ozone/common/target/hadoop-ozone-common-${HDDS_VERSION}" .
  120. run copy "${ROOT}/hadoop-ozone/ozone-manager/target/hadoop-ozone-ozone-manager-${HDDS_VERSION}" .
  121. run copy "${ROOT}/hadoop-ozone/objectstore-service/target/hadoop-ozone-objectstore-service-${HDDS_VERSION}" .
  122. run copy "${ROOT}/hadoop-ozone/client/target/hadoop-ozone-client-${HDDS_VERSION}" .
  123. run copy "${ROOT}/hadoop-ozone/tools/target/hadoop-ozone-tools-${HDDS_VERSION}" .
  124. mkdir -p "./share/hadoop/ozonefs"
  125. cp "${ROOT}/hadoop-ozone/ozonefs/target/hadoop-ozone-filesystem-${HDDS_VERSION}.jar" "./share/hadoop/ozonefs/hadoop-ozone-filesystem.jar"
  126. # Optional documentation, could be missing
  127. cp -r "${ROOT}/hadoop-ozone/docs/target/classes/webapps/docs" ./share/hadoop/ozone/webapps/ozoneManager/
  128. cp -r "${ROOT}/hadoop-ozone/docs/target/classes/webapps/docs" ./share/hadoop/hdds/webapps/scm/
  129. rm sbin/*all.sh
  130. rm sbin/*all.cmd
  131. #Copy docker compose files
  132. run cp -p -r "${ROOT}/hadoop-dist/src/main/compose" .
  133. mkdir -p ./share/hadoop/mapreduce
  134. mkdir -p ./share/hadoop/yarn
  135. mkdir -p ./share/hadoop/hdfs
  136. echo
  137. echo "Hadoop Ozone dist layout available at: ${BASEDIR}/ozone"
  138. echo