Add fetch_debs target to get prebuilt debs from x20 cache.
* Don't cache aiy*.deb
* Decreases total build time by over 2 hrs vs building all.
Usage from clean env:
Build with cached debs:
m fetch_debs
m
Build all including debs:
ROOTFS_FETCH_DEBS=false m
Push debs to cache (make sure they're all OK first):
ROOTFS_FETCH_DEBS=false m
ROOTFS_PUSH_DEBS=true m push_debs
Change-Id: I4a79b3d2d5643c050851f7e5cf8ab5977f076dc2
diff --git a/preamble.mk b/preamble.mk
index 03bb11a..bcc13fb 100644
--- a/preamble.mk
+++ b/preamble.mk
@@ -114,3 +114,5 @@
/google/data/ro/teams/spacepark/enterprise/kokoro/prod/spacepark/enterprise/rootfs
PREBUILT_DOCKER_ROOT ?= /google/data/ro/teams/spacepark/enterprise/kokoro/prod/spacepark/enterprise/docker
+
+DEBCACHE_ROOT ?= /google/data/rw/teams/spacepark/enterprise/kokoro/prod/spacepark/enterprise/debcache
diff --git a/rootfs.mk b/rootfs.mk
index d731bf1..29f0042 100644
--- a/rootfs.mk
+++ b/rootfs.mk
@@ -11,6 +11,8 @@
ROOTFS_FETCH_TARBALL ?= true
ROOTFS_REVISION ?= latest
+ROOTFS_PUSH_DEBS ?= false
+
USER_GROUPS := \
adm \
audio \
@@ -117,6 +119,21 @@
$(PRODUCT_OUT)/rootfs.img: $(HOST_OUT)/bin/img2simg $(ROOTFS_PATCHED_IMG)
$(HOST_OUT)/bin/img2simg $(ROOTFS_PATCHED_IMG) $(PRODUCT_OUT)/rootfs.img
+fetch_debs:
+ $(info Fetching debs from cache...)
+ mkdir -p $(PRODUCT_OUT)
+ rsync -rv $(DEBCACHE_ROOT)/ $(PRODUCT_OUT)/
+ find $(PRODUCT_OUT) -name *.deb | xargs touch -d "-1337 days ago"
+
+ifeq ($(ROOTFS_PUSH_DEBS),true)
+push_debs:
+ $(info Pushing debs to cache...)
+ rsync -rvm --exclude="aiy*.deb" --include="*.deb" --include="*/" --exclude="*" $(PRODUCT_OUT)/ $(DEBCACHE_ROOT)/
+else
+push_debs:
+ $(error Pushing debs to cache disabled)
+endif
+
clean::
if mount |grep -q $(ROOTFS_DIR); then sudo umount -R $(ROOTFS_DIR); fi
if [[ -d $(ROOTFS_DIR) ]]; then rmdir $(ROOTFS_DIR); fi
@@ -125,4 +142,4 @@
targets::
@echo "rootfs - runs debootstrap to build the rootfs tree"
-.PHONY:: rootfs rootfs_raw gpu firmware adjustments
+.PHONY:: rootfs rootfs_raw gpu firmware adjustments fetch_debs push_debs