diff setup.py @ 1153:25a16df15ae2

misc (installation): --root option is ignored for _final destinations
author Goffi <goffi@goffi.org>
date Wed, 03 Sep 2014 16:40:52 +0200
parents beaf8d4475e4
children 6365e6826831
line wrap: on
line diff
--- a/setup.py	Wed Sep 03 12:25:07 2014 +0200
+++ b/setup.py	Wed Sep 03 16:40:52 2014 +0200
@@ -24,6 +24,7 @@
 from setuptools import setup
 from distutils.file_util import copy_file
 import os
+import os.path
 import sys
 import subprocess
 from stat import ST_MODE
@@ -70,7 +71,7 @@
 # to replace or a tuple with a template and values to replace (if value to replace is a string,
 # the attribute from self with that name will be used).
 FILE_ADJ = {'sh_script_path': {r'PYTHON *=.*': 'PYTHON="{}"'.format(sys.executable)},
-            'dbus_service_path': {r'Exec *=.*': ('Exec={}', 'sh_script_path')},
+            'dbus_service_path': {r'Exec *=.*': ('Exec={}', 'sh_script_path_final')},
            }
 
 
@@ -123,14 +124,22 @@
             if os.path.islink(dest) and os.readlink(dest) != source:
                 os.remove(dest)  # copy_file doesn't force the link update
             dest_name, copied = copy_file(source, dest, link='sym')
-            assert (copied)
+            assert copied
             # we change the perm in the same way as in the original install_scripts
             mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
             os.chmod(dest_name, mode)
 
     def run(self):
+        ignore_idx = 0 if self.root is None else len(self.root)
+        if self.root[-1] == '/':
+            ignore_idx-=1 # we dont want to remove the first '/' in _final paths
+        # _final suffixed attributes are the ones without the self.root prefix path
+        # it's used at least on Arch linux installation as install is made on a local $pkgdir
+        # which is later moved to user's FS root
+        self.install_lib_final = self.install_lib[ignore_idx:]
         self.sh_script_path = os.path.join(self.install_lib, NAME, 'sat.sh')
-        self.sh_script_links = [(self.sh_script_path, os.path.join(self.install_scripts, LAUNCH_DAEMON_COMMAND))]
+        self.sh_script_path_final = os.path.join(self.install_lib_final, NAME, 'sat.sh')
+        self.sh_script_links = [(self.sh_script_path_final, os.path.join(self.install_scripts, LAUNCH_DAEMON_COMMAND))]
         self.dbus_service_path = os.path.join(self.install_data, 'share', DBUS_DIR, os.path.basename(DBUS_FILE))
         sys.stdout.write('running pre installation stuff\n')
         sys.stdout.flush()