Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Atomic install class #1311

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyanaconda/installclasses/fedora_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class FedoraServerInstallClass(FedoraBaseInstallClass):
hidden = True

def setDefaultPartitioning(self, storage):
self.createDefaultPartitioning(storage)

@staticmethod
def createDefaultPartitioning(storage):
autorequests = [PartSpec(mountpoint="/", fstype=storage.default_fstype,
size=Size("2GiB"),
max_size=Size("15GiB"),
Expand Down
119 changes: 119 additions & 0 deletions pyanaconda/installclasses/installclass_atomic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#
# installclass_atomic.py
#
# Atomic-specific partitioning defaults
#
# Copyright (C) 2014 Red Hat, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import os
import shutil
from pyanaconda.installclasses.fedora import FedoraBaseInstallClass
from pyanaconda.installclasses.fedora_server import FedoraServerInstallClass
from pyanaconda.product import productVariant
from pyanaconda.core import util

import logging
log = logging.getLogger("anaconda")

__all__ = ['AtomicInstallClass']


class AtomicInstallClass(FedoraBaseInstallClass):
name = "Atomic Host"
stylesheet = "/usr/share/anaconda/pixmaps/atomic/fedora-atomic.css"
sortPriority = FedoraBaseInstallClass.sortPriority + 1
defaultFS = "xfs"

if productVariant != "Atomic":
hidden = True

def __init__(self):
self.localemap = {} # loaded lazily
FedoraBaseInstallClass.__init__(self)

def setDefaultPartitioning(self, storage):
FedoraServerInstallClass.createDefaultPartitioning(storage)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this install class be based on Fedora Server install class?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I'm not sure we want to do that. Yeah this one method is the same but what if FedoraServer will change something else in future.

Basically I don't think we want to mix hierarchy in this. If something we can use that mixin but these install classes are not extending one to other by principle.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I don't like this solution, but we will change install classes anyway.


def filterSupportedLangs(self, ksdata, langs):
self._initialize_localemap(ksdata.ostreesetup.ref,
ksdata.ostreesetup.url)
for lang in langs:
if lang in self.localemap:
yield lang

def filterSupportedLocales(self, ksdata, lang, locales):
self._initialize_localemap(ksdata.ostreesetup.ref,
ksdata.ostreesetup.url)
supported = []
if lang in self.localemap:
for locale in locales:
stripped = self._strip_codeset_and_modifier(locale)
if stripped in self.localemap[lang]:
supported.append(locale)
return supported

def _initialize_localemap(self, ref, repo):

if self.localemap:
return

# fallback to just en_US in case of errors
self.localemap = {"en": ["en_US"]}

# Let's only handle local embedded repos for now. Anyway, it'd probably
# not be very common to only override ostreesetup through kickstart and
# still want the interactive installer. Though to be nice, let's handle
# that case.
if not repo.startswith("file://"):
log.info("ostree repo is not local; defaulting to en_US")
return

# convert to regular UNIX path
repo = repo[len("file://"):]

util.mkdirChain(os.path.join(repo, "tmp/usr/lib"))
rc = util.execWithRedirect("/usr/bin/ostree",
["checkout", "--repo", repo, ref,
"--subpath", "/usr/lib/locale/locale-archive",
"%s/tmp/usr/lib/locale" % repo])
if rc != 0:
log.error("failed to check out locale-archive; check program.log")
return

for line in util.execReadlines("/usr/bin/localedef",
["--prefix", os.path.join(repo, "tmp"),
"--list-archive"]):
line = self._strip_codeset_and_modifier(line)
if '_' in line:
(lang, _territory) = line.split('_', 1)
else:
lang = line
if lang not in self.localemap:
self.localemap[lang] = [line]
else:
self.localemap[lang].append(line)

# nuke the checkout for good measure
shutil.rmtree(os.path.join(repo, "tmp/usr"))

@staticmethod
def _strip_codeset_and_modifier(locale):
if '@' in locale:
locale = locale[:locale.find('@')]
if '.' in locale:
locale = locale[:locale.find('.')]
return locale