Skip to content

Instantly share code, notes, and snippets.

@DNI9
Forked from TingPing/meson_uninstall.py
Created December 20, 2020 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DNI9/b154a47cbb8a80f32ee30371b71e4067 to your computer and use it in GitHub Desktop.
Save DNI9/b154a47cbb8a80f32ee30371b71e4067 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# NOTE: This is only useful until Meson 0.38.0 which includes an `uninstall` target.
import argparse
from contextlib import suppress
from os import path, remove
parser = argparse.ArgumentParser()
parser.add_argument('--dry-run', action='store_true')
parser.add_argument('directory', type=str, default='.', nargs='?')
args = parser.parse_args()
log_file = path.join(args.directory, 'meson-logs', 'install-log.txt')
with open(log_file) as f:
for line in f:
line = line.strip()
if line.startswith('#'):
continue
if args.dry_run:
print('Would delete:', line)
else:
print('Deleting:', line)
with suppress(FileNotFoundError):
remove(line)
print('Note that empty directories and post-install script created files maybe left over')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment