create-release 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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. if [[ -z "${BASH_VERSINFO[0]}" ]] \
  17. || [[ "${BASH_VERSINFO[0]}" -lt 3 ]] \
  18. || [[ "${BASH_VERSINFO[0]}" -eq 3 && "${BASH_VERSINFO[1]}" -lt 2 ]]; then
  19. echo "bash v3.2+ is required. Sorry."
  20. exit 1
  21. fi
  22. function centered_text
  23. {
  24. local text="$*"
  25. local spacing=$(( (75+${#text}) /2 ))
  26. printf "%*s\n" ${spacing} "${text}"
  27. }
  28. function big_console_header
  29. {
  30. printf "\n\n"
  31. echo "****************************************************************************"
  32. centered_text "${@}"
  33. echo "****************************************************************************"
  34. printf "\n\n"
  35. }
  36. ## @description Given a filename or dir, return the absolute version of it
  37. ## @audience public
  38. ## @stability stable
  39. ## @param directory
  40. ## @replaceable no
  41. ## @return 0 success
  42. ## @return 1 failure
  43. ## @return stdout abspath
  44. function hadoop_abs
  45. {
  46. declare obj=$1
  47. declare dir
  48. declare fn
  49. declare ret
  50. if [[ ! -e ${obj} ]]; then
  51. return 1
  52. elif [[ -d ${obj} ]]; then
  53. dir=${obj}
  54. else
  55. dir=$(dirname -- "${obj}")
  56. fn=$(basename -- "${obj}")
  57. fn="/${fn}"
  58. fi
  59. dir=$(cd -P -- "${dir}" >/dev/null 2>/dev/null && pwd -P)
  60. ret=$?
  61. if [[ ${ret} = 0 ]]; then
  62. echo "${dir}${fn}"
  63. return 0
  64. fi
  65. return 1
  66. }
  67. ## @description Print a message to stderr
  68. ## @audience public
  69. ## @stability stable
  70. ## @replaceable no
  71. ## @param string
  72. function hadoop_error
  73. {
  74. echo "$*" 1>&2
  75. }
  76. function run_and_redirect
  77. {
  78. declare logfile=$1
  79. shift
  80. declare res
  81. echo "\$ ${*} > ${logfile} 2>&1"
  82. # to the log
  83. {
  84. date
  85. echo "cd $(pwd)"
  86. echo "${*}"
  87. } > "${logfile}"
  88. # run the actual command
  89. "${@}" >> "${logfile}" 2>&1
  90. res=$?
  91. if [[ ${res} != 0 ]]; then
  92. echo
  93. echo "Failed!"
  94. echo
  95. exit "${res}"
  96. fi
  97. }
  98. function hadoop_native_flags
  99. {
  100. # modified version of the Yetus personality
  101. if [[ ${NATIVE} != true ]]; then
  102. return
  103. fi
  104. # Based upon HADOOP-11937
  105. #
  106. # Some notes:
  107. #
  108. # - getting fuse to compile on anything but Linux
  109. # is always tricky.
  110. # - Darwin assumes homebrew is in use.
  111. # - HADOOP-12027 required for bzip2 on OS X.
  112. # - bzip2 is broken in lots of places.
  113. # e.g, HADOOP-12027 for OS X. so no -Drequire.bzip2
  114. #
  115. case "${OSNAME}" in
  116. Linux)
  117. # shellcheck disable=SC2086
  118. echo -Pnative -Drequire.snappy -Drequire.openssl -Drequire.fuse
  119. ;;
  120. Darwin)
  121. echo \
  122. -Pnative -Drequire.snappy \
  123. -Drequire.openssl \
  124. -Dopenssl.prefix=/usr/local/opt/openssl/ \
  125. -Dopenssl.include=/usr/local/opt/openssl/include \
  126. -Dopenssl.lib=/usr/local/opt/openssl/lib
  127. ;;
  128. *)
  129. # shellcheck disable=SC2086
  130. echo \
  131. -Pnative \
  132. -Drequire.snappy -Drequire.openssl \
  133. -Drequire.test.libhadoop
  134. ;;
  135. esac
  136. }
  137. # Function to probe the exit code of the script commands,
  138. # and stop in the case of failure with an contextual error
  139. # message.
  140. function run()
  141. {
  142. declare res
  143. declare logfile
  144. echo "\$ ${*}"
  145. "${@}"
  146. res=$?
  147. if [[ ${res} != 0 ]]; then
  148. echo
  149. echo "Failed!"
  150. echo
  151. exit "${res}"
  152. fi
  153. }
  154. function header()
  155. {
  156. echo
  157. printf "\n\n"
  158. echo "============================================================================"
  159. echo "============================================================================"
  160. centered_text "Hadoop Release Creator"
  161. echo "============================================================================"
  162. echo "============================================================================"
  163. printf "\n\n"
  164. echo "Version to create : ${HADOOP_VERSION}"
  165. echo "Release Candidate Label: ${RC_LABEL##-}"
  166. echo "Source Version : ${DEFAULT_HADOOP_VERSION}"
  167. printf "\n\n"
  168. }
  169. function set_defaults
  170. {
  171. BINDIR=$(dirname "${BIN}")
  172. BASEDIR=$(hadoop_abs "${BINDIR}/../..")
  173. ARTIFACTS_DIR="${BASEDIR}/target/artifacts"
  174. # Extract Hadoop version from ${BASEDIR}/pom.xml
  175. DEFAULT_HADOOP_VERSION=$(grep "<version>" "${BASEDIR}/pom.xml" \
  176. | head -1 \
  177. | sed -e 's|^ *<version>||' -e 's|</version>.*$||')
  178. DEPLOY=false
  179. DOCKER=false
  180. DOCKERCACHE=false
  181. DOCKERFILE="${BASEDIR}/dev-support/docker/Dockerfile"
  182. DOCKERRAN=false
  183. CPU_ARCH=$(echo "$MACHTYPE" | cut -d- -f1)
  184. if [ "$CPU_ARCH" = "aarch64" ]; then
  185. DOCKERFILE="${BASEDIR}/dev-support/docker/Dockerfile_aarch64"
  186. fi
  187. # Extract Java version from ${BASEDIR}/pom.xml
  188. # doing this outside of maven means we can do this before
  189. # the docker container comes up...
  190. JVM_VERSION=$(grep "<javac.version>" "${BASEDIR}/hadoop-project/pom.xml" \
  191. | head -1 \
  192. | sed -e 's|^ *<javac.version>||' -e 's|</javac.version>.*$||' -e 's|..||')
  193. GIT=$(command -v git)
  194. GPG=$(command -v gpg)
  195. GPGAGENT=$(command -v gpg-agent)
  196. HADOOP_VERSION="${DEFAULT_HADOOP_VERSION}"
  197. INDOCKER=false
  198. LOGDIR="${BASEDIR}/patchprocess"
  199. if [[ -z "${MVN}" ]]; then
  200. if [[ -n "${MAVEN_HOME}" ]]; then
  201. MVN=${MAVEN_HOME}/bin/mvn
  202. else
  203. MVN=$(command -v mvn)
  204. fi
  205. fi
  206. NATIVE=false
  207. OSNAME=$(uname -s)
  208. PUBKEYFILE="https://dist.apache.org/repos/dist/release/hadoop/common/KEYS"
  209. SIGN=false
  210. }
  211. function startgpgagent
  212. {
  213. if [[ "${SIGN}" = true ]]; then
  214. if [[ -n "${GPGAGENT}" && -z "${GPG_AGENT_INFO}" ]]; then
  215. echo "starting gpg agent"
  216. echo "default-cache-ttl 36000" > "${LOGDIR}/gpgagent.conf"
  217. echo "max-cache-ttl 36000" >> "${LOGDIR}/gpgagent.conf"
  218. # shellcheck disable=2046
  219. eval $("${GPGAGENT}" --daemon \
  220. --options "${LOGDIR}/gpgagent.conf" \
  221. --log-file="${LOGDIR}/create-release-gpgagent.log")
  222. GPGAGENTPID=$(pgrep "${GPGAGENT}")
  223. GPG_AGENT_INFO="$HOME/.gnupg/S.gpg-agent:$GPGAGENTPID:1"
  224. export GPG_AGENT_INFO
  225. fi
  226. if [[ -n "${GPG_AGENT_INFO}" ]]; then
  227. echo "Warming the gpg-agent cache prior to calling maven"
  228. # warm the agent's cache:
  229. touch "${LOGDIR}/warm"
  230. ${GPG} --use-agent --armor --output "${LOGDIR}/warm.asc" --detach-sig "${LOGDIR}/warm"
  231. rm "${LOGDIR}/warm.asc" "${LOGDIR}/warm"
  232. else
  233. SIGN=false
  234. hadoop_error "ERROR: Unable to launch or acquire gpg-agent. Disable signing."
  235. fi
  236. fi
  237. }
  238. function stopgpgagent
  239. {
  240. if [[ -n "${GPGAGENTPID}" ]]; then
  241. kill "${GPGAGENTPID}"
  242. fi
  243. }
  244. function usage
  245. {
  246. echo "--artifactsdir=[path] Path to use to store release bits"
  247. echo "--asfrelease Make an ASF release"
  248. echo "--deploy Deploy Maven artifacts using ~/.m2/settings.xml"
  249. echo "--docker Use Hadoop's Dockerfile for guaranteed environment"
  250. echo "--dockercache Use a Docker-private maven cache"
  251. echo "--logdir=[path] Path to store logs"
  252. echo "--mvncache=[path] Path to the maven cache to use"
  253. echo "--native Also build the native components"
  254. echo "--rc-label=[label] Add this label to the builds"
  255. echo "--security Emergency security release"
  256. echo "--sign Use .gnupg dir to sign the artifacts and jars"
  257. echo "--version=[version] Use an alternative version string"
  258. }
  259. function option_parse
  260. {
  261. declare i
  262. for i in "$@"; do
  263. case ${i} in
  264. --asfrelease)
  265. ASFRELEASE=true
  266. NATIVE=true
  267. SIGN=true
  268. DEPLOY=true
  269. ;;
  270. --artifactsdir=*)
  271. ARTIFACTS_DIR=${i#*=}
  272. ;;
  273. --deploy)
  274. DEPLOY=true
  275. ;;
  276. --docker)
  277. DOCKER=true
  278. ;;
  279. --dockercache)
  280. DOCKERCACHE=true
  281. ;;
  282. --help)
  283. usage
  284. exit
  285. ;;
  286. --indocker)
  287. INDOCKER=true
  288. ;;
  289. --logdir=*)
  290. LOGDIR=${i#*=}
  291. ;;
  292. --mvncache=*)
  293. MVNCACHE=${i#*=}
  294. ;;
  295. --native)
  296. NATIVE=true
  297. ;;
  298. --rc-label=*)
  299. RC_LABEL=${i#*=}
  300. ;;
  301. --security)
  302. SECURITYRELEASE=true
  303. ;;
  304. --sign)
  305. SIGN=true
  306. ;;
  307. --version=*)
  308. HADOOP_VERSION=${i#*=}
  309. ;;
  310. esac
  311. done
  312. if [[ ! -d "${HOME}/.gnupg" ]]; then
  313. hadoop_error "ERROR: No .gnupg dir. Disabling signing capability."
  314. SIGN=false
  315. fi
  316. if [[ "${SIGN}" = true ]]; then
  317. if [[ -n "${GPG_AGENT_INFO}" ]]; then
  318. echo "NOTE: Using existing gpg-agent. If the default-cache-ttl"
  319. echo "is set to less than ~20 mins, maven commands will fail."
  320. elif [[ -z "${GPGAGENT}" ]]; then
  321. hadoop_error "ERROR: No gpg-agent. Disabling signing capability."
  322. SIGN=false
  323. fi
  324. fi
  325. if [[ "${DEPLOY}" = true && ! -f "${HOME}/.m2/settings.xml" ]]; then
  326. hadoop_error "ERROR: No ~/.m2/settings.xml file, cannot deploy Maven artifacts."
  327. exit 1
  328. fi
  329. DOCKERCMD=$(command -v docker)
  330. if [[ "${DOCKER}" = true && -z "${DOCKERCMD}" ]]; then
  331. hadoop_error "ERROR: docker binary not found. Disabling docker mode."
  332. DOCKER=false
  333. fi
  334. if [[ "${DOCKERCACHE}" = true && "${DOCKER}" = false ]]; then
  335. if [[ "${INDOCKER}" = false ]]; then
  336. hadoop_error "ERROR: docker mode not enabled. Disabling dockercache."
  337. fi
  338. DOCKERCACHE=false
  339. fi
  340. if [[ "${DOCKERCACHE}" = true && -n "${MVNCACHE}" ]]; then
  341. hadoop_error "ERROR: Cannot set --mvncache and --dockercache simultaneously."
  342. exit 1
  343. else
  344. MVNCACHE=${MVNCACHE:-"${HOME}/.m2/repository"}
  345. fi
  346. if [[ "${ASFRELEASE}" = true ]]; then
  347. if [[ "${SIGN}" = false ]]; then
  348. hadoop_error "ERROR: --asfrelease requires --sign. Exiting."
  349. exit 1
  350. fi
  351. if [[ "${OSNAME}" = Linux ]]; then
  352. if [[ "${DOCKER}" = false && "${INDOCKER}" = false ]]; then
  353. hadoop_error "ERROR: --asfrelease requires --docker on Linux. Exiting."
  354. exit 1
  355. elif [[ "${DOCKERCACHE}" = false && "${INDOCKER}" = false ]]; then
  356. hadoop_error "ERROR: --asfrelease on Linux requires --dockercache. Exiting."
  357. exit 1
  358. fi
  359. fi
  360. fi
  361. if [[ -n "${MVNCACHE}" ]]; then
  362. mkdir -p "${MVNCACHE}"
  363. if [[ -d "${MVNCACHE}" ]]; then
  364. MVN_ARGS=("-Dmaven.repo.local=${MVNCACHE}")
  365. fi
  366. fi
  367. if [[ "${SECURITYRELEASE}" = true ]]; then
  368. if [[ ! -d "${BASEDIR}/hadoop-common-project/hadoop-common/src/site/markdown/release/${HADOOP_VERSION}" ]]; then
  369. hadoop_error "ERROR: ${BASEDIR}/hadoop-common-project/hadoop-common/src/site/markdown/release/${HADOOP_VERSION} does not exist."
  370. hadoop_error "ERROR: This directory and its contents are required to be manually created for a security release."
  371. exit 1
  372. fi
  373. fi
  374. }
  375. function dockermode
  376. {
  377. declare lines
  378. declare -a modp
  379. declare imgname
  380. declare -a extrad
  381. declare user_name
  382. declare group_id
  383. if [[ "${DOCKER}" != true ]]; then
  384. return
  385. fi
  386. user_name=${SUDO_USER:=$USER}
  387. user_id=$(id -u "${user_name}")
  388. group_id=$(id -g "${user_name}")
  389. imgname="hadoop/createrelease:${HADOOP_VERSION}_${RANDOM}"
  390. if [[ -d "${HOME}/.gnupg" ]]; then
  391. extrad+=("-v" "${HOME}/.gnupg:/home/${user_name}/.gnupg")
  392. fi
  393. if [[ -n "${LOGDIR}" ]]; then
  394. if [[ ! -d "${LOGDIR}" ]]; then
  395. mkdir -p "${LOGDIR}"
  396. fi
  397. lines=$(hadoop_abs "${LOGDIR}")
  398. extrad+=("-v" "${lines}:${lines}")
  399. fi
  400. if [[ -n "${ARTIFACTS_DIR}" ]]; then
  401. if [[ ! -d "${ARTIFACTS_DIR}" ]]; then
  402. mkdir -p "${ARTIFACTS_DIR}"
  403. fi
  404. lines=$(hadoop_abs "${ARTIFACTS_DIR}")
  405. extrad+=("-v" "${lines}:${lines}")
  406. fi
  407. if [[ "${DEPLOY}" = true ]]; then
  408. modp+=("--deploy")
  409. extrad+=("-v" "${HOME}/.m2/settings.xml:/home/${user_name}/.m2/settings.xml")
  410. fi
  411. if [[ "${DOCKERCACHE}" = true ]]; then
  412. modp+=("--mvncache=/maven")
  413. else
  414. lines=$(hadoop_abs "${MVNCACHE}")
  415. extrad+=("-v" "${lines}:${lines}")
  416. fi
  417. for lines in "${PARAMS[@]}"; do
  418. if [[ "${lines}" != "--docker" ]]; then
  419. modp+=("$lines")
  420. fi
  421. done
  422. modp+=("--indocker")
  423. (
  424. lines=$(grep -n 'YETUS CUT HERE' "${DOCKERFILE}" | cut -f1 -d:)
  425. if [[ -z "${lines}" ]]; then
  426. cat "${DOCKERFILE}"
  427. else
  428. head -n "${lines}" "${DOCKERFILE}"
  429. fi
  430. # make sure we put some space between, just in case last
  431. # line isn't an empty line or whatever
  432. printf "\n\n"
  433. # force a new image for every run to make it easier to remove later
  434. echo "LABEL org.apache.hadoop.create-release=\"cr-${RANDOM}\""
  435. # setup ownerships, etc
  436. echo "RUN groupadd --non-unique -g ${group_id} ${user_name}"
  437. echo "RUN useradd -g ${group_id} -u ${user_id} -m ${user_name}"
  438. echo "RUN chown -R ${user_name} /home/${user_name}"
  439. echo "ENV HOME /home/${user_name}"
  440. echo "RUN mkdir -p /maven"
  441. echo "RUN chown -R ${user_name} /maven"
  442. # we always force build with the OpenJDK JDK
  443. # but with the correct version
  444. if [ "$CPU_ARCH" = "aarch64" ]; then
  445. echo "ENV JAVA_HOME /usr/lib/jvm/java-${JVM_VERSION}-openjdk-arm64"
  446. else
  447. echo "ENV JAVA_HOME /usr/lib/jvm/java-${JVM_VERSION}-openjdk-amd64"
  448. fi
  449. echo "USER ${user_name}"
  450. printf "\n\n"
  451. ) | docker build -t "${imgname}" -f - "${BASEDIR}"/dev-support/docker/
  452. run docker run -i -t \
  453. --privileged \
  454. "${extrad[@]}" \
  455. -v "${BASEDIR}:/build/source" \
  456. -u "${user_name}" \
  457. -w "/build/source" \
  458. "${imgname}" \
  459. "/build/source/dev-support/bin/create-release" "${modp[@]}"
  460. DOCKERRAN=true
  461. }
  462. function makearelease
  463. {
  464. # let's start at the root
  465. run cd "${BASEDIR}"
  466. big_console_header "Cleaning the Source Tree"
  467. # git clean to clear any remnants from previous build
  468. run "${GIT}" clean -xdf -e /patchprocess
  469. mkdir -p "${LOGDIR}"
  470. # Install the Hadoop maven plugins first
  471. run_and_redirect "${LOGDIR}/mvn_install_maven_plugins.log" "${MVN}" "${MVN_ARGS[@]}" -pl hadoop-maven-plugins -am clean install
  472. # mvn clean for sanity
  473. run_and_redirect "${LOGDIR}/mvn_clean.log" "${MVN}" "${MVN_ARGS[@]}" clean
  474. # Create staging dir for release artifacts
  475. run mkdir -p "${ARTIFACTS_DIR}"
  476. big_console_header "Apache RAT Check"
  477. # Create RAT report
  478. run_and_redirect "${LOGDIR}/mvn_apache_rat.log" "${MVN}" "${MVN_ARGS[@]}" apache-rat:check
  479. big_console_header "Maven Build and Install"
  480. if [[ "${SIGN}" = true ]]; then
  481. signflags=("-Psign" "-Dgpg.useagent=true" "-Dgpg.executable=${GPG}")
  482. fi
  483. local target="install"
  484. if [[ "${DEPLOY}" = true ]]; then
  485. target="deploy"
  486. fi
  487. # Create SRC and BIN tarballs for release,
  488. # shellcheck disable=SC2046
  489. run_and_redirect "${LOGDIR}/mvn_${target}.log" \
  490. "${MVN}" "${MVN_ARGS[@]}" ${target} \
  491. -Pdist,src,yarn-ui \
  492. "${signflags[@]}" \
  493. -DskipTests -Dtar $(hadoop_native_flags)
  494. # Stage BIN tarball
  495. run cd "${BASEDIR}"
  496. run mv \
  497. "${BASEDIR}/hadoop-dist/target/hadoop-${HADOOP_VERSION}.tar.gz" \
  498. "${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}.tar.gz"
  499. # Stage SRC tarball
  500. run mv \
  501. "${BASEDIR}/hadoop-dist/target/hadoop-${HADOOP_VERSION}-src.tar.gz" \
  502. "${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-src.tar.gz"
  503. big_console_header "Maven Site"
  504. if [[ "${SECURITYRELEASE}" = true ]]; then
  505. DOCFLAGS="-Pdocs"
  506. hadoop_error "WARNING: Skipping automatic changelog and release notes generation due to --security"
  507. else
  508. DOCFLAGS="-Preleasedocs,docs"
  509. fi
  510. # Create site for release
  511. # we need to do install again so that jdiff and
  512. # a few other things get registered in the maven
  513. # universe correctly
  514. run_and_redirect "${LOGDIR}/mvn_site.log" \
  515. "${MVN}" "${MVN_ARGS[@]}" install \
  516. site site:stage \
  517. -DskipTests \
  518. -DskipShade \
  519. -Pdist,src \
  520. "${DOCFLAGS}"
  521. # Create the site tarball
  522. run mv "${BASEDIR}/target/staging/hadoop-project" "${BASEDIR}/target/r${HADOOP_VERSION}/"
  523. run cd "${BASEDIR}/target/"
  524. run tar czpf "hadoop-site-${HADOOP_VERSION}.tar.gz" "r${HADOOP_VERSION}"/*
  525. run cd "${BASEDIR}"
  526. # Stage SITE tarball
  527. run mv \
  528. "${BASEDIR}/target/hadoop-site-${HADOOP_VERSION}.tar.gz" \
  529. "${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-site.tar.gz"
  530. # Stage RAT report
  531. #shellcheck disable=SC2038
  532. find . -name rat.txt | xargs -I% cat % > "${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-rat.txt"
  533. # Stage CHANGELOG and RELEASENOTES files
  534. for i in CHANGELOG RELEASENOTES; do
  535. run cp -p \
  536. "${BASEDIR}/hadoop-common-project/hadoop-common/src/site/markdown/release/${HADOOP_VERSION}"/${i}*.md \
  537. "${ARTIFACTS_DIR}/${i}.md"
  538. done
  539. # We need to fixup the BIN tarball at the end to contain the site docs.
  540. run cd "${ARTIFACTS_DIR}"
  541. run tar -xzpf "hadoop-${HADOOP_VERSION}${RC_LABEL}.tar.gz"
  542. run mkdir -p "hadoop-${HADOOP_VERSION}/share/doc/hadoop/"
  543. run cp -r "${BASEDIR}/target/r${HADOOP_VERSION}"/* "hadoop-${HADOOP_VERSION}/share/doc/hadoop/"
  544. run tar -czpf "hadoop-${HADOOP_VERSION}${RC_LABEL}.tar.gz" "hadoop-${HADOOP_VERSION}"
  545. run rm -rf "hadoop-${HADOOP_VERSION}"
  546. }
  547. function signartifacts
  548. {
  549. declare i
  550. declare ret
  551. if [[ "${SIGN}" = false ]]; then
  552. echo ""
  553. echo "Remember to sign the artifacts before staging them on the open"
  554. echo ""
  555. return
  556. fi
  557. big_console_header "Signing the release"
  558. run cd "${ARTIFACTS_DIR}"
  559. for i in *; do
  560. ${GPG} --use-agent --armor --output "${i}.asc" --detach-sig "${i}"
  561. sha512sum --tag "${i}" > "${i}.sha512"
  562. done
  563. run cd "${BASEDIR}"
  564. if [[ "${ASFRELEASE}" = true ]]; then
  565. echo "Fetching the Apache Hadoop KEYS file..."
  566. curl -L "${PUBKEYFILE}" -o "${BASEDIR}/target/KEYS"
  567. ${GPG} --import --trustdb "${BASEDIR}/target/testkeysdb" "${BASEDIR}/target/KEYS"
  568. ${GPG} --verify --trustdb "${BASEDIR}/target/testkeysdb" \
  569. "${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}.tar.gz.asc" \
  570. "${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}.tar.gz"
  571. ret=$?
  572. if [[ ${ret} != 0 ]]; then
  573. hadoop_error "ERROR: GPG key is not present in ${PUBKEYFILE}."
  574. hadoop_error "ERROR: This MUST be fixed. Exiting."
  575. exit 1
  576. fi
  577. fi
  578. }
  579. # find root of the source tree
  580. BIN=$(hadoop_abs "${BASH_SOURCE:-$0}")
  581. PARAMS=("$@")
  582. set_defaults
  583. option_parse "${PARAMS[@]}"
  584. dockermode
  585. header
  586. if [[ -n ${RC_LABEL} ]]; then
  587. RC_LABEL="-${RC_LABEL}"
  588. fi
  589. if [[ "${INDOCKER}" = true || "${DOCKERRAN}" = false ]]; then
  590. startgpgagent
  591. makearelease
  592. releaseret=$?
  593. signartifacts
  594. stopgpgagent
  595. fi
  596. if [[ "${INDOCKER}" = true ]]; then
  597. exit $?
  598. fi
  599. if [[ ${releaseret} == 0 ]]; then
  600. echo
  601. echo "Congratulations, you have successfully built the release"
  602. echo "artifacts for Apache Hadoop ${HADOOP_VERSION}${RC_LABEL}"
  603. echo
  604. echo "The artifacts for this run are available at ${ARTIFACTS_DIR}:"
  605. run ls -1 "${ARTIFACTS_DIR}"
  606. echo
  607. fi