From 2ccc760da838532dcde32d1a93a65dc275971c4f Mon Sep 17 00:00:00 2001
From: Marc Gariepy <gariepy.marc@gmail.com>
Date: Fri, 24 Nov 2017 11:46:39 -0500
Subject: [PATCH] Validate the target directory exists before linking.

If you run the script manually and export the target release to another tag, it
might generate a broken link, this ensure the target exists.

Change-Id: Ia18bd7796f5f48c42ad9c23e917ddb37aa8103b3
---
 leap-upgrades/lib/functions.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/leap-upgrades/lib/functions.sh b/leap-upgrades/lib/functions.sh
index d2317e96..5454b91b 100644
--- a/leap-upgrades/lib/functions.sh
+++ b/leap-upgrades/lib/functions.sh
@@ -430,6 +430,10 @@ function link_release {
     if [[ -d "/opt/openstack-ansible" ]]; then
       mv "/opt/openstack-ansible" "/opt/openstack-ansible.bak"
     fi
+    if [[ ! -d "$1" ]]; then
+      failure "Make sure the target "$1" exists. "
+      exit 99
+    fi
     ln -sf "$1" "/opt/openstack-ansible"
 }