forked from RenderKit/ospray
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfiles-to-md5.sh
executable file
·70 lines (57 loc) · 2.51 KB
/
files-to-md5.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
## ======================================================================== ##
## Copyright 2017-2017 Intel Corporation ##
## ##
## Licensed under the Apache License, Version 2.0 (the "License"); ##
## you may not use this file except in compliance with the License. ##
## You may obtain a copy of the License at ##
## ##
## http://www.apache.org/licenses/LICENSE-2.0 ##
## ##
## Unless required by applicable law or agreed to in writing, software ##
## distributed under the License is distributed on an "AS IS" BASIS, ##
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ##
## See the License for the specific language governing permissions and ##
## limitations under the License. ##
## ======================================================================== ##
#!/bin/bash
# This script should be called from build directory (OSPRay root should be in ../)
#
# Usage:
# CI_TARGET_MACHINE_PATH=user@machine-name:/target/path BASELINE_MD5_DIR=/dir/with/md5/hashes
# BASELINE_DIR=/dir/with/files/to/be/synced ../scripts/files-to-md5.sh
md5 () {
md5sum $1 | awk '{print $1 }'
}
if [[ ! $CI_TARGET_MACHINE_PATH ]]
then
echo "Please set CI_TARGET_MACHINE_PATH env variable"
exit 1
fi
if [[ ! $BASELINE_MD5_DIR ]]
then
echo "Please set BASELINE_MD5_DIR env variable"
exit 1
fi
if [[ ! $BASELINE_DIR ]]
then
echo "Please set BASELINE_DIR env variable"
exit 1
fi
LOCAL_TMP_DIR=/tmp/ospray-tmp-data
# Remove any old files (whole directory)
rm -rf $LOCAL_TMP_DIR
# Create this directory again
mkdir $LOCAL_TMP_DIR
# From now on any command should stop executing script
set -e
for FILE in $BASELINE_DIR/*; do
# Copy file to local tmp directory with new name (based on md5 from this img)
cp $FILE $LOCAL_TMP_DIR/`md5 $FILE`
# Create/Filll metadata file in ospray repo
# so we can link img in remote repo by this md5 string
md5 $FILE > $BASELINE_MD5_DIR/`basename $FILE`.md5
done
# Copy all files (only when there is need to update) to target CI machine
rsync --progress -au --no-o --no-g $LOCAL_TMP_DIR/* $CI_TARGET_MACHINE_PATH
# Another cleanup - we don't want to leave any files locally
rm -rf $LOCAL_TMP_DIR/*