Browse Source

http_prebuilt: Implement archive of artifacts

* checksum will be downloaded and asserted to prevent a
    redownload every clean
* Archives will exist (invisibly) at vendor/aokp/prebuilt/archive

Change-Id: I637e86cacd146d665044a119885900dc4660e22b
Signed-off-by: Brandon McAnsh <brandon.mcansh@gmail.com>
Brandon McAnsh 3 years ago
parent
commit
13e4859483
4 changed files with 68 additions and 4 deletions
  1. 2
    0
      .gitignore
  2. 57
    2
      build/core/http_prebuilt.mk
  3. 6
    0
      build/tasks/http_curl_prebuilt.sh
  4. 3
    2
      gello/Android.mk

+ 2
- 0
.gitignore View File

@@ -1,3 +1,5 @@
1 1
 bot/
2 2
 resources/
3 3
 .DS_Store
4
+proprietary/*
5
+prebuilt/archive

+ 57
- 2
build/core/http_prebuilt.mk View File

@@ -21,12 +21,67 @@ ifeq ($(strip $(LOCAL_HTTP_FILENAME)),)
21 21
   $(error LOCAL_HTTP_FILENAME not defined.)
22 22
 endif
23 23
 
24
+ifeq ($(strip $(LOCAL_HTTP_MD5SUM)),)
25
+  $(error LOCAL_HTTP_MD5SUM not defined.)
26
+endif
27
+
28
+PREBUILT_MODULE_ARCHIVE := vendor/aokp/prebuilt/archive/$(LOCAL_MODULE)
29
+
30
+PREBUILT_MODULE_FILE := $(PREBUILT_MODULE_ARCHIVE)/$(LOCAL_HTTP_FILENAME)
31
+
32
+PREBUILT_MODULE_MD5SUM := $(PREBUILT_MODULE_ARCHIVE)/md5sum
33
+
34
+HTTP_FILE_URL := $(LOCAL_HTTP_PATH)/$(LOCAL_HTTP_FILENAME)
35
+HTTP_FILE_MD5_URL := $(LOCAL_HTTP_PATH)/$(LOCAL_HTTP_MD5SUM)
36
+
24 37
 LOCAL_PREBUILT_MODULE_FILE := $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),,COMMON)/$(LOCAL_HTTP_FILENAME)
25 38
 
26 39
 $(LOCAL_PREBUILT_MODULE_FILE): filename := $(LOCAL_HTTP_FILENAME)
40
+$(LOCAL_PREBUILT_MODULE_FILE): checksum := $(PREBUILT_MODULE_MD5SUM)
41
+$(LOCAL_PREBUILT_MODULE_FILE): filepath := $(PREBUILT_MODULE_FILE)
42
+$(LOCAL_PREBUILT_MODULE_FILE): version  := $(LOCAL_HTTP_FILE_VERSION)
43
+
44
+define curl-checksum
45
+  @echo "Pulling comparison md5sum for $(filename)"
46
+  $(call download-prebuilt-module, $(HTTP_FILE_MD5_URL),$(checksum))
47
+endef
48
+
49
+define audit-checksum
50
+  @echo "Downloading: $(filename) (version $(version))" -> $(filepath);
51
+  $(hide) if [ ! -f $(filepath) ]; then \
52
+            $(call download-prebuilt-module, $(HTTP_FILE_URL),$(filepath)) \
53
+          else \
54
+            if [ "$(shell echo $(md5sum $(filepath)))" != "$(shell cat $(checksum) | cut -d ' ' -f1)" ]; then \
55
+              rm -rf $(filepath); \
56
+              $(call download-prebuilt-module, $(HTTP_FILE_URL),$(filepath)) \
57
+            fi; \
58
+          fi; \
59
+          rm -f $(checksum);
60
+endef
61
+
62
+# $(1) url
63
+# $(2) file output
64
+define download-prebuilt-module
65
+  ./vendor/aokp/build/tasks/http_curl_prebuilt.sh $(1) $(2);
66
+endef
67
+
68
+define cleanup
69
+  @echo "Copying: $(filename) -> $(dir $@)"
70
+  $(hide) mkdir -p $(dir $@)
71
+  $(hide) cp $(filepath) $(dir $@)/$(filename)
72
+endef
27 73
 
28 74
 $(LOCAL_PREBUILT_MODULE_FILE):
29
-	$(hide) curl -L $(LOCAL_HTTP_PATH) --create-dirs -o $(dir $@)/$(filename) --compressed -H "Accept-Encoding: gzip,deflate,sdch"
30
-	@echo "Download: $@"
75
+	$(call curl-checksum)
76
+	$(call audit-checksum)
77
+	$(call cleanup)
31 78
 
32 79
 include $(BUILD_PREBUILT)
80
+
81
+# the "fetchprebuilts" target will go through and pre-download all of the maven dependencies in the tree
82
+fetchprebuilts: $(LOCAL_PREBUILT_MODULE_FILE)
83
+
84
+# the "nukeprebuilts" target will evict all archived artifacts
85
+nukeprebuilts:
86
+	  @echo "Removing artifact for $(LOCAL_HTTP_FILENAME)"
87
+	  $(hide) rm -rf $(PREBUILT_MODULE_ARCHIVE)

+ 6
- 0
build/tasks/http_curl_prebuilt.sh View File

@@ -0,0 +1,6 @@
1
+#!/bin/bash
2
+
3
+url=$1
4
+output=$2
5
+
6
+curl -L "$url" --create-dirs -o $output --compressed -H "Accept-Encoding: gzip,deflate,sdch" && exit 0 || exit 1

+ 3
- 2
gello/Android.mk View File

@@ -42,9 +42,10 @@ LOCAL_MODULE_TAGS := optional
42 42
 LOCAL_BUILT_MODULE_STEM := package.apk
43 43
 LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
44 44
 
45
-LOCAL_GELLO_VERSION := 40
46
-LOCAL_HTTP_PATH := https://github.com/LineageOS/android_packages_apps_Gello/releases/download/$(LOCAL_GELLO_VERSION)/gello.apk
45
+LOCAL_HTTP_FILE_VERSION := 40
46
+LOCAL_HTTP_PATH := https://github.com/LineageOS/android_packages_apps_Gello/releases/download/$(LOCAL_HTTP_FILE_VERSION)
47 47
 LOCAL_HTTP_FILENAME := gello.apk
48
+LOCAL_HTTP_MD5SUM := $(LOCAL_HTTP_FILENAME).md5sum
48 49
 
49 50
 include $(BUILD_HTTP_PREBUILT)
50 51
 endif