Repository: conan-io/conan

Issue:
[bug] deploy generator broken with 1.25.0
### Environment Details (include every applicable attribute)
  * Operating System+version: Ubuntu 20.04
  * Compiler+version: any
  * Conan version: 1.25.0
  * Python version: 3.8.2

### Steps to reproduce (Include if Applicable)
* mkdir /tmp/conan-paho-mqtt
* conan install  paho-mqtt-cpp/1.1@ -g deploy -o *:shared=True

### Logs (Executed commands with output) (Include/Attach if Applicable)
```
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=9
os=Linux
os_build=Linux
[options]
*:shared=True
[build_requires]
[env]

Installing package: paho-mqtt-cpp/1.1
Requirements
    paho-mqtt-c/1.3.1 from 'conan-center' - Cache
    paho-mqtt-cpp/1.1 from 'conan-center' - Cache
Packages
    paho-mqtt-c/1.3.1:bf0adb9a727594d902b6dc22b23c800d7707b38a - Cache
    paho-mqtt-cpp/1.1:698833d5e29368eb40ad7c3fd09f712da2722f78 - Cache

Installing (downloading, building) binaries...
paho-mqtt-c/1.3.1: Already installed!
paho-mqtt-cpp/1.1: Already installed!
ERROR: Generator deploy(file:deploy_manifest.txt) failed
[Errno 2] No such file or directory: '/tmp/conan-paho-mqtt/paho-mqtt-cpp/lib/libpaho-mqttpp3.so.1'
ERROR: [Errno 2] No such file or directory: '/tmp/conan-paho-mqtt/paho-mqtt-cpp/lib/libpaho-mqttpp3.so.1'
```



Discussion:

Resolving patch:
diff --git a/conans/client/generators/deploy.py b/conans/client/generators/deploy.py
--- a/conans/client/generators/deploy.py
+++ b/conans/client/generators/deploy.py
@@ -43,7 +43,10 @@ def content(self):
                     dst = os.path.normpath(dst)
                     mkdir(os.path.dirname(dst))
                     if os.path.islink(src):
-                        linkto = os.path.relpath(os.readlink(src), os.path.dirname(src))
+                        link_target = os.readlink(src)
+                        if not os.path.isabs(link_target):
+                            link_target = os.path.join(os.path.dirname(src), link_target)
+                        linkto = os.path.relpath(link_target, os.path.dirname(src))
                         os.symlink(linkto, dst)
                     else:
                         shutil.copy(src, dst)


Test patch:
diff --git a/conans/test/functional/generators/deploy_test.py b/conans/test/functional/generators/deploy_test.py
--- a/conans/test/functional/generators/deploy_test.py
+++ b/conans/test/functional/generators/deploy_test.py
@@ -145,7 +145,7 @@ class DeployGeneratorSymbolicLinkTest(unittest.TestCase):
 
     def setUp(self):
         conanfile = GenConanfile()
-        conanfile.with_package_file("include/header.h", "whatever")
+        conanfile.with_package_file("include/header.h", "whatever", link="include/header.h.lnk")
         self.ref = ConanFileReference("name", "version", "user", "channel")
 
         self.client = TurboTestClient()
@@ -153,10 +153,9 @@ def setUp(self):
         layout = self.client.cache.package_layout(self.ref)
         package_folder = layout.package(PackageReference(self.ref, NO_SETTINGS_PACKAGE_ID))
         self.header_path = os.path.join(package_folder, "include", "header.h")
+        self.link_path = os.path.join(package_folder, "include", "header.h.lnk")
 
     def test_symbolic_links(self):
-        link_path = self.header_path + ".lnk"
-        os.symlink(self.header_path, link_path)
         self.client.current_folder = temp_folder()
         self.client.run("install %s -g deploy" % self.ref.full_str())
         base_path = os.path.join(self.client.current_folder, "name")
diff --git a/conans/test/utils/genconanfile.py b/conans/test/utils/genconanfile.py
--- a/conans/test/utils/genconanfile.py
+++ b/conans/test/utils/genconanfile.py
@@ -22,6 +22,7 @@ def __init__(self, name=None, version=None):
         self._default_options = {}
         self._package_files = {}
         self._package_files_env = {}
+        self._package_files_link = {}
         self._build_messages = []
         self._scm = {}
         self._requires = []
@@ -90,13 +91,15 @@ def with_default_option(self, option_name, value):
         self._default_options[option_name] = value
         return self
 
-    def with_package_file(self, file_name, contents=None, env_var=None):
+    def with_package_file(self, file_name, contents=None, env_var=None, link=None):
         if not contents and not env_var:
             raise Exception("Specify contents or env_var")
         self.with_import("import os")
         self.with_import("from conans import tools")
         if contents:
             self._package_files[file_name] = contents
+        if link:
+            self._package_files_link[file_name] = link
         if env_var:
             self._package_files_env[file_name] = env_var
         return self
@@ -229,6 +232,12 @@ def _package_method(self):
             lines.extend(['        tools.save(os.path.join(self.package_folder, "{}"), '
                           'os.getenv("{}"))'.format(key, value)
                           for key, value in self._package_files_env.items()])
+        if self._package_files_link:
+            lines.extend(['        with tools.chdir(os.path.dirname('
+                          'os.path.join(self.package_folder, "{}"))):\n'
+                          '            os.symlink(os.path.basename("{}"), '
+                          'os.path.join(self.package_folder, "{}"))'.format(key, key, value)
+                          for key, value in self._package_files_link.items()])
 
         if not lines:
             return ""