chrootcfg: rank mirrors fasttrack on host

The ranking at boot is too unreliable
This commit is contained in:
udeved 2017-04-07 22:11:41 +02:00 committed by Philip
parent 1ee2a76ef3
commit 24c877b36e
2 changed files with 16 additions and 7 deletions

View File

@ -7,6 +7,8 @@ requirements:
- name: /var/lib/pacman - name: /var/lib/pacman
mode: "0o755" mode: "0o755"
isRank: true
keyrings: keyrings:
- archlinux - archlinux
- manjaro - manjaro

View File

@ -24,6 +24,7 @@ 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
class OperationTracker: class OperationTracker:
def __init__(self): def __init__(self):
@ -107,9 +108,6 @@ class PacmanController:
def populate_keyring(self): def populate_keyring(self):
target_env_call(["pacman-key", "--populate"] + self.keyrings) target_env_call(["pacman-key", "--populate"] + self.keyrings)
def rank_mirrors(self):
check_target_env_call(["pacman-mirrors", "-g", "-m", "rank"])
def parse_output(self, cmd): def parse_output(self, cmd):
cal_env = os.environ cal_env = os.environ
cal_env["LC_ALL"] = "C" cal_env["LC_ALL"] = "C"
@ -167,7 +165,7 @@ class PacmanController:
cmd = args + pkglist cmd = args + pkglist
check_target_env_call(cmd) check_target_env_call(cmd)
def run(self, rank=False): def run(self):
pkgs = [] pkgs = []
for key in self.operations.keys(): for key in self.operations.keys():
if key == "install": if key == "install":
@ -194,8 +192,6 @@ class PacmanController:
self.init_keyring() self.init_keyring()
self.populate_keyring() self.populate_keyring()
if rank:
self.rank_mirrors()
return None return None
@ -203,11 +199,16 @@ 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']
@property @property
def root(self): def root(self):
return self.__root return self.__root
@property
def isRank(self):
return self.__isRank
@property @property
def requirements(self): def requirements(self):
return self.__requirements return self.__requirements
@ -221,6 +222,9 @@ class ChrootController:
debug("Mode: {}".format(oct(mod))) debug("Mode: {}".format(oct(mod)))
os.makedirs(dest, mode=mod) os.makedirs(dest, mode=mod)
def rank_mirrors(self):
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))
@ -236,10 +240,13 @@ class ChrootController:
self.copy_file('etc/resolv.conf') self.copy_file('etc/resolv.conf')
def run(self): def run(self):
if self.isRank:
self.rank_mirrors()
self.prepare() self.prepare()
pacman = PacmanController(self.root) pacman = PacmanController(self.root)
return pacman.run(rank=False) 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 """