Use timedatectl provided by systemd to set the time on the target

Use tools provided by systemd to set the time and fall back to
manually doing it via linking /etc/localtime
main
Rohan Garg 9 years ago committed by Teo Mrnjavac
parent 7212aaec74
commit a98742c32c

@ -1,6 +1,7 @@
/* === This file is part of Calamares - <http://github.com/calamares> === /* === This file is part of Calamares - <http://github.com/calamares> ===
* *
* Copyright 2014, Teo Mrnjavac <teo@kde.org> * Copyright 2014, Teo Mrnjavac <teo@kde.org>
* Copyright 2015, Rohan Garg <rohan@garg.io>
* *
* Calamares is free software: you can redistribute it and/or modify * Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -45,6 +46,14 @@ SetTimezoneJob::prettyName() const
Calamares::JobResult Calamares::JobResult
SetTimezoneJob::exec() SetTimezoneJob::exec()
{ {
int ec = CalamaresUtils::System::instance()->
targetEnvCall( { "timedatectl",
"set-timezone",
m_region + '/' + m_zone } );
if ( !ec )
return Calamares::JobResult::ok();
QString localtimeSlink( "/etc/localtime" ); QString localtimeSlink( "/etc/localtime" );
QString zoneinfoPath( "/usr/share/zoneinfo" ); QString zoneinfoPath( "/usr/share/zoneinfo" );
zoneinfoPath.append( QDir::separator() + m_region ); zoneinfoPath.append( QDir::separator() + m_region );
@ -62,7 +71,7 @@ SetTimezoneJob::exec()
"-f", "-f",
localtimeSlink } ); localtimeSlink } );
int ec = CalamaresUtils::System::instance()-> ec = CalamaresUtils::System::instance()->
targetEnvCall( { "ln", targetEnvCall( { "ln",
"-s", "-s",
zoneinfoPath, zoneinfoPath,

Loading…
Cancel
Save