diff options
author | Brad King <brad.king@kitware.com> | 2019-05-24 13:17:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-05-24 13:51:25 (GMT) |
commit | 9bf97363b0d0f3ba0bf89247ce4f8811b4286961 (patch) | |
tree | 3d6c53fd34e7e263f47951e835464519fa848dfc /Utilities/Release | |
parent | 3a0ab3ba2303784e20f1025cf3cd337d840a5b17 (diff) | |
download | CMake-9bf97363b0d0f3ba0bf89247ce4f8811b4286961.zip CMake-9bf97363b0d0f3ba0bf89247ce4f8811b4286961.tar.gz CMake-9bf97363b0d0f3ba0bf89247ce4f8811b4286961.tar.bz2 |
Utilities/Release: Replace upload step with a "push" script
Replace the `upload_release.cmake` script with a `push.bash` script
that is more configurable from the command line and that does not
hard-code any destinations. Instead of using `scp` to access
`cmake.org` directly, push the files atomically to a staging
directory from which another process will actually upload them.
Diffstat (limited to 'Utilities/Release')
-rwxr-xr-x | Utilities/Release/push.bash | 70 | ||||
-rw-r--r-- | Utilities/Release/upload_release.cmake | 40 |
2 files changed, 70 insertions, 40 deletions
diff --git a/Utilities/Release/push.bash b/Utilities/Release/push.bash new file mode 100755 index 0000000..1c8efe9 --- /dev/null +++ b/Utilities/Release/push.bash @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +usage='usage: push.bash [<options>] [--] <dest> + +Options: + + --dir <dir> Specify subdirectory under destination. + Defaults to "v<version>". + --version <ver> CMake <major>.<minor> version number to push. + Defaults to version of source tree. +' + +die() { + echo "$@" 1>&2; exit 1 +} + +cmake_source_dir="${BASH_SOURCE%/*}/../.." + +cmake_version_component() +{ + sed -n " +/^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;} +" "${cmake_source_dir}/Source/CMakeVersion.cmake" +} + + +version='' +dir='' +while test "$#" != 0; do + case "$1" in + --dir) shift; dir="$1" ;; + --version) shift; version="$1" ;; + --) shift ; break ;; + -*) die "$usage" ;; + *) break ;; + esac + shift +done +test "$#" = 1 || die "$usage" +readonly dest="$1" + +if test -z "$version"; then + cmake_version_major="$(cmake_version_component MAJOR)" + cmake_version_minor="$(cmake_version_component MINOR)" + version="${cmake_version_major}.${cmake_version_minor}" +fi +readonly version + +if test -z "$dir"; then + dir="v${version}" +fi +readonly dir + +for f in cmake-${version}*; do + if ! test -f "${f}"; then + continue + fi + + echo "pushing '${f}'" + + # Make a copy with a new timestamp and atomically rename into place. + tf="${dest}/${dir}/.tmp.${f}" + df="${dest}/${dir}/${f}" + cp "${f}" "${tf}" + mv "${tf}" "${df}" + + # Pause to give each file a distinct time stamp even with 1s resolution + # so that sorting by time also sorts alphabetically. + sleep 1.1 +done diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake deleted file mode 100644 index d78e68a..0000000 --- a/Utilities/Release/upload_release.cmake +++ /dev/null @@ -1,40 +0,0 @@ -set(CTEST_RUN_CURRENT_SCRIPT 0) -if(NOT VERSION) - include(${CMAKE_CURRENT_LIST_DIR}/../../Source/CMakeVersion.cmake) - set(VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}) -endif() -if(NOT DEFINED PROJECT_PREFIX) - set(PROJECT_PREFIX cmake-${VERSION}) -endif() -if(NOT DEFINED DIR) - set(DIR "v${VERSION}") -endif() -file(GLOB FILES ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_PREFIX}*") -list(SORT FILES) -list(REVERSE FILES) -message("${FILES}") -set(UPLOAD_LOC - "kitware@www.cmake.org:/projects/FTP/pub/cmake/${DIR}") -set(count 0) -foreach(file ${FILES}) - if(NOT IS_DIRECTORY ${file}) - message("upload ${file} ${UPLOAD_LOC}") - execute_process(COMMAND - scp ${file} ${UPLOAD_LOC} - RESULT_VARIABLE result) - if("${result}" GREATER 0) - message(FATAL_ERROR "failed to upload file to ${UPLOAD_LOC}") - endif() - - # Pause to give each upload a distinct (to the nearest second) - # time stamp - if(COMMAND ctest_sleep) - ctest_sleep(2) - endif() - - math(EXPR count "${count} + 1") - endif() -endforeach() -if(${count} EQUAL 0) - message(FATAL_ERROR "Error no files uploaded.") -endif() |