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 <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2020-03-19 14:11:54 -07:00 committed by James Valleroy
parent 6179d98a07
commit 94883b3c92
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -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)