summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandon McAnsh <brandon.mcansh@gmail.com>2016-12-30 16:26:44 -0500
committerDan Pasanen <dan.pasanen@gmail.com>2017-01-08 15:58:48 +0000
commit1846ec0341efacef7f90012ff64bae440fa12f1c (patch)
tree7ae6fbcf68d0c0b958e26b7574df52d9fc9be3e9
parent3521fa5a3bd003269498eea337009ee4e17f3eda (diff)
downloadvendor_replicant-1846ec0341efacef7f90012ff64bae440fa12f1c.zip
vendor_replicant-1846ec0341efacef7f90012ff64bae440fa12f1c.tar.gz
vendor_replicant-1846ec0341efacef7f90012ff64bae440fa12f1c.tar.bz2
http_prebuilt: Implement archive of artifacts
* checksum will be downloaded and asserted to prevent a redownload every clean * Archives will exist (invisibly) at vendor/cm/prebuilt/archive Change-Id: I637e86cacd146d665044a119885900dc4660e22b Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
-rw-r--r--.gitignore1
-rw-r--r--build/core/http_prebuilt.mk59
-rwxr-xr-xbuild/tasks/http_curl_prebuilt.sh6
-rw-r--r--gello/Android.mk5
4 files changed, 67 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index f5b82f3..931ce07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
proprietary/*
+prebuilt/archive
diff --git a/build/core/http_prebuilt.mk b/build/core/http_prebuilt.mk
index 805b9f0..9dc3975 100644
--- a/build/core/http_prebuilt.mk
+++ b/build/core/http_prebuilt.mk
@@ -21,12 +21,67 @@ ifeq ($(strip $(LOCAL_HTTP_FILENAME)),)
$(error LOCAL_HTTP_FILENAME not defined.)
endif
+ifeq ($(strip $(LOCAL_HTTP_MD5SUM)),)
+ $(error LOCAL_HTTP_MD5SUM not defined.)
+endif
+
+PREBUILT_MODULE_ARCHIVE := vendor/cm/prebuilt/archive/$(LOCAL_MODULE)
+
+PREBUILT_MODULE_FILE := $(PREBUILT_MODULE_ARCHIVE)/$(LOCAL_HTTP_FILENAME)
+
+PREBUILT_MODULE_MD5SUM := $(PREBUILT_MODULE_ARCHIVE)/md5sum
+
+HTTP_FILE_URL := $(LOCAL_HTTP_PATH)/$(LOCAL_HTTP_FILENAME)
+HTTP_FILE_MD5_URL := $(LOCAL_HTTP_PATH)/$(LOCAL_HTTP_MD5SUM)
+
LOCAL_PREBUILT_MODULE_FILE := $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),,COMMON)/$(LOCAL_HTTP_FILENAME)
$(LOCAL_PREBUILT_MODULE_FILE): filename := $(LOCAL_HTTP_FILENAME)
+$(LOCAL_PREBUILT_MODULE_FILE): checksum := $(PREBUILT_MODULE_MD5SUM)
+$(LOCAL_PREBUILT_MODULE_FILE): filepath := $(PREBUILT_MODULE_FILE)
+$(LOCAL_PREBUILT_MODULE_FILE): version := $(LOCAL_HTTP_FILE_VERSION)
+
+define curl-checksum
+ @echo "Pulling comparison md5sum for $(filename)"
+ $(call download-prebuilt-module, $(HTTP_FILE_MD5_URL),$(checksum))
+endef
+
+define audit-checksum
+ @echo "Downloading: $(filename) (version $(version))" -> $(filepath);
+ $(hide) if [ ! -f $(filepath) ]; then \
+ $(call download-prebuilt-module, $(HTTP_FILE_URL),$(filepath)) \
+ else \
+ if [ "$(shell echo $(md5sum $(filepath)))" != "$(shell cat $(checksum) | cut -d ' ' -f1)" ]; then \
+ rm -rf $(filepath); \
+ $(call download-prebuilt-module, $(HTTP_FILE_URL),$(filepath)) \
+ fi; \
+ fi; \
+ rm -f $(checksum);
+endef
+
+# $(1) url
+# $(2) file output
+define download-prebuilt-module
+ ./vendor/cm/build/tasks/http_curl_prebuilt.sh $(1) $(2);
+endef
+
+define cleanup
+ @echo "Copying: $(filename) -> $(dir $@)"
+ $(hide) mkdir -p $(dir $@)
+ $(hide) cp $(filepath) $(dir $@)/$(filename)
+endef
$(LOCAL_PREBUILT_MODULE_FILE):
- $(hide) curl -L $(LOCAL_HTTP_PATH) --create-dirs -o $(dir $@)/$(filename) --compressed -H "Accept-Encoding: gzip,deflate,sdch"
- @echo "Download: $@"
+ $(call curl-checksum)
+ $(call audit-checksum)
+ $(call cleanup)
include $(BUILD_PREBUILT)
+
+# the "fetchprebuilts" target will go through and pre-download all of the maven dependencies in the tree
+fetchprebuilts: $(LOCAL_PREBUILT_MODULE_FILE)
+
+# the "nukeprebuilts" target will evict all archived artifacts
+nukeprebuilts:
+ @echo "Removing artifact for $(LOCAL_HTTP_FILENAME)"
+ $(hide) rm -rf $(PREBUILT_MODULE_ARCHIVE)
diff --git a/build/tasks/http_curl_prebuilt.sh b/build/tasks/http_curl_prebuilt.sh
new file mode 100755
index 0000000..c90c35f
--- /dev/null
+++ b/build/tasks/http_curl_prebuilt.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+url=$1
+output=$2
+
+curl -L "$url" --create-dirs -o $output --compressed -H "Accept-Encoding: gzip,deflate,sdch" && exit 0 || exit 1
diff --git a/gello/Android.mk b/gello/Android.mk
index 62e6aa6..a88c42a 100644
--- a/gello/Android.mk
+++ b/gello/Android.mk
@@ -42,9 +42,10 @@ LOCAL_MODULE_TAGS := optional
LOCAL_BUILT_MODULE_STEM := package.apk
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
-LOCAL_GELLO_VERSION := 40
-LOCAL_HTTP_PATH := https://github.com/LineageOS/android_packages_apps_Gello/releases/download/$(LOCAL_GELLO_VERSION)/gello.apk
+LOCAL_HTTP_FILE_VERSION := 40
+LOCAL_HTTP_PATH := https://github.com/LineageOS/android_packages_apps_Gello/releases/download/$(LOCAL_HTTP_FILE_VERSION)
LOCAL_HTTP_FILENAME := gello.apk
+LOCAL_HTTP_MD5SUM := $(LOCAL_HTTP_FILENAME).md5sum
include $(BUILD_HTTP_PREBUILT)
endif