xpra icon
Bug tracker and wiki

Ticket #172: 0003-draft-of-template-file-build-and-install.patch

File 0003-draft-of-template-file-build-and-install.patch, 5.9 KB (added by Benoit Gschwind, 6 years ago)
  • src/setup.py

    From 161814b18f911fcc7370473bc48b966f6c5e2f72 Mon Sep 17 00:00:00 2001
    From: Benoit Gschwind <gschwind@gnu-log.net>
    Date: Sat, 14 Jun 2014 17:53:57 +0200
    Subject: [PATCH 3/3] draft of template file build and install
    
    ---
     src/setup.py | 75 ++++++++++++++++++++++++++++++++++++++++++++++++------------
     1 file changed, 61 insertions(+), 14 deletions(-)
    
    diff --git a/src/setup.py b/src/setup.py
    index c5d636a..5f9bc64 100755
    a b from distutils.extension import Extension 
    1616import subprocess, sys
    1717import os.path
    1818import stat
     19from distutils.command.build import build
     20from distutils.command.install_data import install_data
     21import shutil
     22
    1923try:
    2024    from hashlib import md5         #@UnusedImport
    2125    new_md5 = md5
    cmdclass = {} 
    5155scripts = []
    5256
    5357
     58xpra_conf = None
     59
     60
    5461WIN32 = sys.platform.startswith("win")
    5562OSX = sys.platform.startswith("darwin")
    5663PYTHON3 = sys.version_info[0] == 3
    def get_xorg_version(): 
    633640        xorg_version = None
    634641    return xorg_version
    635642
    636 def build_xpra_conf(xvfb, displayfd):
     643def build_xpra_conf_file(build_base, xvfb, displayfd):
    637644    f_in = open("etc/xpra/xpra.conf.in", "r")
    638     f_out = open("etc/xpra/xpra.conf", "w")
     645    f_out = open(build_base + "/xpra.conf", "w")
    639646    f_out.write((f_in.read()) % {'xvfb_command': xvfb, 'has_displayfd': displayfd})
    640647    f_out.close()
    641648    f_in.close()
     649    return
    642650   
    643 def get_xorg_conf_and_script():
     651def detect_xorg_setup():
    644652    if not server_ENABLED:
    645         return "etc/xpra/client-only/xpra.conf", False
    646 
     653        return (None, None, False)
    647654    #do live detection
    648655    xorg_version = get_xorg_version()
    649656
    def get_xorg_conf_and_script(): 
    656663        has_displayfd = 'no'
    657664       
    658665    def Xvfb():
    659         build_xpra_conf("Xvfb +extension Composite -screen 0 3840x2560x24+32 -nolisten tcp -noreset -auth $XAUTHORITY", has_displayfd)
    660         return "etc/xpra/xpra.conf", False
    661 
     666        return ("Xvfb +extension Composite -screen 0 3840x2560x24+32 -nolisten tcp -noreset -auth $XAUTHORITY", has_displayfd, False)
     667       
    662668    if sys.platform.find("bsd")>=0:
    663669        print("Warning: sorry, no support for Xdummy on %s" % sys.platform)
    664670        return Xvfb()
    def get_xorg_conf_and_script(): 
    681687                print("Xorg is suid and not readable, Xdummy support unavailable")
    682688                return Xvfb()
    683689            print("%s is suid and readable, using the xpra_Xdummy wrapper" % XORG_BIN)
    684             build_xpra_conf("xpra_Xdummy -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf", has_displayfd)
    685             return "etc/xpra/xpra.conf", True
     690            return ("xpra_Xdummy -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf", has_displayfd, True)
    686691        else:
    687692            print("using Xdummy config file")
    688             build_xpra_conf("Xorg -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf", has_displayfd)
    689             return "etc/xpra/xpra.conf", False
     693            return ("Xorg -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf", has_displayfd, False)
    690694
    691695    if Xdummy_ENABLED is False:
    692696        return Xvfb()
    def get_xorg_conf_and_script(): 
    721725    return Xorg_suid_check()
    722726
    723727
     728   
     729def build_xpra_conf(build_base):
     730    xvfb_cmd, has_displayfd, xdummy_wrapper = detect_xorg_setup()
     731
     732    if not xvfb_cmd:
     733        f_in = open("etc/xpra/client-only/xpra.conf", "r")
     734        f_out = open(build_base + "/xpra.conf", "w")
     735        f_out.write(f_in.read())
     736        f_out.close()
     737        f_in.close()
     738    else:
     739        build_xpra_conf_file(build_base, xvfb_cmd, has_displayfd)
     740
     741
    724742#*******************************************************************************
    725743if 'clean' in sys.argv or 'sdist' in sys.argv:
    726744    #clean and sdist don't actually use cython,
    else: 
    13471365    add_data_files("share/icons",         ["xdg/xpra.png"])
    13481366    html5_dir = "share/xpra/www"
    13491367
     1368    class build_overide(build):
     1369        def run(self):
     1370            build.run(self)
     1371            self.run_command("build_conf")
     1372
     1373    class build_conf(build):
     1374        def run(self):
     1375            build_xpra_conf(self.build_base)
     1376
     1377
     1378    class install_data_override(install_data):
     1379        def run(self):           
     1380            # Call parent
     1381            install_data.run(self)
     1382
     1383            # install Xpra
     1384            dst_xpra_conf = self.install_dir + "/etc/xpra.conf"
     1385            src_xpra_conf = self.distribution.command_obj['build'].build_base + "/xpra.conf"
     1386
     1387            if os.path.exists(src_xpra_conf):
     1388                shutil.copyfile(src_xpra_conf, dst_xpra_conf)
     1389           
     1390            print "Running"
     1391       
     1392    # add build_conf to build step
     1393    cmdclass['build'] = build_overide
     1394    cmdclass['build_conf'] = build_conf
     1395    cmdclass['install_data'] = install_data_override
     1396
    13501397    if OSX:
    13511398        #OSX package names (ie: gdk-x11-2.0 -> gdk-2.0, etc)
    13521399        PYGTK_PACKAGES += ["gdk-2.0", "gtk+-2.0"]
    else: 
    13781425        if server_ENABLED and x11_ENABLED:
    13791426            etc_files = ["etc/xpra/xorg.conf"]
    13801427            #figure out the version of the Xorg server:
    1381             xorg_conf, use_Xdummy_wrapper = get_xorg_conf_and_script()
     1428            _, _, use_Xdummy_wrapper = detect_xorg_setup()
    13821429            if not use_Xdummy_wrapper and "scripts/xpra_Xdummy" in scripts:
    13831430                #if we're not using the wrapper, don't install it
    13841431                scripts.remove("scripts/xpra_Xdummy")
    1385             etc_files.append(xorg_conf)
     1432            #etc_files.append(xorg_conf)
    13861433        add_data_files(etc_prefix, etc_files)
    13871434
    13881435    if OSX and "py2app" in sys.argv: