aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/scripts/uninstall.py
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-07-04 10:01:12 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-08-01 11:40:28 +0100
commitd436869a89eee7c6e43ddf799386b16a4acdf74c (patch)
treeb45f818df84bbdd5f91f096b55b9d791bdda80b8 /mesonbuild/scripts/uninstall.py
parent36e58e88650f0ef51cdee37ec7a593893298cadf (diff)
downloadmeson-d436869a89eee7c6e43ddf799386b16a4acdf74c.zip
meson-d436869a89eee7c6e43ddf799386b16a4acdf74c.tar.gz
meson-d436869a89eee7c6e43ddf799386b16a4acdf74c.tar.bz2
Remove directories created by ninja install
Introduce a DirMaker class that disassembles the path up to '/' and stores all directories in a list. That list is in creation order and pre-existing directories are ignored, i.e. creating the two paths '/usr/share/foo/bar/baz' and '/usr/share/foo/bar/boo' is stored as [ '/usr/share/foo', '/usr/share/foo/bar', '/usr/share/foo/bar/baz', '/usr/share/foo/bar/boo' ] This is on the assumption that /usr/share already existed. After all files have been installed, the list of created directories is appended in reverse order to the install log. The uninstall script then triggers rmdir on all directories. If a custom install script drops files into the directories, removing those will fail. This matches the current expectation, see the existing warning "Remember that files created by custom scripts have not been removed." Unfortunately, this makes the behavior on uninstall inconsistent. Assuming a non-existing prefix, ninja install && ninja uninstall removes all traces of the install. However, ninja install && ninja install && ninja uninstall removes the files only, not the directories as they already existed. This could be fixed by just unconditionally removing any (emtpy) directories that we drop files into, at the risk of removing system directories if empty. For example, one could imagine /etc/foo.conf.d/ to be removed in that case if it is empty. https://github.com/mesonbuild/meson/issues/2032
Diffstat (limited to 'mesonbuild/scripts/uninstall.py')
-rw-r--r--mesonbuild/scripts/uninstall.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/mesonbuild/scripts/uninstall.py b/mesonbuild/scripts/uninstall.py
index 1480921..bdc036b 100644
--- a/mesonbuild/scripts/uninstall.py
+++ b/mesonbuild/scripts/uninstall.py
@@ -24,7 +24,10 @@ def do_uninstall(log):
continue
fname = line.strip()
try:
- os.unlink(fname)
+ if os.path.isdir(fname) and not os.path.islink(fname):
+ os.rmdir(fname)
+ else:
+ os.unlink(fname)
print('Deleted:', fname)
successes += 1
except Exception as e: