2022-04-09 05:14:48 -04:00
|
|
|
#!/usr/bin/env python3
|
2024-12-20 11:04:13 -05:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import glob
|
2024-12-20 11:22:09 -05:00
|
|
|
import shutil
|
2016-10-04 17:07:19 -04:00
|
|
|
from setuptools import setup
|
2017-10-20 15:24:50 -04:00
|
|
|
|
2024-12-20 11:09:32 -05:00
|
|
|
def get_data_files():
|
2024-12-20 11:04:13 -05:00
|
|
|
data_files = []
|
2024-12-20 11:09:32 -05:00
|
|
|
force_settings = os.environ.get('FENRIR_FORCE_SETTINGS') == '1'
|
2024-12-20 11:04:13 -05:00
|
|
|
|
|
|
|
# Handle locale files
|
|
|
|
locale_files = glob.glob('locale/*/LC_MESSAGES/*.mo')
|
|
|
|
for locale_file in locale_files:
|
|
|
|
lang = locale_file.split(os.sep)[1]
|
|
|
|
dest_dir = f'/usr/share/locale/{lang}/LC_MESSAGES'
|
|
|
|
data_files.append((dest_dir, [locale_file]))
|
2017-07-25 11:19:40 -04:00
|
|
|
|
2024-12-20 11:22:09 -05:00
|
|
|
# Handle /etc/fenrirscreenreader directories
|
|
|
|
etc_dirs = {
|
|
|
|
'keyboard': '/etc/fenrirscreenreader/keyboard',
|
|
|
|
'punctuation': '/etc/fenrirscreenreader/punctuation',
|
|
|
|
'settings': '/etc/fenrirscreenreader/settings'
|
|
|
|
}
|
|
|
|
|
|
|
|
for src_dir, dest_dir in etc_dirs.items():
|
|
|
|
src_path = f'config/{src_dir}'
|
|
|
|
if os.path.exists(src_path):
|
|
|
|
files = glob.glob(f'{src_path}/*')
|
|
|
|
if src_dir == 'settings':
|
|
|
|
if not force_settings:
|
|
|
|
# Remove settings.conf if it exists in the list
|
|
|
|
files = [f for f in files if not f.endswith('settings.conf')]
|
|
|
|
# Ensure settings.conf.example is included
|
|
|
|
example_file = os.path.join(src_path, 'settings.conf.example')
|
|
|
|
if os.path.exists(example_file) and example_file not in files:
|
|
|
|
files.append(example_file)
|
|
|
|
if files: # Only add if there are files to copy
|
|
|
|
data_files.append((dest_dir, files))
|
|
|
|
|
|
|
|
# Handle /usr/share/fenrirscreenreader directories
|
|
|
|
share_dirs = {
|
|
|
|
'scripts': '/usr/share/fenrirscreenreader/scripts',
|
|
|
|
}
|
|
|
|
|
|
|
|
for src_dir, dest_dir in share_dirs.items():
|
|
|
|
src_path = f'config/{src_dir}'
|
|
|
|
if os.path.exists(src_path):
|
|
|
|
files = glob.glob(f'{src_path}/*')
|
|
|
|
if files: # Only add if there are files to copy
|
|
|
|
data_files.append((dest_dir, files))
|
|
|
|
|
|
|
|
# Handle sound directory separately since it has subdirectories
|
|
|
|
sound_src = 'config/sound'
|
|
|
|
if os.path.exists(sound_src):
|
|
|
|
# Handle default sounds
|
|
|
|
default_files = glob.glob(f'{sound_src}/default/*')
|
|
|
|
if default_files:
|
|
|
|
data_files.append(('/usr/share/sounds/fenrirscreenreader/default', default_files))
|
|
|
|
|
|
|
|
# Handle template sounds
|
|
|
|
template_files = glob.glob(f'{sound_src}/template/*')
|
|
|
|
if template_files:
|
|
|
|
data_files.append(('/usr/share/sounds/fenrirscreenreader/template', template_files))
|
2024-12-20 08:57:27 -05:00
|
|
|
|
2024-12-20 11:22:09 -05:00
|
|
|
# Handle tools directory
|
|
|
|
tools_files = glob.glob('tools/*')
|
|
|
|
if tools_files:
|
|
|
|
data_files.append(('/usr/share/fenrirscreenreader/tools', tools_files))
|
|
|
|
|
|
|
|
# Add man page
|
|
|
|
if os.path.exists('docs/fenrir.1'):
|
|
|
|
data_files.append(('/usr/share/man/man1', ['docs/fenrir.1']))
|
2024-12-20 08:57:27 -05:00
|
|
|
|
2024-12-20 11:04:13 -05:00
|
|
|
return data_files
|
|
|
|
|
2024-12-20 11:22:09 -05:00
|
|
|
if __name__ == "__main__":
|
|
|
|
setup(data_files=get_data_files())
|
|
|
|
|
|
|
|
# Post-install setup for settings.conf if needed
|
|
|
|
if not os.environ.get('FENRIR_FORCE_SETTINGS') == '1':
|
|
|
|
settings_path = '/etc/fenrirscreenreader/settings/settings.conf'
|
|
|
|
example_path = '/etc/fenrirscreenreader/settings/settings.conf.example'
|
|
|
|
if not os.path.exists(settings_path) and os.path.exists(example_path):
|
2017-10-21 10:03:03 -04:00
|
|
|
try:
|
2024-12-20 11:22:09 -05:00
|
|
|
shutil.copyfile(example_path, settings_path)
|
|
|
|
print(f'Created settings file: {settings_path}')
|
|
|
|
except Exception as e:
|
|
|
|
print(f'Note: Could not create {settings_path}: {e}')
|
|
|
|
|
|
|
|
print('\nSetup complete!')
|
2024-12-20 11:04:13 -05:00
|
|
|
print('To have Fenrir start at boot:')
|
|
|
|
print('sudo systemctl enable fenrir')
|
|
|
|
print('Pulseaudio users may want to run:')
|
|
|
|
print('/usr/share/fenrirscreenreader/tools/configure_pulse.sh')
|
|
|
|
print('once as their user account and once as root to configure Pulseaudio.')
|
2024-12-20 11:22:09 -05:00
|
|
|
print('\nPlease install the following packages manually:')
|
2024-12-20 11:04:13 -05:00
|
|
|
print('- Speech-dispatcher: for the default speech driver')
|
|
|
|
print('- Espeak: as basic TTS engine')
|
|
|
|
print('- sox: is a player for the generic sound driver')
|