mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-03 20:35:36 -04:00
[keyboard] Refactor writing-various-files
- put the writing of each kind of file in its own block -- this should become separate functions -- so that variables become more local and debugging can be improved. - while here, fix the error message for /etc/default/keyboard: it would complain and name the vconsole file path if it ever failed.
This commit is contained in:
parent
3e51d77782
commit
845fb3f6da
1 changed files with 58 additions and 45 deletions
|
@ -337,60 +337,73 @@ SetKeyboardLayoutJob::exec()
|
||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
QDir destDir( gs->value( "rootMountPoint" ).toString() );
|
QDir destDir( gs->value( "rootMountPoint" ).toString() );
|
||||||
|
|
||||||
// Get the path to the destination's /etc/vconsole.conf
|
|
||||||
QString vconsoleConfPath = destDir.absoluteFilePath( "etc/vconsole.conf" );
|
|
||||||
|
|
||||||
// Get the path to the destination's /etc/X11/xorg.conf.d/00-keyboard.conf
|
|
||||||
QString xorgConfDPath;
|
|
||||||
QString keyboardConfPath;
|
|
||||||
if ( QDir::isAbsolutePath( m_xOrgConfFileName ) )
|
|
||||||
{
|
{
|
||||||
keyboardConfPath = m_xOrgConfFileName;
|
// Get the path to the destination's /etc/vconsole.conf
|
||||||
while ( keyboardConfPath.startsWith( '/' ) )
|
QString vconsoleConfPath = destDir.absoluteFilePath( "etc/vconsole.conf" );
|
||||||
|
|
||||||
|
// Get the path to the destination's path to the converted key mappings
|
||||||
|
QString convertedKeymapPath = m_convertedKeymapPath;
|
||||||
|
if ( !convertedKeymapPath.isEmpty() )
|
||||||
{
|
{
|
||||||
keyboardConfPath.remove( 0, 1 );
|
while ( convertedKeymapPath.startsWith( '/' ) )
|
||||||
|
{
|
||||||
|
convertedKeymapPath.remove( 0, 1 );
|
||||||
|
}
|
||||||
|
convertedKeymapPath = destDir.absoluteFilePath( convertedKeymapPath );
|
||||||
}
|
}
|
||||||
keyboardConfPath = destDir.absoluteFilePath( keyboardConfPath );
|
|
||||||
xorgConfDPath = QFileInfo( keyboardConfPath ).path();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
xorgConfDPath = destDir.absoluteFilePath( "etc/X11/xorg.conf.d" );
|
|
||||||
keyboardConfPath = QDir( xorgConfDPath ).absoluteFilePath( m_xOrgConfFileName );
|
|
||||||
}
|
|
||||||
destDir.mkpath( xorgConfDPath );
|
|
||||||
|
|
||||||
QString defaultKeyboardPath;
|
cDebug() << "Writing VCONSOLE data to" << vconsoleConfPath << convertedKeymapPath;
|
||||||
if ( QDir( destDir.absoluteFilePath( "etc/default" ) ).exists() )
|
if ( !writeVConsoleData( vconsoleConfPath, convertedKeymapPath ) )
|
||||||
{
|
|
||||||
defaultKeyboardPath = destDir.absoluteFilePath( "etc/default/keyboard" );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the path to the destination's path to the converted key mappings
|
|
||||||
QString convertedKeymapPath = m_convertedKeymapPath;
|
|
||||||
if ( !convertedKeymapPath.isEmpty() )
|
|
||||||
{
|
|
||||||
while ( convertedKeymapPath.startsWith( '/' ) )
|
|
||||||
{
|
{
|
||||||
convertedKeymapPath.remove( 0, 1 );
|
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration for the virtual console." ),
|
||||||
|
tr( "Failed to write to %1" ).arg( vconsoleConfPath ) );
|
||||||
}
|
}
|
||||||
convertedKeymapPath = destDir.absoluteFilePath( convertedKeymapPath );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !writeVConsoleData( vconsoleConfPath, convertedKeymapPath ) )
|
|
||||||
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration for the virtual console." ),
|
|
||||||
tr( "Failed to write to %1" ).arg( vconsoleConfPath ) );
|
|
||||||
|
|
||||||
if ( !writeX11Data( keyboardConfPath ) )
|
|
||||||
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration for X11." ),
|
|
||||||
tr( "Failed to write to %1" ).arg( keyboardConfPath ) );
|
|
||||||
|
|
||||||
if ( !defaultKeyboardPath.isEmpty() && m_writeEtcDefaultKeyboard )
|
|
||||||
{
|
{
|
||||||
if ( !writeDefaultKeyboardData( defaultKeyboardPath ) )
|
// Get the path to the destination's /etc/X11/xorg.conf.d/00-keyboard.conf
|
||||||
return Calamares::JobResult::error(
|
QString xorgConfDPath;
|
||||||
tr( "Failed to write keyboard configuration to existing /etc/default directory." ),
|
QString keyboardConfPath;
|
||||||
tr( "Failed to write to %1" ).arg( keyboardConfPath ) );
|
if ( QDir::isAbsolutePath( m_xOrgConfFileName ) )
|
||||||
|
{
|
||||||
|
keyboardConfPath = m_xOrgConfFileName;
|
||||||
|
while ( keyboardConfPath.startsWith( '/' ) )
|
||||||
|
{
|
||||||
|
keyboardConfPath.remove( 0, 1 );
|
||||||
|
}
|
||||||
|
keyboardConfPath = destDir.absoluteFilePath( keyboardConfPath );
|
||||||
|
xorgConfDPath = QFileInfo( keyboardConfPath ).path();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xorgConfDPath = destDir.absoluteFilePath( "etc/X11/xorg.conf.d" );
|
||||||
|
keyboardConfPath = QDir( xorgConfDPath ).absoluteFilePath( m_xOrgConfFileName );
|
||||||
|
}
|
||||||
|
destDir.mkpath( xorgConfDPath );
|
||||||
|
|
||||||
|
if ( !writeX11Data( keyboardConfPath ) )
|
||||||
|
{
|
||||||
|
return Calamares::JobResult::error( tr( "Failed to write keyboard configuration for X11." ),
|
||||||
|
tr( "Failed to write to %1" ).arg( keyboardConfPath ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
QString defaultKeyboardPath;
|
||||||
|
if ( QDir( destDir.absoluteFilePath( "etc/default" ) ).exists() )
|
||||||
|
{
|
||||||
|
defaultKeyboardPath = destDir.absoluteFilePath( "etc/default/keyboard" );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !defaultKeyboardPath.isEmpty() && m_writeEtcDefaultKeyboard )
|
||||||
|
{
|
||||||
|
if ( !writeDefaultKeyboardData( defaultKeyboardPath ) )
|
||||||
|
{
|
||||||
|
return Calamares::JobResult::error(
|
||||||
|
tr( "Failed to write keyboard configuration to existing /etc/default directory." ),
|
||||||
|
tr( "Failed to write to %1" ).arg( defaultKeyboardPath ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue