From 9eab773b8fe7ae7700d77b686836c093fdfdeb31 Mon Sep 17 00:00:00 2001
From: Stanislav Ershov <digital.stream.of.mind@gmail.com>
Date: Wed, 21 Nov 2018 02:19:09 +0300
Subject: [PATCH] [asio] Download from github (#4709)

---
 ports/asio/CONTROL        |  2 +-
 ports/asio/portfile.cmake | 22 ++++++++--------------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/ports/asio/CONTROL b/ports/asio/CONTROL
index 34543b9cd7..295b01db8e 100644
--- a/ports/asio/CONTROL
+++ b/ports/asio/CONTROL
@@ -1,3 +1,3 @@
 Source: asio
-Version: 1.12.1
+Version: 1.12.1-1
 Description: Asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.
diff --git a/ports/asio/portfile.cmake b/ports/asio/portfile.cmake
index 279f2c6090..60d329ed81 100644
--- a/ports/asio/portfile.cmake
+++ b/ports/asio/portfile.cmake
@@ -1,25 +1,19 @@
 #header-only library
 include(vcpkg_common_functions)
 
-vcpkg_download_distfile(
-	ARCHIVE_FILE
-	URLS "https://sourceforge.net/projects/asio/files/asio/1.12.1%20%28Stable%29/asio-1.12.1.zip/download"
-	FILENAME "asio-1.12.1.zip"
-	SHA512 f35a519cde88824f65bde095c19d69449d0779e75da9e9ebb6a04f4847802213e8730715756a21632c4d27722cd5568ff7878d656ac79165a8bdf8652fbc1bd8
+vcpkg_from_github(
+    OUT_SOURCE_PATH SOURCE_PATH
+    REPO chriskohlhoff/asio
+    REF asio-1-12-1
+    SHA512 e335eea05c27a72faae95dd5d5ca997ac8bb144cd5fb68e5538129ea6afb3b4d88e2be1c31a1effdbbbe4c93e07ee274a7e5817453c29faf56abf9ab692b2dd6
+    HEAD_REF master
 )
 
-vcpkg_extract_source_archive(
-	${ARCHIVE_FILE}
-)
-
-set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/asio-1.12.1)
-
 # Handle copyright
-file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
-file(RENAME ${CURRENT_PACKAGES_DIR}/share/${PORT}/COPYING ${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright)
+file(INSTALL ${SOURCE_PATH}/asio/LICENSE_1_0.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
 
 # Copy the asio header files
-file(INSTALL ${SOURCE_PATH}/include DESTINATION ${CURRENT_PACKAGES_DIR} FILES_MATCHING PATTERN "*.hpp" PATTERN "*.ipp")
+file(INSTALL ${SOURCE_PATH}/asio/include DESTINATION ${CURRENT_PACKAGES_DIR} FILES_MATCHING PATTERN "*.hpp" PATTERN "*.ipp")
 
 # Always use "ASIO_STANDALONE" to avoid boost dependency
 file(READ "${CURRENT_PACKAGES_DIR}/include/asio/detail/config.hpp" _contents)