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