Extended rosbuild_download_*() to accept and check md5sums, #1662.
This commit is contained in:
parent
321827d682
commit
7be59ddb98
|
@ -16,16 +16,33 @@ def main():
|
|||
else:
|
||||
parser.error("wrong number of arguments")
|
||||
|
||||
urllib.urlretrieve(uri, dest)
|
||||
fresh = False
|
||||
if not os.path.exists(dest):
|
||||
sys.stdout.write('[rosbuild] Downloading %s to %s...'%(uri, dest))
|
||||
sys.stdout.flush()
|
||||
urllib.urlretrieve(uri, dest)
|
||||
sys.stdout.write('Done\n')
|
||||
fresh = True
|
||||
|
||||
if md5sum:
|
||||
m = md5.new(open(dest).read())
|
||||
d = m.hexdigest()
|
||||
|
||||
print '[rosbuild] Checking md5sum on %s'%(dest)
|
||||
|
||||
if d != md5sum:
|
||||
print 'md5sum mismatch (%s != %s); removing file %s'%(d, md5sum, dest)
|
||||
os.remove(dest)
|
||||
return 1
|
||||
if not fresh:
|
||||
print '[rosbuild] WARNING: md5sum mismatch (%s != %s); re-downloading file %s'%(d, md5sum, dest)
|
||||
os.remove(dest)
|
||||
|
||||
# Try one more time
|
||||
urllib.urlretrieve(uri, dest)
|
||||
m = md5.new(open(dest).read())
|
||||
d = m.hexdigest()
|
||||
|
||||
if d != md5sum:
|
||||
print '[rosbuild] ERROR: md5sum mismatch (%s != %s) on %s; aborting'%(d, md5sum, dest)
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
|
|
@ -743,34 +743,35 @@ macro(rosbuild_link_boost target)
|
|||
endmacro(rosbuild_link_boost)
|
||||
|
||||
# Macro to download data on the tests target
|
||||
# The real signature is:
|
||||
#macro(rosbuild_download_test_data _url _filename _md5)
|
||||
macro(rosbuild_download_test_data _url _filename)
|
||||
find_package(Wget REQUIRED)
|
||||
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/${_filename}
|
||||
COMMAND cmake -E echo "[rosbuild] Downloading ${_url} to ${_filename}..."
|
||||
COMMAND ${WGET_EXECUTABLE} -q ${_url} -O ${PROJECT_SOURCE_DIR}/${_filename}
|
||||
COMMAND cmake -E echo "[rosbuild] Done."
|
||||
VERBATIM)
|
||||
if("${ARGN}" STREQUAL "")
|
||||
_rosbuild_warn("The 2-argument rosbuild_download_test_data(url file) is deprecated; please switch to the 3-argument form, supplying an md5sum for the file: rosbuild_download_test_data(url file md5)")
|
||||
endif("${ARGN}" STREQUAL "")
|
||||
|
||||
# Create a legal target name, in case the target name has slashes in it
|
||||
string(REPLACE "/" "_" _testname download_data_${_filename})
|
||||
add_custom_target(${_testname}
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/${_filename})
|
||||
COMMAND $ENV{ROS_ROOT}/core/rosbuild/bin/download_checkmd5.py ${_url} ${PROJECT_SOURCE_DIR}/${_filename} ${ARGN}
|
||||
VERBATIM)
|
||||
# Redeclaration of target is to workaround bug in 2.4.6
|
||||
add_custom_target(tests)
|
||||
add_dependencies(tests ${_testname})
|
||||
endmacro(rosbuild_download_test_data)
|
||||
|
||||
# Macro to download data on the all target
|
||||
# The real signature is:
|
||||
#macro(rosbuild_download_data _url _filename _md5)
|
||||
macro(rosbuild_download_data _url _filename)
|
||||
find_package(Wget REQUIRED)
|
||||
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/${_filename}
|
||||
COMMAND cmake -E echo "[rosbuild] Downloading ${_url} to ${_filename}..."
|
||||
COMMAND ${WGET_EXECUTABLE} -q ${_url} -O ${PROJECT_SOURCE_DIR}/${_filename}
|
||||
COMMAND cmake -E echo "[rosbuild] Done."
|
||||
if("${ARGN}" STREQUAL "")
|
||||
_rosbuild_warn("The 2-argument rosbuild_download_data(url file) is deprecated; please switch to the 3-argument form, supplying an md5sum for the file: rosbuild_download_data(url file md5)")
|
||||
endif("${ARGN}" STREQUAL "")
|
||||
# Create a legal target name, in case the target name has slashes in it
|
||||
string(REPLACE "/" "_" _testname download_data_${_filename})
|
||||
add_custom_target(${_testname} ALL
|
||||
COMMAND $ENV{ROS_ROOT}/core/rosbuild/bin/download_checkmd5.py ${_url} ${PROJECT_SOURCE_DIR}/${_filename} ${ARGN}
|
||||
VERBATIM)
|
||||
# Create a legal target name, in case the target name has slashes in it
|
||||
string(REPLACE "/" "_" _testname download_data_${_filename})
|
||||
add_custom_target(${_testname} ALL
|
||||
DEPENDS ${PROJECT_SOURCE_DIR}/${_filename})
|
||||
endmacro(rosbuild_download_data)
|
||||
|
||||
macro(rosbuild_add_openmp_flags target)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
cmake_minimum_required(VERSION 2.4.6)
|
||||
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
|
||||
rosbuild_init()
|
||||
genmsg()
|
||||
gensrv()
|
||||
rosbuild_genmsg()
|
||||
rosbuild_gensrv()
|
||||
# unit tests
|
||||
rospack_add_pyunit(test/test_genmsg_py.py)
|
||||
rospack_add_pyunit(test/test_rospy_api.py)
|
||||
|
|
|
@ -30,5 +30,5 @@ genmsg()
|
|||
#target_link_libraries(example ${PROJECT_NAME})
|
||||
|
||||
# unit tests
|
||||
rospack_download_test_data(http://pr.willowgarage.com/data/rosrecord/rosrecord_rename_test.bag test/rosrecord_rename_test.bag)
|
||||
rospack_download_test_data(http://pr.willowgarage.com/data/rosrecord/rosrecord_rename_test.bag test/rosrecord_rename_test.bag 09c6e106c77b06ed3e836a5280c8a7c2)
|
||||
rospack_add_rostest(test/rename_test.xml)
|
||||
|
|
Loading…
Reference in New Issue