Use relative path instead of absolute path for latest symlink

This maintains the intended functionality while simultaneously
allowing to copy or move the folder somewhere else.
Otherwise, if I copy /var/tmp/packstack elsewhere, the symlink
will keep pointing to /var/tmp/packstack.

Change-Id: I7da0af24dbccb14d1f7fb1d75079ac109e981882
This commit is contained in:
David Moreau Simard 2016-01-27 17:00:33 -05:00
parent d220fc0c93
commit 4c55410145
1 changed files with 4 additions and 1 deletions

View File

@ -75,7 +75,10 @@ if os.path.exists(LATEST_LOG_DIR):
print ('Unable to delete symbol link for log dir %s.' % LATEST_LOG_DIR)
try:
os.symlink(DIR_LOG, LATEST_LOG_DIR)
# Extract folder name at /var/tmp/packstack/<VAR_DIR> and do a relative
# symlink to /var/tmp/packstack/latest
os.symlink(os.path.basename(VAR_DIR),
os.path.join(PACKSTACK_VAR_DIR, 'latest'))
except OSError:
print ('Unable to create symbol link for log dir %s.' % LATEST_LOG_DIR)