[chrootcfg] PEP8 modification
This commit is contained in:
parent
779f602df7
commit
4b19c677b3
@ -4,6 +4,7 @@
|
|||||||
# === This file is part of Calamares - <http://github.com/calamares> ===
|
# === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
#
|
#
|
||||||
# Copyright 2016, Artoo <artoo@manjaro.org>
|
# Copyright 2016, Artoo <artoo@manjaro.org>
|
||||||
|
# Copyright 2017, Philip Müller <philm@manjaro.org>
|
||||||
#
|
#
|
||||||
# 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
|
||||||
@ -18,14 +19,18 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os, shutil, subprocess, sys, re
|
import os
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import re
|
||||||
import libcalamares
|
import libcalamares
|
||||||
|
|
||||||
from libcalamares.utils import check_target_env_call, target_env_call, debug
|
from libcalamares.utils import check_target_env_call, target_env_call, debug
|
||||||
from os.path import join
|
from os.path import join
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
|
|
||||||
|
|
||||||
class OperationTracker:
|
class OperationTracker:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._downloaded = 0
|
self._downloaded = 0
|
||||||
@ -82,9 +87,14 @@ ON_POSIX = 'posix' in sys.builtin_module_names
|
|||||||
class PacmanController:
|
class PacmanController:
|
||||||
def __init__(self, root):
|
def __init__(self, root):
|
||||||
self.__root = root
|
self.__root = root
|
||||||
self.__operations = libcalamares.globalstorage.value("packageOperations")
|
self.__operations = libcalamares.globalstorage.value(
|
||||||
|
"packageOperations"
|
||||||
|
)
|
||||||
self.__tracker = OperationTracker()
|
self.__tracker = OperationTracker()
|
||||||
self.__keyrings = libcalamares.job.configuration.get('keyrings', [])
|
self.__keyrings = libcalamares.job.configuration.get(
|
||||||
|
'keyrings',
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tracker(self):
|
def tracker(self):
|
||||||
@ -114,7 +124,13 @@ class PacmanController:
|
|||||||
last = []
|
last = []
|
||||||
phase = 0
|
phase = 0
|
||||||
|
|
||||||
process = subprocess.Popen(cmd, env=cal_env, bufsize=1, stdout=subprocess.PIPE, close_fds=ON_POSIX)
|
process = subprocess.Popen(
|
||||||
|
cmd,
|
||||||
|
env=cal_env,
|
||||||
|
bufsize=1,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
close_fds=ON_POSIX
|
||||||
|
)
|
||||||
|
|
||||||
for line in iter(process.stdout.readline, b''):
|
for line in iter(process.stdout.readline, b''):
|
||||||
pkgs = re.findall(r'\((\d+)\)', line.decode())
|
pkgs = re.findall(r'\((\d+)\)', line.decode())
|
||||||
@ -141,7 +157,6 @@ class PacmanController:
|
|||||||
debug("Installed packages: {}".format(self.tracker.installed))
|
debug("Installed packages: {}".format(self.tracker.installed))
|
||||||
self.tracker.send_progress(self.tracker.installed, phase)
|
self.tracker.send_progress(self.tracker.installed, phase)
|
||||||
|
|
||||||
|
|
||||||
if process.returncode != 0:
|
if process.returncode != 0:
|
||||||
return process.kill()
|
return process.kill()
|
||||||
|
|
||||||
@ -156,7 +171,14 @@ class PacmanController:
|
|||||||
else:
|
else:
|
||||||
args.extend(["-Sy"])
|
args.extend(["-Sy"])
|
||||||
|
|
||||||
args.extend(["--cachedir", cachedir, "--root", self.root, "--dbpath", dbdir])
|
args.extend([
|
||||||
|
"--cachedir",
|
||||||
|
cachedir,
|
||||||
|
"--root",
|
||||||
|
self.root,
|
||||||
|
"--dbpath",
|
||||||
|
dbdir
|
||||||
|
])
|
||||||
cmd = args + pkglist
|
cmd = args + pkglist
|
||||||
self.parse_output(cmd)
|
self.parse_output(cmd)
|
||||||
|
|
||||||
@ -195,10 +217,14 @@ class PacmanController:
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class ChrootController:
|
class ChrootController:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__root = libcalamares.globalstorage.value('rootMountPoint')
|
self.__root = libcalamares.globalstorage.value('rootMountPoint')
|
||||||
self.__requirements = libcalamares.job.configuration.get('requirements', [])
|
self.__requirements = libcalamares.job.configuration.get(
|
||||||
|
'requirements',
|
||||||
|
[]
|
||||||
|
)
|
||||||
self.__isRank = libcalamares.job.configuration['isRank']
|
self.__isRank = libcalamares.job.configuration['isRank']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -226,8 +252,11 @@ class ChrootController:
|
|||||||
call(["pacman-mirrors", "-f", "5"])
|
call(["pacman-mirrors", "-f", "5"])
|
||||||
|
|
||||||
def copy_file(self, file):
|
def copy_file(self, file):
|
||||||
if os.path.exists(os.path.join("/",file)):
|
if os.path.exists(os.path.join("/", file)):
|
||||||
shutil.copy2(os.path.join("/",file), os.path.join(self.root, file))
|
shutil.copy2(
|
||||||
|
os.path.join("/", file),
|
||||||
|
os.path.join(self.root, file)
|
||||||
|
)
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
cal_umask = os.umask(0)
|
cal_umask = os.umask(0)
|
||||||
@ -249,7 +278,10 @@ class ChrootController:
|
|||||||
return pacman.run()
|
return pacman.run()
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
""" Create chroot dirs and install pacman, kernel and netinstall selection """
|
"""
|
||||||
|
Create chroot dirs and install pacman,
|
||||||
|
kernel and netinstall selection
|
||||||
|
"""
|
||||||
|
|
||||||
targetRoot = ChrootController()
|
targetRoot = ChrootController()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user