-
Notifications
You must be signed in to change notification settings - Fork 345
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
jkonecny12
merged 4 commits into
rhinstaller:master
from
jkonecny12:master-add-atomic-install-class
Feb 9, 2018
Merged
Add Atomic install class #1311
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0555e25
Move Atomic install class to Anaconda (#1491287) (#1536853)
jkonecny12 048c880
Migrate Atomic install class (#1491287)
jkonecny12 d025d2f
Clean code of Atomic install class
jkonecny12 2a6fd3a
Use Fedora Server default partitioning in Atomic
jkonecny12 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.