From 4c43d14891a286affbf2a5b4d57415451410048e Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Tue, 4 Dec 2018 10:18:01 +0700 Subject: [PATCH] Use MESON_INSTALL_DESTDIR_PREFIX instead of DESTDIR --- contrib/meson/InstallSymlink.py | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/contrib/meson/InstallSymlink.py b/contrib/meson/InstallSymlink.py index a0858eb..c1f13f5 100644 --- a/contrib/meson/InstallSymlink.py +++ b/contrib/meson/InstallSymlink.py @@ -12,23 +12,6 @@ import os import pathlib # since Python 3.4 -def prepend_destdir(path): - """prepend_destdir(path) -> Path - - Needed because pathlib.Path.joinpath() discards the first path if the - second one is absolute, which is usually the case here. - """ - path = pathlib.Path(path) - DESTDIR = os.environ.get('DESTDIR') - - if DESTDIR: - if not path.is_absolute(): - raise Exception('{!r} must be an absolute path when DESTDIR is set'.format(path)) - - path = pathlib.Path(DESTDIR).joinpath(*path.resolve().parts[1:]) - return path - - def install_symlink(src, dst, install_dir, dst_is_dir=False, dir_mode=0o777): if not install_dir.exists(): install_dir.mkdir(mode=dir_mode, parents=True, exist_ok=True) @@ -48,8 +31,7 @@ def main(): parser = argparse.ArgumentParser(description='Install a symlink', usage='InstallSymlink.py [-h] [-d] [-m MODE] src dst install_dir\n\n' 'example:\n' - '\tInstallSymlink.py dash sh /bin\n' - '\tDESTDIR=./staging InstallSymlink.py dash sh /bin') + '\tInstallSymlink.py dash sh /bin') parser.add_argument('src', help='target to link') parser.add_argument('dst', help='link name') parser.add_argument('install_dir', help='installation directory') @@ -65,8 +47,11 @@ def main(): dst = args.dst dst_is_dir = args.isdir dir_mode = int(args.mode, 8) + install_dir = pathlib.Path(args.install_dir) - install_dir = prepend_destdir(args.install_dir) + meson_destdir = os.environ.get('MESON_INSTALL_DESTDIR_PREFIX') + if meson_destdir: + install_dir = pathlib.Path(meson_destdir).joinpath(install_dir) install_symlink(src, dst, install_dir, dst_is_dir, dir_mode)