From: Mikko Rasa Date: Fri, 27 Jul 2012 07:29:32 +0000 (+0300) Subject: Make sure that symlinks point to the right place X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=dfa45a1b64f59515a0b62f0912250fa1cf08b8b9;p=builder.git Make sure that symlinks point to the right place --- diff --git a/source/copy.cpp b/source/copy.cpp index 0073320..75d047d 100644 --- a/source/copy.cpp +++ b/source/copy.cpp @@ -87,6 +87,8 @@ void Copy::Worker::main() if(!link.empty()) { FS::Path relpath = FS::relative(dst_path, FS::dirname(link)); + if(FS::exists(link)) + FS::unlink(link); symlink(relpath.str().c_str(), link.str().c_str()); } diff --git a/source/installedfile.cpp b/source/installedfile.cpp index 4638cc4..76e7b69 100644 --- a/source/installedfile.cpp +++ b/source/installedfile.cpp @@ -55,8 +55,17 @@ void InstalledFile::check_rebuild() mark_rebuild(source.get_name()+" has changed"); else if(source.needs_rebuild()) mark_rebuild(source.get_name()+" needs rebuilding"); - else if(!link.empty() && !FS::exists(link)) - mark_rebuild("Symlink does not exist"); + if(!needs_rebuild() && !link.empty()) + { + if(!FS::exists(link)) + mark_rebuild("Symlink does not exist"); + else + { + FS::Path rel_path = FS::relative(path, FS::dirname(link)); + if(FS::readlink(link)!=rel_path) + mark_rebuild("Symlink needs updating"); + } + } } void InstalledFile::clean()