From 94883b3c922caccb2de009d0a9994a2fe037c182 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 19 Mar 2020 14:11:54 -0700 Subject: [PATCH] setup.py: Remove files shipped in the past - This only effects development environments where ./setup.py is run but not the shipped product. - Write log messages about removing the files only when actually removing the file. This is so that the log output is quiet when no action is taken (typical). Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- setup.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 8ff5a860a..1253a9802 100755 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ FreedomBox Service setup file. import collections import glob import os +import pathlib import re import shutil import subprocess @@ -42,6 +43,12 @@ DISABLED_APPS_TO_REMOVE = [ 'xmpp', 'disks', 'udiskie', + 'restore', + 'repro', +] + +REMOVED_FILES = [ + '/etc/apt/preferences.d/50freedombox3.pref', ] LOCALE_PATHS = ['plinth/locale'] @@ -121,11 +128,16 @@ class CustomClean(clean): class CustomInstall(install): """Override install command.""" def run(self): - log.info("Removing disabled apps") for app in DISABLED_APPS_TO_REMOVE: - file_path = os.path.join(ENABLED_APPS_PATH, app) - log.info("removing '%s'", file_path) - subprocess.check_call(['rm', '-f', file_path]) + file_path = pathlib.Path(ENABLED_APPS_PATH) / app + if file_path.exists(): + log.info("removing '%s'", str(file_path)) + subprocess.check_call(['rm', '-f', str(file_path)]) + + for path in REMOVED_FILES: + if pathlib.Path(path).exists(): + log.info('removing %s', path) + subprocess.check_call(['rm', '-f', path]) install.run(self)