Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
1152:c8c7755de5d8 | 1153:25a16df15ae2 |
---|---|
22 use_setuptools() | 22 use_setuptools() |
23 from setuptools.command.install import install | 23 from setuptools.command.install import install |
24 from setuptools import setup | 24 from setuptools import setup |
25 from distutils.file_util import copy_file | 25 from distutils.file_util import copy_file |
26 import os | 26 import os |
27 import os.path | |
27 import sys | 28 import sys |
28 import subprocess | 29 import subprocess |
29 from stat import ST_MODE | 30 from stat import ST_MODE |
30 import shutil | 31 import shutil |
31 import re | 32 import re |
68 # key is the self attribute to get (e.g.: sh_script_path will modify self.sh_script_path file) | 69 # key is the self attribute to get (e.g.: sh_script_path will modify self.sh_script_path file) |
69 # value is a dict where key is the regex of the part to change, and value is either the string | 70 # value is a dict where key is the regex of the part to change, and value is either the string |
70 # to replace or a tuple with a template and values to replace (if value to replace is a string, | 71 # to replace or a tuple with a template and values to replace (if value to replace is a string, |
71 # the attribute from self with that name will be used). | 72 # the attribute from self with that name will be used). |
72 FILE_ADJ = {'sh_script_path': {r'PYTHON *=.*': 'PYTHON="{}"'.format(sys.executable)}, | 73 FILE_ADJ = {'sh_script_path': {r'PYTHON *=.*': 'PYTHON="{}"'.format(sys.executable)}, |
73 'dbus_service_path': {r'Exec *=.*': ('Exec={}', 'sh_script_path')}, | 74 'dbus_service_path': {r'Exec *=.*': ('Exec={}', 'sh_script_path_final')}, |
74 } | 75 } |
75 | 76 |
76 | 77 |
77 class MercurialException(Exception): | 78 class MercurialException(Exception): |
78 pass | 79 pass |
121 # the script which launch the daemon | 122 # the script which launch the daemon |
122 for source, dest in self.sh_script_links: | 123 for source, dest in self.sh_script_links: |
123 if os.path.islink(dest) and os.readlink(dest) != source: | 124 if os.path.islink(dest) and os.readlink(dest) != source: |
124 os.remove(dest) # copy_file doesn't force the link update | 125 os.remove(dest) # copy_file doesn't force the link update |
125 dest_name, copied = copy_file(source, dest, link='sym') | 126 dest_name, copied = copy_file(source, dest, link='sym') |
126 assert (copied) | 127 assert copied |
127 # we change the perm in the same way as in the original install_scripts | 128 # we change the perm in the same way as in the original install_scripts |
128 mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777 | 129 mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777 |
129 os.chmod(dest_name, mode) | 130 os.chmod(dest_name, mode) |
130 | 131 |
131 def run(self): | 132 def run(self): |
133 ignore_idx = 0 if self.root is None else len(self.root) | |
134 if self.root[-1] == '/': | |
135 ignore_idx-=1 # we dont want to remove the first '/' in _final paths | |
136 # _final suffixed attributes are the ones without the self.root prefix path | |
137 # it's used at least on Arch linux installation as install is made on a local $pkgdir | |
138 # which is later moved to user's FS root | |
139 self.install_lib_final = self.install_lib[ignore_idx:] | |
132 self.sh_script_path = os.path.join(self.install_lib, NAME, 'sat.sh') | 140 self.sh_script_path = os.path.join(self.install_lib, NAME, 'sat.sh') |
133 self.sh_script_links = [(self.sh_script_path, os.path.join(self.install_scripts, LAUNCH_DAEMON_COMMAND))] | 141 self.sh_script_path_final = os.path.join(self.install_lib_final, NAME, 'sat.sh') |
142 self.sh_script_links = [(self.sh_script_path_final, os.path.join(self.install_scripts, LAUNCH_DAEMON_COMMAND))] | |
134 self.dbus_service_path = os.path.join(self.install_data, 'share', DBUS_DIR, os.path.basename(DBUS_FILE)) | 143 self.dbus_service_path = os.path.join(self.install_data, 'share', DBUS_DIR, os.path.basename(DBUS_FILE)) |
135 sys.stdout.write('running pre installation stuff\n') | 144 sys.stdout.write('running pre installation stuff\n') |
136 sys.stdout.flush() | 145 sys.stdout.flush() |
137 if PURGE_OPT in install_opt: | 146 if PURGE_OPT in install_opt: |
138 self.purge() | 147 self.purge() |