From 3b596e49987beae7359485d7f308bba03ebf1041 Mon Sep 17 00:00:00 2001
From: Brett Parker <iDunno@sommitrealweird.co.uk>
Date: Wed, 18 Jan 2017 12:30:11 +0000
Subject: [PATCH] Only remove devices.tar.gz if it exists

---
 templates/lxc-debian-unprivileged | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/templates/lxc-debian-unprivileged b/templates/lxc-debian-unprivileged
index abb925f..dd7bdaf 100755
--- a/templates/lxc-debian-unprivileged
+++ b/templates/lxc-debian-unprivileged
@@ -315,7 +315,9 @@ keyring_dpkg=$(sed -ne "/^debian-archive-keyring/ { s#.* ##; p; }" "${LXC_ROOTFS
 (cd "${LXC_ROOTFS}" && dpkg-deb -x ".$keyring_dpkg" .)
 
 # replace the tar containing devices with something that doesn't contain any
-(cd "$LXC_ROOTFS/debootstrap" && rm devices.tar.gz && tar czvf devices.tar.gz --files-from=/dev/null)
+if [ -e "$LXC_ROOTFS/debootstrap/devices.tar.gz" ]; then
+    (cd "$LXC_ROOTFS/debootstrap" && rm devices.tar.gz && tar czvf devices.tar.gz --files-from=/dev/null)
+fi
 
 # and mount a shitload of things for fun and profit...
 for file in /var/lib/lxcfs/proc/*; do
-- 
2.39.5