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:32:26 -05:00
|
|
|
from shutil import copyfile
|
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
|
|
|
|
2024-12-20 11:43:43 -05:00
|
|
|
print("DEBUG: Current working directory:", os.getcwd())
|
|
|
|
|
2024-12-20 11:04:13 -05:00
|
|
|
# Handle locale files
|
|
|
|
locale_files = glob.glob('locale/*/LC_MESSAGES/*.mo')
|
2024-12-20 11:43:43 -05:00
|
|
|
print("DEBUG: Found locale files:", locale_files)
|
2024-12-20 11:04:13 -05:00
|
|
|
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:43:43 -05:00
|
|
|
# Handle configuration files
|
2024-12-20 11:32:26 -05:00
|
|
|
directories = glob.glob('config/*')
|
2024-12-20 11:43:43 -05:00
|
|
|
print("DEBUG: Found config directories:", directories)
|
2024-12-20 11:32:26 -05:00
|
|
|
for directory in directories:
|
|
|
|
files = glob.glob(directory+'/*')
|
2024-12-20 11:43:43 -05:00
|
|
|
print(f"DEBUG: Found files in {directory}:", files)
|
2024-12-20 11:32:26 -05:00
|
|
|
dest_dir = ''
|
|
|
|
if 'config/punctuation' in directory:
|
|
|
|
dest_dir = '/etc/fenrirscreenreader/punctuation'
|
|
|
|
elif 'config/keyboard' in directory:
|
|
|
|
dest_dir = '/etc/fenrirscreenreader/keyboard'
|
|
|
|
elif 'config/settings' in directory:
|
|
|
|
dest_dir = '/etc/fenrirscreenreader/settings'
|
|
|
|
if not force_settings:
|
|
|
|
try:
|
|
|
|
files.remove('config/settings/settings.conf')
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
elif 'config/scripts' in directory:
|
|
|
|
dest_dir = '/usr/share/fenrirscreenreader/scripts'
|
|
|
|
if dest_dir:
|
2024-12-20 11:43:43 -05:00
|
|
|
print(f"DEBUG: Adding files to {dest_dir}:", files)
|
2024-12-20 11:32:26 -05:00
|
|
|
data_files.append((dest_dir, files))
|
2024-12-20 11:22:09 -05:00
|
|
|
|
2024-12-20 11:32:26 -05:00
|
|
|
# Handle sound files
|
|
|
|
files = glob.glob('config/sound/default/*')
|
2024-12-20 11:43:43 -05:00
|
|
|
print("DEBUG: Found default sound files:", files)
|
|
|
|
if files:
|
|
|
|
data_files.append(('/usr/share/sounds/fenrirscreenreader/default', files))
|
|
|
|
|
2024-12-20 11:32:26 -05:00
|
|
|
files = glob.glob('config/sound/template/*')
|
2024-12-20 11:43:43 -05:00
|
|
|
print("DEBUG: Found template sound files:", files)
|
|
|
|
if files:
|
|
|
|
data_files.append(('/usr/share/sounds/fenrirscreenreader/template', files))
|
2024-12-20 08:57:27 -05:00
|
|
|
|
2024-12-20 11:22:09 -05:00
|
|
|
# Handle tools directory
|
2024-12-20 11:32:26 -05:00
|
|
|
files = glob.glob('tools/*')
|
2024-12-20 11:43:43 -05:00
|
|
|
if files:
|
|
|
|
data_files.append(('/usr/share/fenrirscreenreader/tools', files))
|
2024-12-20 11:22:09 -05:00
|
|
|
|
|
|
|
# Add man page
|
2024-12-20 11:43:43 -05:00
|
|
|
if os.path.exists('docs/fenrir.1'):
|
|
|
|
data_files.append(('/usr/share/man/man1', ['docs/fenrir.1']))
|
|
|
|
|
|
|
|
print("\nDEBUG: Final data_files list:")
|
|
|
|
for dest, files in data_files:
|
|
|
|
print(f" {dest}:")
|
|
|
|
for f in files:
|
|
|
|
print(f" - {f}")
|
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__":
|
2024-12-20 11:32:26 -05:00
|
|
|
setup(
|
|
|
|
data_files=get_data_files(),
|
|
|
|
)
|
2024-12-20 11:22:09 -05:00
|
|
|
|
2024-12-20 11:32:26 -05:00
|
|
|
force_settings = os.environ.get('FENRIR_FORCE_SETTINGS') == '1'
|
|
|
|
if not force_settings:
|
|
|
|
print('')
|
|
|
|
if not os.path.isfile('/etc/fenrirscreenreader/settings/settings.conf'):
|
2017-10-21 10:03:03 -04:00
|
|
|
try:
|
2024-12-20 11:32:26 -05:00
|
|
|
copyfile('/etc/fenrirscreenreader/settings/settings.conf.example',
|
|
|
|
'/etc/fenrirscreenreader/settings/settings.conf')
|
|
|
|
print('create settings file in /etc/fenrirscreenreader/settings/settings.conf')
|
2024-12-20 11:43:43 -05:00
|
|
|
except Exception as e:
|
|
|
|
print("DEBUG: Error copying settings file:", e)
|
2024-12-20 11:32:26 -05:00
|
|
|
pass
|
|
|
|
else:
|
|
|
|
print('settings.conf file found. It is not overwritten automatically')
|
|
|
|
|
|
|
|
print('')
|
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:32:26 -05:00
|
|
|
print('Please 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')
|