Skip to content

Commit

Permalink
unity: ensure we use python3 for the launch script
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry Warsaw authored and 3v1n0 committed Nov 5, 2015
1 parent 6732fbe commit 8c752c6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 45 deletions.
4 changes: 3 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Build-Depends: cmake,
dbus-test-runner,
dh-migrations,
dh-translations (>= 94),
dh-python,
google-mock (>= 1.6.0+svn437),
gsettings-desktop-schemas-dev,
gsettings-ubuntu-schemas (>= 0.0.1+14.04.20140219),
Expand Down Expand Up @@ -48,6 +49,7 @@ Build-Depends: cmake,
libzeitgeist-2.0-dev,
pkg-config,
python (>= 2.7),
python3 (>= 3.4),
python-setuptools,
quilt,
xserver-xorg-video-dummy,
Expand All @@ -62,7 +64,7 @@ Package: unity
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
${python:Depends},
${python3:Depends},
libunity-core-6.0-9 (= ${binary:Version}),
compiz,
compiz-core, compiz-core-abiversion-${coreabiversion},
Expand Down
8 changes: 2 additions & 6 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ gles2_architectures := armel armhf

DEB_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')

# avoid template instance removal (lp:1286284)
export DEB_CXXFLAGS_MAINT_STRIP=-O3
export DEB_CXXFLAGS_MAINT_APPEND=-O2

# http://ccache.samba.org/manual.html#_precompiled_headers
CCACHE_SLOPPINESS=time_macros

Expand Down Expand Up @@ -46,7 +42,7 @@ override_dh_install:
find debian/tmp/usr/lib -name \*.*a -exec rm {} \;
rm -f debian/tmp/usr/share/compiz/networkarearegion.xml
rm -f debian/tmp//usr/lib/compiz/libnetworkarearegion.so
rm -rf debian/tmp/usr/share/gconf/schemas/
rm -rf debian/tmp/usr/share/gconf/schemas/
dh_install --fail-missing

override_dh_gencontrol:
Expand All @@ -64,4 +60,4 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
endif

%:
dh $@ --with translations,quilt,python2,migrations --parallel
dh $@ --with translations,quilt,python2,python3,migrations --parallel
75 changes: 37 additions & 38 deletions tools/unity.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (C) 2010 Canonical
#
Expand All @@ -18,7 +18,6 @@
# this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

import glib
import glob
from optparse import OptionParser
import os
Expand Down Expand Up @@ -58,21 +57,21 @@ def set_unity_env ():
'''set variable environnement for unity to run'''

os.environ['COMPIZ_CONFIG_PROFILE'] = 'ubuntu'

if not 'DISPLAY' in os.environ:
# take an optimistic chance and warn about it :)
print "WARNING: no DISPLAY variable set, setting it to :0"
print("WARNING: no DISPLAY variable set, setting it to :0")
os.environ['DISPLAY'] = ':0'

def reset_launcher_icons ():
'''Reset the default launcher icon and restart it.'''
subprocess.Popen(["gsettings", "reset" ,"com.canonical.Unity.Launcher" , "favorites"])
subprocess.Popen(["gsettings", "reset" ,"com.canonical.Unity.Launcher" , "favorites"])

def process_and_start_unity (verbose, debug_mode, compiz_path, compiz_args, log_file):
'''launch unity under compiz (replace the current shell in any case)'''

cli = []

if debug_mode > 0:
# we can do more check later as if it's in PATH...
if not os.path.isfile('/usr/bin/gdb'):
Expand All @@ -85,7 +84,7 @@ def process_and_start_unity (verbose, debug_mode, compiz_path, compiz_args, log_
sys.exit(1)
else:
cli.extend(['gdb', '--args'])

if options.compiz_path:
cli.extend([options.compiz_path, '--replace'])
else:
Expand All @@ -95,7 +94,7 @@ def process_and_start_unity (verbose, debug_mode, compiz_path, compiz_args, log_
cli.append("--debug")
if args:
cli.extend(compiz_args)

if log_file:
cli.extend(['2>&1', '|', 'tee', log_file])

Expand All @@ -119,7 +118,7 @@ def process_and_start_unity (verbose, debug_mode, compiz_path, compiz_args, log_
# In this case, we need a string and not a list
# FIXME: still some bug with 2>&1 not showing everything before wait()
return subprocess.Popen(" ".join(cli), env=dict(os.environ), shell=True)


def run_unity (verbose, debug, advanced_debug, compiz_path, compiz_args, log_file):
'''run the unity shell and handle Ctrl + C'''
Expand All @@ -130,7 +129,7 @@ def run_unity (verbose, debug, advanced_debug, compiz_path, compiz_args, log_fil
unity_instance = process_and_start_unity (verbose, debug_mode, compiz_path, compiz_args, log_file)
subprocess.call(["start", "unity-panel-service"])
unity_instance.wait()
except KeyboardInterrupt, e:
except KeyboardInterrupt as e:
try:
os.kill(unity_instance.pid, signal.SIGKILL)
except:
Expand All @@ -139,31 +138,31 @@ def run_unity (verbose, debug, advanced_debug, compiz_path, compiz_args, log_fil
sys.exit(unity_instance.returncode)

def reset_to_distro():
''' remove all known default local installation path '''
# check if we are root, we need to be root
if os.getuid() != 0:
print "Error: You need to be root to remove your local unity installation"
return 1
error = False
for filedir in well_known_local_path:
for elem in glob.glob(filedir):
try:
shutil.rmtree(elem)
except OSError, e:
if os.path.isfile(elem) or os.path.islink(elem):
os.remove(elem)
else:
print "ERROR: Cannot remove %s: %s" % (elem, e)
error = True
if error:
print "See above: some error happened and you should clean them before trying to restart unity"
return 1
else:
print "Unity local install cleaned, you can now restart unity"
return 0
''' remove all known default local installation path '''

# check if we are root, we need to be root
if os.getuid() != 0:
print("Error: You need to be root to remove your local unity installation")
return 1
error = False

for filedir in well_known_local_path:
for elem in glob.glob(filedir):
try:
shutil.rmtree(elem)
except OSError as e:
if os.path.isfile(elem) or os.path.islink(elem):
os.remove(elem)
else:
print("ERROR: Cannot remove %s: %s" % (elem, e))
error = True

if error:
print("See above: some error happened and you should clean them before trying to restart unity")
return 1
else:
print("Unity local install cleaned, you can now restart unity")
return 0

if __name__ == '__main__':
usage = "usage: %prog [options]"
Expand All @@ -176,15 +175,15 @@ if __name__ == '__main__':
parser.add_option("--debug", action="store_true",
help="Run unity under gdb and print a backtrace on crash. /!\ Only if devs ask for it.")
parser.add_option("--distro", action="store_true",
help="Remove local build if present with default values to return to the package value (this doesn't run unity and need root access)")
help="Remove local build if present with default values to return to the package value (this doesn't run unity and need root access)")
parser.add_option("--log", action="store",
help="Store log under filename.")
parser.add_option("--replace", action="store_true",
help="Run unity /!\ This is for compatibility with other desktop interfaces and acts the same as running unity without --replace")
parser.add_option("--reset", action="store_true",
help="Reset is not supported anymore. Deprecated option")
parser.add_option("--reset-icons", action="store_true",
help="Reset the default launcher icon.")
help="Reset the default launcher icon.")
parser.add_option("-v", "--verbose", action="store_true",
help="Get additional debug output from unity.")
(options, args) = parser.parse_args()
Expand Down

0 comments on commit 8c752c6

Please sign in to comment.