uninstall.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright 2016 The Meson development team
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. # Unless required by applicable law or agreed to in writing, software
  7. # distributed under the License is distributed on an "AS IS" BASIS,
  8. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing permissions and
  10. # limitations under the License.
  11. import os
  12. logfile = 'meson-logs/install-log.txt'
  13. def do_uninstall(log):
  14. failures = 0
  15. successes = 0
  16. for line in open(log):
  17. if line.startswith('#'):
  18. continue
  19. fname = line.strip()
  20. try:
  21. if os.path.isdir(fname) and not os.path.islink(fname):
  22. os.rmdir(fname)
  23. else:
  24. os.unlink(fname)
  25. print('Deleted:', fname)
  26. successes += 1
  27. except Exception as e:
  28. print('Could not delete %s: %s.' % (fname, e))
  29. failures += 1
  30. print('\nUninstall finished.\n')
  31. print('Deleted:', successes)
  32. print('Failed:', failures)
  33. print('\nRemember that files created by custom scripts have not been removed.')
  34. def run(args):
  35. if args:
  36. print('Weird error.')
  37. return 1
  38. if not os.path.exists(logfile):
  39. print('Log file does not exist, no installation has been done.')
  40. return 0
  41. do_uninstall(logfile)
  42. return 0