From 200072dc384b94d977ba66a66f902fcf406fbd9b Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Fri, 3 Feb 2017 15:43:08 -0500 Subject: [PATCH] Added update script --- cmake/DownloadProject.CMakeLists.cmake.in | 3 ++ cmake/DownloadProject.cmake | 34 +++-------------------- scripts/UpdateDownloadProj.py | 29 +++++++++++++++++++ 3 files changed, 36 insertions(+), 30 deletions(-) create mode 100755 scripts/UpdateDownloadProj.py diff --git a/cmake/DownloadProject.CMakeLists.cmake.in b/cmake/DownloadProject.CMakeLists.cmake.in index 0b3c40b9..89be4fdd 100644 --- a/cmake/DownloadProject.CMakeLists.cmake.in +++ b/cmake/DownloadProject.CMakeLists.cmake.in @@ -1,3 +1,6 @@ +# Distributed under the OSI-approved MIT License. See accompanying +# file LICENSE or https://github.com/Crascit/DownloadProject for details. + cmake_minimum_required(VERSION 2.8.2) project(${DL_ARGS_PROJ}-download NONE) diff --git a/cmake/DownloadProject.cmake b/cmake/DownloadProject.cmake index 160c1381..798c74b6 100644 --- a/cmake/DownloadProject.cmake +++ b/cmake/DownloadProject.cmake @@ -1,3 +1,6 @@ +# Distributed under the OSI-approved MIT License. See accompanying +# file LICENSE or https://github.com/Crascit/DownloadProject for details. +# # MODULE: DownloadProject # # PROVIDES: @@ -73,7 +76,7 @@ # # EXAMPLE USAGE: # -# include(DownloadProject.cmake) +# include(DownloadProject) # download_project(PROJ googletest # GIT_REPOSITORY https://github.com/google/googletest.git # GIT_TAG master @@ -83,35 +86,6 @@ # # add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR}) # -# -# SOURCE: -# -# https://github.com/Crascit/DownloadProject -# -# LICENSE: -# -# The MIT License (MIT) -# -# Copyright (c) 2015 Crascit -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# #======================================================================================== diff --git a/scripts/UpdateDownloadProj.py b/scripts/UpdateDownloadProj.py new file mode 100755 index 00000000..3b4fa3a6 --- /dev/null +++ b/scripts/UpdateDownloadProj.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +from __future__ import print_function, division + +from plumbum import local, cli, FG + +FILES = [ 'https://raw.githubusercontent.com/Crascit/DownloadProject/master/DownloadProject.cmake', + 'https://raw.githubusercontent.com/Crascit/DownloadProject/master/DownloadProject.CMakeLists.cmake.in'] + +DIR = local.path(__file__).dirname + +def download_file(path): + try: + from plumbum.cmd import wget + wget[path] & FG + + except ImportError: + from plumbum.cmd import curl + name = path.split('/')[-1] + (curl[path] > name) & FG + +class UpdateDownloadProj(cli.Application): + def main(self): + with local.cwd(DIR / '../cmake'): + for f in FILES: + download_file(f) + +if __name__ == "__main__": + UpdateDownloadProj()