source: calamares/trunk/fuentes/src/modules/hwclock/main.py @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 17 months ago

sync with github

File size: 2.0 KB
Line 
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3#
4# === This file is part of Calamares - <https://github.com/calamares> ===
5#
6#   Copyright 2014 - 2015, Philip Müller <philm@manjaro.org>
7#   Copyright 2014, Teo Mrnjavac <teo@kde.org>
8#   Copyright 2017, Alf Gaida <agaida@siduction.org>
9#   Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org>
10#
11#   Calamares is free software: you can redistribute it and/or modify
12#   it under the terms of the GNU General Public License as published by
13#   the Free Software Foundation, either version 3 of the License, or
14#   (at your option) any later version.
15#
16#   Calamares is distributed in the hope that it will be useful,
17#   but WITHOUT ANY WARRANTY; without even the implied warranty of
18#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19#   GNU General Public License for more details.
20#
21#   You should have received a copy of the GNU General Public License
22#   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
23
24import libcalamares
25
26def run():
27    """
28    Set hardware clock.
29    """
30    hwclock_rtc = ["hwclock", "--systohc", "--utc"]
31    hwclock_isa = ["hwclock", "--systohc", "--utc", "--directisa"]
32    is_broken_rtc = False
33    is_broken_isa = False
34
35    ret = libcalamares.utils.target_env_call(hwclock_rtc)
36    if ret != 0:
37        is_broken_rtc = True
38        libcalamares.utils.debug("Hwclock returned error code {}".format(ret))
39        libcalamares.utils.debug("  .. RTC method failed, trying ISA bus method.")
40    else:
41        libcalamares.utils.debug("Hwclock set using RTC method.")
42    if is_broken_rtc:
43        ret = libcalamares.utils.target_env_call(hwclock_isa)
44        if  ret != 0:
45            is_broken_isa = True
46            libcalamares.utils.debug("Hwclock returned error code {}".format(ret))
47            libcalamares.utils.debug("  .. ISA bus method failed.")
48        else:
49            libcalamares.utils.debug("Hwclock set using ISA bus method.")
50    if is_broken_rtc and is_broken_isa:
51        libcalamares.utils.debug("BIOS or Kernel BUG: Setting hwclock failed.")
52
53    return None
Note: See TracBrowser for help on using the repository browser.