Add GPU drivers and Weston

- Import wayland-protocols and weston debian packaging files from
upstream, and tweak to work with the -imx trees
- Add configuration for an arm64 docker container to build weston in
- Make the rootfs dependent on
imx-gpu-viv/wayland-protocols-imx/weston-imx deb packages
- Swap xorg for xwayland in the rootfs, and add a few extra packages

Change-Id: I0be6a6f6f86d619ae4475653a46af3376c1a8b1f
diff --git a/Dockerfile.arm64 b/Dockerfile.arm64
new file mode 100644
index 0000000..60387ae
--- /dev/null
+++ b/Dockerfile.arm64
@@ -0,0 +1,24 @@
+FROM arm64v8/debian:9.4
+MAINTAINER support-aiyprojects@google.com
+COPY qemu-aarch64-static /usr/bin
+RUN apt-get update && apt-get install -y \
+    automake \
+    debhelper \
+    dpkg-dev \
+    libcairo2-dev \
+    libdrm-dev \
+    libegl1-mesa-dev \
+    libgbm-dev \
+    libgles2-mesa-dev \
+    libinput-dev \
+    libpam-dev \
+    libtool \
+    libudev-dev \
+    libwayland-dev \
+    libx11-xcb-dev \
+    libxcb-composite0-dev \
+    libxcb-xfixes0-dev \
+    libxcb1-dev \
+    libxcursor-dev \
+    libxkbcommon-dev \
+    pkg-config
diff --git a/kokoro/continuous.cfg b/kokoro/continuous.cfg
index 03ee270..17feb1e 100644
--- a/kokoro/continuous.cfg
+++ b/kokoro/continuous.cfg
@@ -4,6 +4,7 @@
 gfile_resources: "/x20/teams/spacepark/enterprise/kokoro/prod/spacepark/enterprise/rootfs/latest/rootfs.raw.img"
 gfile_resources: "/x20/teams/spacepark/enterprise/kokoro/prod/spacepark/enterprise/rootfs/latest/rootfs.raw.img.sha256sum"
 gfile_resources: "/x20/teams/spacepark/enterprise/kokoro/prod/spacepark/enterprise/debs/apex.deb"
+gfile_resources: "/x20/teams/spacepark/enterprise/kokoro/prod/spacepark/enterprise/docker/arm64-builder.tar"
 action {
   define_artifacts {
     regex: "boot.img"
diff --git a/kokoro/continuous.sh b/kokoro/continuous.sh
index 835ba4e..8d3a3ad 100644
--- a/kokoro/continuous.sh
+++ b/kokoro/continuous.sh
@@ -14,6 +14,7 @@
 
 export TARBALL_FETCH_ROOT_DIRECTORY=${KOKORO_GFILE_DIR}
 export PREBUILT_MODULES_ROOT=${KOKORO_GFILE_DIR}
+export PREBUILT_DOCKER_ROOT=${KOKORO_GFILE_DIR}
 export DEBOOTSTRAP_TARBALL_REVISION=.
 export ROOTFS_REVISION=.
 
@@ -32,4 +33,4 @@
 cp ${PRODUCT_OUT}/boot.img ${KOKORO_ARTIFACTS_DIR}
 cp ${PRODUCT_OUT}/partition-table.img ${KOKORO_ARTIFACTS_DIR}
 cp ${PRODUCT_OUT}/rootfs.img ${KOKORO_ARTIFACTS_DIR}
-cp ${PRODUCT_OUT}/sdcard.img ${KOKORO_ARTIFACTS_DIR}
\ No newline at end of file
+cp ${PRODUCT_OUT}/sdcard.img ${KOKORO_ARTIFACTS_DIR}
diff --git a/permissions.txt b/permissions.txt
index a42da31..e4f3d2b 100644
--- a/permissions.txt
+++ b/permissions.txt
@@ -19,172 +19,3 @@
 etc/locale.gen                                                       -       root    root    0644
 etc/passwd                                                           -       root    root    0644
 etc/shadow                                                           -       root    root    0600
-
-## Vivante drivers from the imx-gpu-viv-6.2.4.p0.2-aarch64.bin sharfile #########################
-# TODO(jtgans): Make these modes actually reflect file vs. library vs. directory
-
-etc/Vivante.icd                                                      -       root    root    0644
-opt/                                                                 recurse root    root    0755
-usr/                                                                 -       root    root    0755
-usr/bin/                                                             -       root    root    0755
-usr/bin/gmem_info                                                    -       root    root    0755
-usr/include/                                                         -       root    root    0755
-usr/include/CL/                                                      -       root    root    0755
-usr/include/CL/cl.h                                                  -       root    root    0755
-usr/include/CL/cl.hpp                                                -       root    root    0755
-usr/include/CL/cl_d3d10.h                                            -       root    root    0755
-usr/include/CL/cl_d3d11.h                                            -       root    root    0755
-usr/include/CL/cl_dx9_media_sharing.h                                -       root    root    0755
-usr/include/CL/cl_egl.h                                              -       root    root    0755
-usr/include/CL/cl_ext.h                                              -       root    root    0755
-usr/include/CL/cl_gl.h                                               -       root    root    0755
-usr/include/CL/cl_gl_ext.h                                           -       root    root    0755
-usr/include/CL/cl_platform.h                                         -       root    root    0755
-usr/include/CL/cl_viv_vx_ext.h                                       -       root    root    0755
-usr/include/CL/opencl.h                                              -       root    root    0755
-usr/include/EGL/                                                     -       root    root    0755
-usr/include/EGL/egl.h                                                -       root    root    0755
-usr/include/EGL/eglext.h                                             -       root    root    0755
-usr/include/EGL/eglplatform.h                                        -       root    root    0755
-usr/include/EGL/eglvivante.h                                         -       root    root    0755
-usr/include/GL/                                                      -       root    root    0755
-usr/include/GL/gl.h                                                  -       root    root    0755
-usr/include/GL/glext.h                                               -       root    root    0755
-usr/include/GL/glx.h                                                 -       root    root    0755
-usr/include/GL/glxext.h                                              -       root    root    0755
-usr/include/GLES/                                                    -       root    root    0755
-usr/include/GLES/egl.h                                               -       root    root    0755
-usr/include/GLES/gl.h                                                -       root    root    0755
-usr/include/GLES/glext.h                                             -       root    root    0755
-usr/include/GLES/glplatform.h                                        -       root    root    0755
-usr/include/GLES/glrename.h                                          -       root    root    0755
-usr/include/GLES/glunname.h                                          -       root    root    0755
-usr/include/GLES2/                                                   -       root    root    0755
-usr/include/GLES2/gl2.h                                              -       root    root    0755
-usr/include/GLES2/gl2ext.h                                           -       root    root    0755
-usr/include/GLES2/gl2platform.h                                      -       root    root    0755
-usr/include/GLES2/gl2rename.h                                        -       root    root    0755
-usr/include/GLES2/gl2unname.h                                        -       root    root    0755
-usr/include/GLES3/                                                   -       root    root    0755
-usr/include/GLES3/gl3.h                                              -       root    root    0755
-usr/include/GLES3/gl31.h                                             -       root    root    0755
-usr/include/GLES3/gl32.h                                             -       root    root    0755
-usr/include/GLES3/gl3ext.h                                           -       root    root    0755
-usr/include/GLES3/gl3platform.h                                      -       root    root    0755
-usr/include/GLES3/gl3rename.h                                        -       root    root    0755
-usr/include/GLES3/gl3unname.h                                        -       root    root    0755
-usr/include/HAL/                                                     -       root    root    0755
-usr/include/HAL/aqHal.h                                              -       root    root    0755
-usr/include/HAL/gc_hal.h                                             -       root    root    0755
-usr/include/HAL/gc_hal_base.h                                        -       root    root    0755
-usr/include/HAL/gc_hal_driver.h                                      -       root    root    0755
-usr/include/HAL/gc_hal_driver_vg.h                                   -       root    root    0755
-usr/include/HAL/gc_hal_dump.h                                        -       root    root    0755
-usr/include/HAL/gc_hal_engine.h                                      -       root    root    0755
-usr/include/HAL/gc_hal_engine_vg.h                                   -       root    root    0755
-usr/include/HAL/gc_hal_enum.h                                        -       root    root    0755
-usr/include/HAL/gc_hal_options.h                                     -       root    root    0755
-usr/include/HAL/gc_hal_profiler.h                                    -       root    root    0755
-usr/include/HAL/gc_hal_raster.h                                      -       root    root    0755
-usr/include/HAL/gc_hal_rename.h                                      -       root    root    0755
-usr/include/HAL/gc_hal_statistics.h                                  -       root    root    0755
-usr/include/HAL/gc_hal_types.h                                       -       root    root    0755
-usr/include/HAL/gc_hal_version.h                                     -       root    root    0755
-usr/include/HAL/gc_hal_vg.h                                          -       root    root    0755
-usr/include/KHR/                                                     -       root    root    0755
-usr/include/KHR/khrplatform.h                                        -       root    root    0755
-usr/include/VG/                                                      -       root    root    0755
-usr/include/VG/openvg.h                                              -       root    root    0755
-usr/include/VG/vgext.h                                               -       root    root    0755
-usr/include/VG/vgplatform.h                                          -       root    root    0755
-usr/include/VG/vgrename.h                                            -       root    root    0755
-usr/include/VG/vgu.h                                                 -       root    root    0755
-usr/include/VX/                                                      -       root    root    0755
-usr/include/VX/vx.h                                                  -       root    root    0755
-usr/include/VX/vx_api.h                                              -       root    root    0755
-usr/include/VX/vx_compatibility.h                                    -       root    root    0755
-usr/include/VX/vx_ext_program.h                                      -       root    root    0755
-usr/include/VX/vx_ext_target.h                                       -       root    root    0755
-usr/include/VX/vx_helper.h                                           -       root    root    0755
-usr/include/VX/vx_kernels.h                                          -       root    root    0755
-usr/include/VX/vx_khr_cnn.h                                          -       root    root    0755
-usr/include/VX/vx_khr_dot.h                                          -       root    root    0755
-usr/include/VX/vx_khr_icd.h                                          -       root    root    0755
-usr/include/VX/vx_khr_interp.h                                       -       root    root    0755
-usr/include/VX/vx_khr_node_memory.h                                  -       root    root    0755
-usr/include/VX/vx_khr_opencl.h                                       -       root    root    0755
-usr/include/VX/vx_khr_tiling.h                                       -       root    root    0755
-usr/include/VX/vx_khr_variants.h                                     -       root    root    0755
-usr/include/VX/vx_khr_xml.h                                          -       root    root    0755
-usr/include/VX/vx_lib_debug.h                                        -       root    root    0755
-usr/include/VX/vx_lib_extras.h                                       -       root    root    0755
-usr/include/VX/vx_lib_xyz.h                                          -       root    root    0755
-usr/include/VX/vx_nodes.h                                            -       root    root    0755
-usr/include/VX/vx_types.h                                            -       root    root    0755
-usr/include/VX/vx_vendors.h                                          -       root    root    0755
-usr/include/VX/vx_viv_cnn.h                                          -       root    root    0755
-usr/include/VX/vxu.h                                                 -       root    root    0755
-usr/include/gbm.h                                                    -       root    root    0755
-usr/include/gc_vdk.h                                                 -       root    root    0755
-usr/include/gc_vdk_types.h                                           -       root    root    0755
-usr/include/vdk.h                                                    -       root    root    0755
-usr/include/vulkan/                                                  -       root    root    0755
-usr/include/vulkan/vk_android_native_buffer.h                        -       root    root    0755
-usr/include/vulkan/vk_icd.h                                          -       root    root    0755
-usr/include/vulkan/vk_layer.h                                        -       root    root    0755
-usr/include/vulkan/vk_platform.h                                     -       root    root    0755
-usr/include/vulkan/vk_sdk_platform.h                                 -       root    root    0755
-usr/include/vulkan/vulkan.h                                          -       root    root    0755
-usr/lib/                                                             -       root    root    0755
-usr/lib/dri/                                                         -       root    root    0755
-usr/lib/dri/vivante_dri.so                                           -       root    root    0755
-usr/lib/gbm_viv.so                                                   -       root    root    0755
-usr/lib/libCLC.so                                                    -       root    root    0755
-usr/lib/libEGL-fb.so                                                 -       root    root    0755
-usr/lib/libEGL-wl.so                                                 -       root    root    0755
-usr/lib/libEGL-x11.so                                                -       root    root    0755
-usr/lib/libGAL-fb.so                                                 -       root    root    0755
-usr/lib/libGAL-wl.so                                                 -       root    root    0755
-usr/lib/libGAL-x11.so                                                -       root    root    0755
-usr/lib/libGL.so                                                     -       root    root    0755
-usr/lib/libGL.so.1                                                   -       root    root    0755
-usr/lib/libGL.so.1.2                                                 -       root    root    0755
-usr/lib/libGLES_CL.so.1.1.0                                          -       root    root    0755
-usr/lib/libGLES_CM.so.1.1.0                                          -       root    root    0755
-usr/lib/libGLESv1_CL.so.1.1.0                                        -       root    root    0755
-usr/lib/libGLESv1_CM.so.1.1.0                                        -       root    root    0755
-usr/lib/libGLESv2-fb.so                                              -       root    root    0755
-usr/lib/libGLESv2-wl.so                                              -       root    root    0755
-usr/lib/libGLESv2-x11.so                                             -       root    root    0755
-usr/lib/libGLSLC.so                                                  -       root    root    0755
-usr/lib/libLLVM_viv.so                                               -       root    root    0755
-usr/lib/libOpenCL.so                                                 -       root    root    0755
-usr/lib/libOpenVG.2d.so                                              -       root    root    0755
-usr/lib/libOpenVG.3d.so                                              -       root    root    0755
-usr/lib/libOpenVG.so                                                 -       root    root    0755
-usr/lib/libOpenVX.so                                                 -       root    root    0755
-usr/lib/libOpenVXU.so                                                -       root    root    0755
-usr/lib/libSPIRV_viv.so                                              -       root    root    0755
-usr/lib/libVDK-fb.so                                                 -       root    root    0755
-usr/lib/libVDK-wl.so                                                 -       root    root    0755
-usr/lib/libVDK-x11.so                                                -       root    root    0755
-usr/lib/libVSC.so                                                    -       root    root    0755
-usr/lib/libVivanteOpenCL.so                                          -       root    root    0755
-usr/lib/libgbm.so                                                    -       root    root    0755
-usr/lib/libvulkan-fb.so                                              -       root    root    0755
-usr/lib/libvulkan-wl.so                                              -       root    root    0755
-usr/lib/libvulkan-x11.so                                             -       root    root    0755
-usr/lib/pkgconfig/                                                   -       root    root    0755
-usr/lib/pkgconfig/egl.pc                                             -       root    root    0755
-usr/lib/pkgconfig/egl_linuxfb.pc                                     -       root    root    0755
-usr/lib/pkgconfig/egl_wayland.pc                                     -       root    root    0755
-usr/lib/pkgconfig/egl_x11.pc                                         -       root    root    0755
-usr/lib/pkgconfig/gbm.pc                                             -       root    root    0755
-usr/lib/pkgconfig/gl_x11.pc                                          -       root    root    0755
-usr/lib/pkgconfig/glesv1_cm.pc                                       -       root    root    0755
-usr/lib/pkgconfig/glesv1_cm_x11.pc                                   -       root    root    0755
-usr/lib/pkgconfig/glesv2.pc                                          -       root    root    0755
-usr/lib/pkgconfig/glesv2_x11.pc                                      -       root    root    0755
-usr/lib/pkgconfig/vg.pc                                              -       root    root    0755
-usr/lib/pkgconfig/vg_x11.pc                                          -       root    root    0755
-usr/lib/pkgconfig/wayland-egl.pc                                     -       root    root    0755
diff --git a/preamble.mk b/preamble.mk
index 33c292c..42e9da1 100644
--- a/preamble.mk
+++ b/preamble.mk
@@ -17,6 +17,7 @@
 	alsa-utils \
 	apt-listchanges \
 	apt-utils \
+	aptitude \
 	avahi-daemon \
 	bash-completion \
 	bluez \
@@ -44,14 +45,18 @@
 	iputils-ping \
 	isc-dhcp-client \
 	isc-dhcp-common \
+	kbd \
 	krb5-locales \
 	less \
 	libc++1 \
 	libc++abi1 \
 	libclass-isa-perl \
+	libinput10 \
 	liblockfile-bin \
 	libpam-systemd \
 	libswitch-perl \
+	libxcb-composite0 \
+	libxcb-shape0 \
 	locales \
 	logrotate \
 	lrzsz \
@@ -91,9 +96,8 @@
 	whiptail \
 	wireless-tools \
 	wpasupplicant \
-	xorg \
-	xserver-xorg-input-all \
-	xserver-xorg-video-all
+	xdg-user-dirs \
+	xwayland
 
 DEBOOTSTRAP_ARGS := \
 		--arch=arm64 \
diff --git a/rootfs.mk b/rootfs.mk
index 1accb7f..e80b117 100644
--- a/rootfs.mk
+++ b/rootfs.mk
@@ -4,8 +4,15 @@
 
 include $(ROOTDIR)/build/preamble.mk
 
-GPU_VERSION := imx-gpu-viv-6.2.4.p0.2-aarch64
+ARM64_BUILDER_FETCH_TARBALL ?= true
+PREBUILT_DOCKER_ROOT ?= /google/data/ro/teams/spacepark/enterprise/kokoro/prod/spacepark/enterprise/docker
+
+GPU_VERSION := imx-gpu-viv-6.2.4.p1.0-aarch64
 GPU_DIR := $(ROOTDIR)/imx-gpu-viv/$(GPU_VERSION)
+GPU_OUT_DIR := $(PRODUCT_OUT)/obj/GPU
+
+WAYLAND_PROTO_DIR := $(PRODUCT_OUT)/obj/WAYLAND_PROTO
+WESTON_DIR := $(PRODUCT_OUT)/obj/WESTON
 
 ROOTFS_DIR := $(PRODUCT_OUT)/obj/ROOTFS/rootfs
 ROOTFS_RAW_IMG := $(PRODUCT_OUT)/obj/ROOTFS/rootfs.raw.img
@@ -30,11 +37,100 @@
 rootfs: $(PRODUCT_OUT)/rootfs.img
 rootfs_raw: $(ROOTFS_RAW_IMG)
 
-gpu:
-	sudo rsync -rl $(GPU_DIR)/gpu-core/ $(ROOTFS_DIR)
-	sudo rsync -rl $(GPU_DIR)/gpu-demos/ $(ROOTFS_DIR)
-	sudo rsync -rl $(GPU_DIR)/gpu-tools/gmem-info/ $(ROOTFS_DIR)
-	echo "vivante" | sudo tee -a $(ROOTFS_DIR)/etc/modules
+$(PRODUCT_OUT)/wayland-protocols-imx_1.13-0_all.deb:
+	mkdir -p $(WAYLAND_PROTO_DIR)/wayland-protocols-imx-1.13
+	cp -r $(ROOTDIR)/wayland-protocols-imx/* $(WAYLAND_PROTO_DIR)/wayland-protocols-imx-1.13
+	tar -C $(WAYLAND_PROTO_DIR) -cJf $(WAYLAND_PROTO_DIR)/wayland-protocols-imx_1.13.orig.tar.xz wayland-protocols-imx-1.13
+	cp -r $(ROOTDIR)/build/wayland-protocols-imx-debian $(WAYLAND_PROTO_DIR)/wayland-protocols-imx-1.13/debian
+	cd $(WAYLAND_PROTO_DIR)/wayland-protocols-imx-1.13; dpkg-buildpackage -uc -us -tc
+	mv $(WAYLAND_PROTO_DIR)/wayland-protocols-imx_1.13-0_all.deb $(PRODUCT_OUT)
+
+ifeq ($(ARM64_BUILDER_FETCH_TARBALL),true)
+$(ROOTDIR)/cache/arm64-builder.tar: $(PREBUILT_DOCKER_ROOT)/arm64-builder.tar
+	mkdir -p $(ROOTDIR)/cache
+	cp $< $(ROOTDIR)/cache
+else
+$(ROOTDIR)/cache/arm64-builder.tar:
+	mkdir -p $(ROOTDIR)/cache
+	mkdir -p $(PRODUCT_OUT)/obj/ARM64_BUILDER
+	cp $(ROOTDIR)/build/Dockerfile.arm64 $(PRODUCT_OUT)/obj/ARM64_BUILDER/Dockerfile
+	cp $(shell which qemu-aarch64-static) $(PRODUCT_OUT)/obj/ARM64_BUILDER
+	docker build -t arm64-builder $(PRODUCT_OUT)/obj/ARM64_BUILDER
+	docker image save -o $@ arm64-builder:latest
+	docker rmi arm64-builder:latest
+endif
+
+weston: $(PRODUCT_OUT)/weston-imx_3.0.0-0_arm64.deb
+$(PRODUCT_OUT)/weston-imx_3.0.0-0_arm64.deb: $(ROOTDIR)/cache/arm64-builder.tar $(PRODUCT_OUT)/wayland-protocols-imx_1.13-0_all.deb
+	mkdir -p $(WESTON_DIR)/weston-imx-3.0.0
+	cp -r $(ROOTDIR)/weston-imx/* $(WESTON_DIR)/weston-imx-3.0.0
+	mkdir -p $(WESTON_DIR)/weston-imx-3.0.0/etc/systemd/system
+	cp $(ROOTDIR)/build/weston.service $(WESTON_DIR)/weston-imx-3.0.0/etc/systemd/system
+	tar -C $(WESTON_DIR) -cJf $(WESTON_DIR)/weston-imx_3.0.0.orig.tar.xz weston-imx-3.0.0
+	cp -r $(ROOTDIR)/build/weston-imx-debian $(WESTON_DIR)/weston-imx-3.0.0/debian
+	docker load -i $(ROOTDIR)/cache/arm64-builder.tar
+	docker run --rm --privileged --tty \
+	  -v $(PRODUCT_OUT):/out \
+	  -v $(WESTON_DIR):/weston arm64-builder \
+	  /bin/bash -c 'dpkg -i /out/wayland-protocols-imx_1.13-0_all.deb; \
+		cd /weston/weston-imx-3.0.0; dpkg-buildpackage -uc -us -tc'
+	mv $(WESTON_DIR)/weston-imx_3.0.0-0_arm64.deb $(PRODUCT_OUT)
+
+$(PRODUCT_OUT)/imx-gpu-viv_6.2.4_arm64.deb:
+	mkdir -p $(GPU_OUT_DIR)
+	mkdir -p $(GPU_OUT_DIR)/usr
+	mkdir -p $(GPU_OUT_DIR)/usr/bin
+	mkdir -p $(GPU_OUT_DIR)/usr/lib
+	mkdir -p $(GPU_OUT_DIR)/usr/lib/dri
+	mkdir -p $(GPU_OUT_DIR)/usr/lib/pkgconfig
+	mkdir -p $(GPU_OUT_DIR)/usr/lib/vulkan
+	mkdir -p $(GPU_OUT_DIR)/usr/include
+
+	cp -P $(GPU_DIR)/gpu-core/usr/lib/*.so* $(GPU_OUT_DIR)/usr/lib/
+	cp -r $(GPU_DIR)/gpu-core/usr/include/* $(GPU_OUT_DIR)/usr/include/
+	cp -r $(GPU_DIR)/gpu-demos/opt $(GPU_OUT_DIR)
+	cp -r $(GPU_DIR)/gpu-tools/gmem-info/usr/bin/* $(GPU_OUT_DIR)/usr/bin
+
+	cp $(GPU_DIR)/gpu-core/usr/lib/pkgconfig/egl_wayland.pc $(GPU_OUT_DIR)/usr/lib/pkgconfig/egl.pc
+	cp $(GPU_DIR)/gpu-core/usr/lib/pkgconfig/glesv1_cm.pc $(GPU_OUT_DIR)/usr/lib/pkgconfig
+	cp $(GPU_DIR)/gpu-core/usr/lib/pkgconfig/glesv2.pc $(GPU_OUT_DIR)/usr/lib/pkgconfig
+	cp $(GPU_DIR)/gpu-core/usr/lib/pkgconfig/vg.pc $(GPU_OUT_DIR)/usr/lib/pkgconfig
+	cp $(GPU_DIR)/gpu-core/usr/lib/pkgconfig/wayland-egl.pc $(GPU_OUT_DIR)/usr/lib/pkgconfig
+	cp $(GPU_DIR)/gpu-core/usr/lib/pkgconfig/gbm.pc $(GPU_OUT_DIR)/usr/lib/pkgconfig
+
+	cp -r $(GPU_DIR)/gpu-core/usr/lib/dri $(GPU_OUT_DIR)/usr/lib
+
+	mv $(GPU_OUT_DIR)/usr/lib/libGL.so.1.2 $(GPU_OUT_DIR)/usr/lib/libGL.so.1.2.0
+	ln -sf libGL.so.1.2.0 $(GPU_OUT_DIR)/usr/lib/libGL.so.1.2
+	ln -sf libGL.so.1.2 $(GPU_OUT_DIR)/usr/lib/libGL.so.1
+	ln -sf libGL.so.1 $(GPU_OUT_DIR)/usr/lib/libGL.so
+
+	mv $(GPU_OUT_DIR)/usr/lib/libEGL-wl.so $(GPU_OUT_DIR)/usr/lib/libEGL.so.1.0
+	ln -sf libEGL.so.1.0 $(GPU_OUT_DIR)/usr/lib/libEGL.so.1
+	ln -sf libEGL.so.1 $(GPU_OUT_DIR)/usr/lib/libEGL.so
+
+	mv $(GPU_OUT_DIR)/usr/lib/libGAL-wl.so $(GPU_OUT_DIR)/usr/lib/libGAL.so
+	mv $(GPU_OUT_DIR)/usr/lib/libVDK-wl.so $(GPU_OUT_DIR)/usr/lib/libVDK.so
+
+	rm -rf $(GPU_OUT_DIR)/usr/lib/libGLESv2*
+	cp $(GPU_DIR)/gpu-core/usr/lib/libGLESv2-wl.so $(GPU_OUT_DIR)/usr/lib/libGLESv2.so.2.0.0
+	ln -sf libGLESv2.so.2.0.0 $(GPU_OUT_DIR)/usr/lib/libGLESv2.so.2.0
+	ln -sf libGLESv2.so.2.0 $(GPU_OUT_DIR)/usr/lib/libGLESv2.so.2
+	ln -sf libGLESv2.so.2 $(GPU_OUT_DIR)/usr/lib/libGLESv2.so
+
+	mv $(GPU_OUT_DIR)/usr/lib/libvulkan-wl.so $(GPU_OUT_DIR)/usr/lib/vulkan/libvulkan_VSI.so
+
+	rm -rf $(GPU_OUT_DIR)/usr/lib/*-wl.so
+	rm -rf $(GPU_OUT_DIR)/usr/lib/*-fb.so
+	rm -rf $(GPU_OUT_DIR)/usr/lib/*-x11.so
+
+	rm -f $(GPU_OUT_DIR)/usr/lib/libOpenVG.so
+	ln -sf libOpenVG.3d.so $(GPU_OUT_DIR)/usr/lib/libOpenVG.so
+
+	cp -r $(ROOTDIR)/imx-gpu-viv/debian $(GPU_OUT_DIR)
+	cd $(GPU_OUT_DIR); dpkg-buildpackage -aarm64 -b -rfakeroot -us -uc -tc
+
+	mv $(GPU_OUT_DIR)/../imx-gpu-viv_6.2.4_arm64.deb $(PRODUCT_OUT)
 
 firmware:
 	sudo mkdir -p $(ROOTFS_DIR)/lib/firmware
@@ -93,6 +189,9 @@
 $(ROOTFS_PATCHED_IMG): $(ROOTFS_RAW_IMG) \
                        $(ROOTDIR)/build/boot.mk \
                        $(PRODUCT_OUT)/linux-image-4.9.51-aiy_1_arm64.deb \
+                       $(PRODUCT_OUT)/wayland-protocols-imx_1.13-0_all.deb \
+                       $(PRODUCT_OUT)/weston-imx_3.0.0-0_arm64.deb \
+                       $(PRODUCT_OUT)/imx-gpu-viv_6.2.4_arm64.deb \
                        | $(PRODUCT_OUT)/boot.img \
                          modules \
                          packages
@@ -103,13 +202,12 @@
 	sudo mount -o loop $(ROOTFS_PATCHED_IMG) $(ROOTFS_DIR)
 	sudo mount -o loop $(PRODUCT_OUT)/boot.img $(ROOTFS_DIR)/boot
 
-	+make -f $(ROOTDIR)/build/rootfs.mk gpu
 	+make -f $(ROOTDIR)/build/rootfs.mk firmware
 	+make -f $(ROOTDIR)/build/rootfs.mk adjustments
 
 	sudo cp $(PRODUCT_OUT)/*.deb $(ROOTFS_DIR)/root/
 	sudo cp $(ROOTDIR)/build/fstab.emmc $(ROOTFS_DIR)/etc/fstab
-	sudo chroot $(ROOTFS_DIR) bash -c 'dpkg -i /root/*.deb'
+	sudo chroot $(ROOTFS_DIR) bash -c 'apt-get install --no-install-recommends -y /root/*.deb'
 	sudo rm -rf $(ROOTFS_DIR)/root/*.deb
 
 	sudo umount $(ROOTFS_DIR)/boot
diff --git a/wayland-protocols-imx-debian/changelog b/wayland-protocols-imx-debian/changelog
new file mode 100644
index 0000000..fa9f844
--- /dev/null
+++ b/wayland-protocols-imx-debian/changelog
@@ -0,0 +1,5 @@
+wayland-protocols-imx (1.13-0) unstable; urgency=medium
+
+  * Initial release
+
+ -- AIY Projects <support-aiyprojects@google.com>  Mon, 08 Feb 2016 10:45:53 +0100
diff --git a/wayland-protocols-imx-debian/compat b/wayland-protocols-imx-debian/compat
new file mode 100644
index 0000000..f599e28
--- /dev/null
+++ b/wayland-protocols-imx-debian/compat
@@ -0,0 +1 @@
+10
diff --git a/wayland-protocols-imx-debian/control b/wayland-protocols-imx-debian/control
new file mode 100644
index 0000000..80c39e4
--- /dev/null
+++ b/wayland-protocols-imx-debian/control
@@ -0,0 +1,25 @@
+Source: wayland-protocols-imx
+Section: x11
+Priority: optional
+Maintainer: AIY Projects <support-aiyprojects@google.com>
+Build-Depends:
+ debhelper (>=10),
+ libwayland-dev,
+ pkg-config
+Standards-Version: 4.1.1
+Homepage: http://wayland.freedesktop.org/
+
+Package: wayland-protocols-imx
+Section: libdevel
+Architecture: all
+Priority: extra
+Depends:
+ ${shlibs:Depends},
+ ${misc:Depends}
+Multi-Arch: foreign
+Provides: wayland-protocols
+Description: wayland compositor protocols
+ Wayland protocols that add functionality not available in the Wayland core
+ protocol. Such protocols either add completely new functionality, or extend
+ the functionality of some other protocol either in Wayland core, or some other
+ protocol in wayland-protocols.
diff --git a/wayland-protocols-imx-debian/copyright b/wayland-protocols-imx-debian/copyright
new file mode 100644
index 0000000..4751573
--- /dev/null
+++ b/wayland-protocols-imx-debian/copyright
@@ -0,0 +1,43 @@
+Upstream-Name: wayland-protocols-imx
+Upstream-Contact: wayland-devel@lists.freedesktop.org
+Source: https://wayland.freedesktop.org/releases/
+
+Files: debian/*
+Copyright: © 2016 Héctor Orón Martínez <zumbi@debian.org>
+License: Expat
+
+Files: *
+Copyright: © 2008-2013 Kristian Høgsberg
+		   © 2010-2013 Intel Corporation
+		   © 2013      Rafael Antognolli
+		   © 2013      Jasper St. Pierre
+		   © 2014      Jonas Ådahl
+		   © 2014      Jason Ekstrand
+		   © 2014-2015 Collabora, Ltd.
+		   © 2015      Red Hat Inc.
+License: Expat
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+---
+
+The above is the version of the MIT "Expat" License used by X.org:
+
+    http://cgit.freedesktop.org/xorg/xserver/tree/COPYING
diff --git a/wayland-protocols-imx-debian/rules b/wayland-protocols-imx-debian/rules
new file mode 100755
index 0000000..2d33f6a
--- /dev/null
+++ b/wayland-protocols-imx-debian/rules
@@ -0,0 +1,4 @@
+#!/usr/bin/make -f
+
+%:
+	dh $@
diff --git a/wayland-protocols-imx-debian/source/format b/wayland-protocols-imx-debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/wayland-protocols-imx-debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/weston-imx-debian/changelog b/weston-imx-debian/changelog
new file mode 100644
index 0000000..9b80852
--- /dev/null
+++ b/weston-imx-debian/changelog
@@ -0,0 +1,5 @@
+weston-imx (3.0.0-0) unstable; urgency=medium
+
+  * Initial release
+
+ -- AIY Projects <support-aiyprojects@google.com>  Wed, 04 Jul 2018 10:45:53 -0800
diff --git a/weston-imx-debian/compat b/weston-imx-debian/compat
new file mode 100644
index 0000000..f599e28
--- /dev/null
+++ b/weston-imx-debian/compat
@@ -0,0 +1 @@
+10
diff --git a/weston-imx-debian/control b/weston-imx-debian/control
new file mode 100644
index 0000000..bf98fbd
--- /dev/null
+++ b/weston-imx-debian/control
@@ -0,0 +1,23 @@
+Source: weston-imx
+Section: x11
+Priority: optional
+Maintainer: AIY Projects <support-aiyprojects@google.com>
+Build-Depends:
+ debhelper (>=10),
+ libwayland-dev,
+ pkg-config
+Standards-Version: 4.1.1
+
+Package: weston-imx
+Section: libdevel
+Architecture: arm64
+Priority: extra
+Depends:
+ libinput10,
+ libxcb-shape0,
+ libxcb-composite0,
+ ${shlibs:Depends},
+ ${misc:Depends}
+Multi-Arch: foreign
+Provides: weston
+Description: Weston compositor w/ IMX support.
diff --git a/weston-imx-debian/copyright b/weston-imx-debian/copyright
new file mode 100644
index 0000000..4751573
--- /dev/null
+++ b/weston-imx-debian/copyright
@@ -0,0 +1,43 @@
+Upstream-Name: wayland-protocols-imx
+Upstream-Contact: wayland-devel@lists.freedesktop.org
+Source: https://wayland.freedesktop.org/releases/
+
+Files: debian/*
+Copyright: © 2016 Héctor Orón Martínez <zumbi@debian.org>
+License: Expat
+
+Files: *
+Copyright: © 2008-2013 Kristian Høgsberg
+		   © 2010-2013 Intel Corporation
+		   © 2013      Rafael Antognolli
+		   © 2013      Jasper St. Pierre
+		   © 2014      Jonas Ådahl
+		   © 2014      Jason Ekstrand
+		   © 2014-2015 Collabora, Ltd.
+		   © 2015      Red Hat Inc.
+License: Expat
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+---
+
+The above is the version of the MIT "Expat" License used by X.org:
+
+    http://cgit.freedesktop.org/xorg/xserver/tree/COPYING
diff --git a/weston-imx-debian/rules b/weston-imx-debian/rules
new file mode 100755
index 0000000..e74a8cc
--- /dev/null
+++ b/weston-imx-debian/rules
@@ -0,0 +1,10 @@
+#!/usr/bin/make -f
+
+%:
+	dh $@
+
+override_dh_auto_configure:
+	        dh_auto_configure -- --disable-imxg2d
+
+override_dh_auto_test:
+	true
diff --git a/weston-imx-debian/source/format b/weston-imx-debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/weston-imx-debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/weston-imx-debian/weston-imx.install b/weston-imx-debian/weston-imx.install
new file mode 100644
index 0000000..45bf8b7
--- /dev/null
+++ b/weston-imx-debian/weston-imx.install
@@ -0,0 +1 @@
+etc /
diff --git a/weston.service b/weston.service
new file mode 100644
index 0000000..ba222e5
--- /dev/null
+++ b/weston.service
@@ -0,0 +1,38 @@
+[Unit]
+Description=Weston Wayland Compositor (on tty7)
+RequiresMountsFor=/run
+Conflicts=getty@tty7.service plymouth-quit.service
+After=systemd-user-sessions.service getty@tty7.service plymouth-quit-wait.service
+
+[Service]
+User=root
+PermissionsStartOnly=true
+
+# Log us in via PAM so we get our XDG & co. environment and
+# are treated as logged in so we can use the tty:
+PAMName=login
+
+# Grab tty7
+UtmpIdentifier=tty7
+TTYPath=/dev/tty7
+TTYReset=yes
+TTYVHangup=yes
+TTYVTDisallocate=yes
+
+# stderr to journal so our logging doesn't get thrown into /dev/null
+StandardOutput=tty
+StandardInput=tty
+StandardError=journal
+
+EnvironmentFile=-/etc/default/weston
+
+# Weston does not successfully change VT, nor does systemd place us on
+# the VT it just activated for us. Switch manually:
+ExecStartPre=/bin/chvt 7
+ExecStart=/usr/bin/weston-launch -- --log=/var/log/weston.log --xwayland $OPTARGS
+
+IgnoreSIGPIPE=no
+
+[Install]
+WantedBy=multi-user.target
+