Commit 66792510 authored by Brandon McAnsh's avatar Brandon McAnsh Committed by Dan Pasanen

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: 's avatarBrandon McAnsh <brandon.mcansh@gmail.com>
parent 8945f5e8
proprietary/*
prebuilt/archive
......@@ -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)
#!/bin/bash
url=$1
output=$2
curl -L "$url" --create-dirs -o $output --compressed -H "Accept-Encoding: gzip,deflate,sdch" && exit 0 || exit 1
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment