Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/Release/push.bash
3148 views
1
#!/usr/bin/env bash
2
3
usage='usage: push.bash [<options>] [--] <dest>
4
5
Options:
6
7
--dir <dir> Specify subdirectory under destination.
8
Defaults to "v<version>".
9
--version <ver> CMake <major>.<minor> version number to push.
10
Defaults to version of source tree.
11
'
12
13
die() {
14
echo "$@" 1>&2; exit 1
15
}
16
17
cmake_source_dir="${BASH_SOURCE%/*}/../.."
18
19
cmake_version_component()
20
{
21
sed -n "
22
/^set(CMake_VERSION_${1}/ {s/set(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
23
" "${cmake_source_dir}/Source/CMakeVersion.cmake"
24
}
25
26
27
version=''
28
dir=''
29
while test "$#" != 0; do
30
case "$1" in
31
--dir) shift; dir="$1" ;;
32
--version) shift; version="$1" ;;
33
--) shift ; break ;;
34
-*) die "$usage" ;;
35
*) break ;;
36
esac
37
shift
38
done
39
test "$#" = 1 || die "$usage"
40
readonly dest="$1"
41
42
if test -z "$version"; then
43
cmake_version_major="$(cmake_version_component MAJOR)"
44
cmake_version_minor="$(cmake_version_component MINOR)"
45
version="${cmake_version_major}.${cmake_version_minor}"
46
fi
47
readonly version
48
49
if test -z "$dir"; then
50
dir="v${version}"
51
fi
52
readonly dir
53
if ! test -d "${dest}/${dir}"; then
54
mkdir "${dest}/${dir}"
55
fi
56
57
for f in cmake-${version}*; do
58
if ! test -f "${f}"; then
59
continue
60
fi
61
62
echo "pushing '${f}'"
63
64
# Make a copy with a new timestamp and atomically rename into place.
65
tf="${dest}/${dir}/.tmp.${f}"
66
df="${dest}/${dir}/${f}"
67
cp "${f}" "${tf}"
68
mv "${tf}" "${df}"
69
70
# Pause to give each file a distinct time stamp even with 1s resolution
71
# so that sorting by time also sorts alphabetically.
72
sleep 1.1
73
done
74
75