summaryrefslogtreecommitdiff
diff options
authorDidier Roche <didier.roche@canonical.com>2011-02-09 13:11:12 +0100
committerDidier Roche <didier.roche@canonical.com>2011-02-09 13:11:12 +0100
commite5b68f2969a4446e2cdb5de8e5cb190c2c1233da (patch)
tree9ee3fc1b14279286559831c4ab96e21bc7161f56
parent77f762e01331548d44a44e490ccb3bacdfda0f9d (diff)
add --distro switch to remove local installation of unity with default options (LP: #715703
Fixes LP: #715703 (bzr r845)
-rwxr-xr-xtools/unity.cmake49
1 files changed, 49 insertions, 0 deletions
diff --git a/tools/unity.cmake b/tools/unity.cmake
index d26911a45..8d537290c 100755
--- a/tools/unity.cmake
+++ b/tools/unity.cmake
@@ -19,13 +19,29 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import gconf
+import glob
from optparse import OptionParser
import os
+import shutil
import signal
import subprocess
import sys
import time
+home_dir = os.path.expanduser("~%s" % os.getenv("SUDO_USER"))
+supported_prefix = "/usr/local"
+
+well_known_local_path = ("%s/share/unity" % supported_prefix,
+ "%s/share/ccsm/icons/*/*/*/*unity*" % supported_prefix,
+ "%s/share/locale/*/LC_MESSAGES/*unity*" % supported_prefix,
+ "%s/.compiz-1/*/*unity*" % home_dir,
+ "%s/.gconf/schemas/*unity*" % home_dir,
+ "%s/lib/*unity*" % supported_prefix,
+ "%s/share/dbus-1/services/*Unity*" % supported_prefix,
+ "%s/bin/*unity*" % supported_prefix,
+ "%s/share/man/man1/*unity*" % supported_prefix
+ )
+
def set_unity_env ():
'''set variable environnement for unity to run'''
@@ -116,12 +132,41 @@ def run_unity (verbose, debug, compiz_args, log_file):
unity_instance.wait()
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):
+ os.remove(elem)
+ else:
+ print "ERROR: Cannot remove %s", 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]"
parser = OptionParser(version= "%prog @UNITY_VERSION@", usage=usage)
parser.add_option("--advanced-debug", action="store_true",
help="Run unity under debugging to help debugging an issue. /!\ 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)")
parser.add_option("--log", action="store",
help="Store log under filename.")
parser.add_option("--replace", action="store_true",
@@ -133,6 +178,10 @@ if __name__ == '__main__':
(options, args) = parser.parse_args()
set_unity_env()
+
+ if options.distro:
+ sys.exit(reset_to_distro())
+
if options.reset:
reset_unity_compiz_profile ()