Skip to content
Snippets Groups Projects
Commit bf9472c3 authored by Ben Morrice's avatar Ben Morrice
Browse files

Add support for CS8

- Fix broken C8
- use dnf-automatic on 8 family systems
parent 1cb33824
No related branches found
No related tags found
1 merge request!3Add support for CS8
Pipeline #2437123 canceled
Name: cern-anaconda-addon Name: cern-anaconda-addon
Version: 1.7 Version: 1.8
Release: 1%{?dist} Release: 1%{?dist}
Summary: CERN configuration anaconda addon Summary: CERN configuration anaconda addon
...@@ -31,6 +31,10 @@ install -p -m 644 data/cern.svg %{buildroot}/%{_datadir}/icons/hicolor/scalable/ ...@@ -31,6 +31,10 @@ install -p -m 644 data/cern.svg %{buildroot}/%{_datadir}/icons/hicolor/scalable/
%doc LICENSE README.md %doc LICENSE README.md
%changelog %changelog
* Thu Mar 18 2021 Ben Morrice <ben.morrice@cern.ch> - 1.8-1
- Add support for CentOS Stream 8
- Use dnf-automatic instead of yum-autoupdate on 8 family systems
* Tue Jan 28 2020 Ben Morrice <ben.morrice@cern.ch> - 1.7-1 * Tue Jan 28 2020 Ben Morrice <ben.morrice@cern.ch> - 1.7-1
- Add support for C8 - Add support for C8
......
release=open('/etc/redhat-release','r').read().split(' ')[3].split('.')[0] release=open('/etc/redhat-release','r').read().split(' ')[3].split('.')[0].rstrip()
if release == '8': if release == '8':
# to be adjusted later, postfix and dnsmasq # to be adjusted later, postfix and dnsmasq
LOCMAP_CORE_MODULES = ["ssh", "sudo", "chrony", "kerberos", "lpadmin"] LOCMAP_CORE_MODULES = ["ssh", "sudo", "chrony", "kerberos", "lpadmin"]
......
...@@ -28,8 +28,8 @@ class CernSpoke(FirstbootOnlySpokeMixIn, NormalSpoke): ...@@ -28,8 +28,8 @@ class CernSpoke(FirstbootOnlySpokeMixIn, NormalSpoke):
icon = "applications-science-symbolic" icon = "applications-science-symbolic"
title = N_("_CERN CUSTOMIZATIONS") title = N_("_CERN CUSTOMIZATIONS")
def __init__(self, data, storage, payload, instclass): def __init__(self, data, storage, payload):
NormalSpoke.__init__(self, data, storage, payload, instclass) NormalSpoke.__init__(self, data, storage, payload)
def initialize(self): def initialize(self):
NormalSpoke.initialize(self) NormalSpoke.initialize(self)
...@@ -143,4 +143,4 @@ class CernFirstbootDialog(GUIObject): ...@@ -143,4 +143,4 @@ class CernFirstbootDialog(GUIObject):
ret = self.window.run() ret = self.window.run()
self.window.destroy() self.window.destroy()
return ret return ret
\ No newline at end of file
...@@ -7,12 +7,25 @@ import sys ...@@ -7,12 +7,25 @@ import sys
from pyanaconda.addons import AddonData from pyanaconda.addons import AddonData
from inspect import signature, Parameter
AddonDataSetupArgs=[]
for x, p in signature(AddonData.setup).parameters.items():
if p.default == Parameter.empty and p.kind != Parameter.VAR_POSITIONAL:
AddonDataSetupArgs.append(x)
# C8 # C8
if (sys.version_info > (3, 0)): if (sys.version_info > (3, 0)):
from pyanaconda.core.util import getSysroot try:
from pyanaconda.core.configuration.anaconda import conf
system_root = conf.target.system_root
# older versions
except:
from pyanaconda.core.util import getSysroot
system_root = getSysroot()
# CC7 # CC7
else: else:
from pyanaconda.iutil import getSysroot from pyanaconda.iutil import getSysroot
system_root = getSysroot()
from cern_customizations.constants import SYSCONFIG_FILE_PATH, \ from cern_customizations.constants import SYSCONFIG_FILE_PATH, \
AFS_IS_DEFAULT, EOS_IS_DEFAULT, CVMFS_IS_DEFAULT, \ AFS_IS_DEFAULT, EOS_IS_DEFAULT, CVMFS_IS_DEFAULT, \
AUTOUPDATE_IS_DEFAULT, RUN_IS_DEFAULT, LOCMAP_BIN, \ AUTOUPDATE_IS_DEFAULT, RUN_IS_DEFAULT, LOCMAP_BIN, \
...@@ -24,6 +37,8 @@ from cern_customizations.constants import SYSCONFIG_FILE_PATH, \ ...@@ -24,6 +37,8 @@ from cern_customizations.constants import SYSCONFIG_FILE_PATH, \
from pykickstart.options import KSOptionParser from pykickstart.options import KSOptionParser
from pykickstart.errors import KickstartParseError, formatErrorMsg from pykickstart.errors import KickstartParseError, formatErrorMsg
from pykickstart.version import versionToLongString, RHEL8
# export CernData class to prevent Anaconda's collect method from taking # export CernData class to prevent Anaconda's collect method from taking
# # AddonData class instead of the CernData class # # AddonData class instead of the CernData class
# # :see: pyanaconda.kickstart.AnacondaKSHandler.__init__ # # :see: pyanaconda.kickstart.AnacondaKSHandler.__init__
...@@ -91,39 +106,33 @@ class CernData(AddonData): ...@@ -91,39 +106,33 @@ class CernData(AddonData):
:type args: list :type args: list
""" """
opc = KSOptionParser() opc = KSOptionParser(version=RHEL8, description='CERN addon',prog='CERN')
opc.add_option("--afs-client", action="store_true", default=True, opc.add_argument("--afs-client", action="store_true", default=True,
dest="afs", help="Install and configure Openafs client") dest="afs", help="Install and configure Openafs client",
version=RHEL8)
opc.add_option("--auto-update", action="store_true", default=True,
dest="autoupdate", help="Enable automatic system updates")
opc.add_option("--auto-update-boot", action="store_true", default=False,
dest="autoupdateboot", help="Enable automatic system updates at boot")
#opc.add_option("--eos-client", action="store_true", default=False, opc.add_argument("--auto-update", action="store_true", default=True,
# dest="eos", help="Install and configure Fuse EOS client") dest="autoupdate", help="Enable automatic system updates",
version=RHEL8)
opc.add_option("--cvmfs-client", action="store_true", default=False, opc.add_argument("--auto-update-boot", action="store_true", default=False,
dest="cvmfs", help="Install and configure Fuse CVMFS client") dest="autoupdateboot", help="Enable automatic system updates at boot",
version=RHEL8)
opc.add_option("--gnome-initial-setup", action="store_true", default=False, opc.add_argument("--cvmfs-client", action="store_true", default=False,
dest="gnomeinit", help="Run Gnome initial setup after first login") dest="cvmfs", help="Install and configure Fuse CVMFS client",
version=RHEL8)
opc.add_option("--run-locmap", action="store_true", default=True, opc.add_argument("--gnome-initial-setup", action="store_true", default=False,
dest="run", help="Run locmap at firstboot") dest="gnomeinit", help="Run Gnome initial setup after first login",
(opts, extra) = opc.parse_args(args=args, lineno=lineno) version=RHEL8)
# Reject any additional arguments. opc.add_argument("--run-locmap", action="store_true", default=True,
if extra: dest="run", help="Run locmap at firstboot",
msg = "Unhandled arguments on %s %%addon line for %s" % (self.name, extra) version=RHEL8)
if lineno is not None: opts = opc.parse_args(args=args, lineno=lineno)
raise KickstartParseError(formatErrorMsg(lineno, msg=msg))
else:
raise KickstartParseError(msg)
self.afs = opts.afs self.afs = opts.afs
#self.eos = opts.eos
self.run = opts.run self.run = opts.run
self.cvmfs = opts.cvmfs self.cvmfs = opts.cvmfs
self.autoupdate = opts.autoupdate self.autoupdate = opts.autoupdate
...@@ -150,7 +159,7 @@ class CernData(AddonData): ...@@ -150,7 +159,7 @@ class CernData(AddonData):
""" """
pass pass
def setup(self, storage, ksdata, instclass, payload): def setup(AddonDataSetupArgs):
""" """
The setup method that should make changes to the runtime environment The setup method that should make changes to the runtime environment
according to the data stored in this object. according to the data stored in this object.
...@@ -183,7 +192,8 @@ class CernData(AddonData): ...@@ -183,7 +192,8 @@ class CernData(AddonData):
# this is a mandatory spoke, user must check it # this is a mandatory spoke, user must check it
return True return True
def execute(self, storage, ksdata, instclass, users, payload): def execute(self, storage, ksdata, users, payload):
""" """
The execute method that should make changes to the installed system. It The execute method that should make changes to the installed system. It
is called only once in the post-install setup phase. is called only once in the post-install setup phase.
...@@ -193,10 +203,10 @@ class CernData(AddonData): ...@@ -193,10 +203,10 @@ class CernData(AddonData):
:type users: pyanaconda.users.Users instance :type users: pyanaconda.users.Users instance
""" """
yumupdate_file = os.path.normpath(getSysroot() + SYSCONFIG_YUM_PATH) yumupdate_file = os.path.normpath(system_root + SYSCONFIG_YUM_PATH)
# Data is persisted in /root/initial-setup-ks.cfg # Data is persisted in /root/initial-setup-ks.cfg
sysconfig_file = os.path.normpath(getSysroot() + SYSCONFIG_FILE_PATH) sysconfig_file = os.path.normpath(system_root + SYSCONFIG_FILE_PATH)
with open(sysconfig_file, "w") as fobj: with open(sysconfig_file, "w") as fobj:
fobj.write("LOCMAP_FIRSTBOOT_START=%s\n" % self.run) fobj.write("LOCMAP_FIRSTBOOT_START=%s\n" % self.run)
# For compatibility but can be dropped in >= 7.5 # For compatibility but can be dropped in >= 7.5
...@@ -207,8 +217,8 @@ class CernData(AddonData): ...@@ -207,8 +217,8 @@ class CernData(AddonData):
fobj.close() fobj.close()
# Allow to disable gnome-initial-setup # Allow to disable gnome-initial-setup
gdmconfig_file = os.path.normpath(getSysroot() + GDMCONFIG_FILE_PATH) gdmconfig_file = os.path.normpath(system_root + GDMCONFIG_FILE_PATH)
xdgconfig_file = os.path.normpath(getSysroot() + XDGCONFIG_FILE_PATH) xdgconfig_file = os.path.normpath(system_root + XDGCONFIG_FILE_PATH)
if not self.gnomeinit: if not self.gnomeinit:
# C8 # C8
if (sys.version_info > (3, 0)): if (sys.version_info > (3, 0)):
...@@ -238,31 +248,40 @@ class CernData(AddonData): ...@@ -238,31 +248,40 @@ class CernData(AddonData):
except NoOptionError: except NoOptionError:
print("Unexpected error:", sys.exc_info()[0]) print("Unexpected error:", sys.exc_info()[0])
# we will need this for later
release=open('/etc/redhat-release','r').read().split(' ')[3].split('.')[0].rstrip()
# Configure yum-autoupdate # Configure yum-autoupdate
if self.autoupdate: if self.autoupdate:
yumautoupdate_installed=os.path.isfile('/usr/sbin/yum-autoupdate') if release == '8':
if yumautoupdate_installed == False: # install dnf-automatic instead of custom yum-autoupdate
# 'yum' will work for both 7 and 8 subprocess.check_call(["dnf", "-y", "install", "dnf-automatic"])
subprocess.check_call(["yum", "-y", "install", "yum-autoupdate"]) subprocess.check_call([SYSTEMCTL_BIN, "enable", "--now", "dnf-automatic-install.timer"])
subprocess.check_call([SYSTEMCTL_BIN, "enable", "yum-autoupdate"]) else:
try: yumautoupdate_installed=os.path.isfile('/usr/sbin/yum-autoupdate')
with open(yumupdate_file, "a") as fobj: if yumautoupdate_installed == False:
fobj.write("\n# initial-setup [cern-anaconda-cern] values\n") subprocess.check_call(["yum", "-y", "install", "yum-autoupdate"])
fobj.write("YUMUPDATE=%d\n" % int(self.autoupdate)) subprocess.check_call([SYSTEMCTL_BIN, "enable", "yum-autoupdate"])
fobj.write("YUMONBOOT=%d\n" % int(self.autoupdateboot)) try:
fobj.close() with open(yumupdate_file, "a") as fobj:
except IOError: fobj.write("\n# initial-setup [cern-anaconda-cern] values\n")
print("I/O Error couldn't write %s" % (yumupdate_file)) fobj.write("YUMUPDATE=%d\n" % int(self.autoupdate))
except: fobj.write("YUMONBOOT=%d\n" % int(self.autoupdateboot))
print("Unexpected error:", sys.exc_info()[0]) fobj.close()
except IOError:
print("I/O Error couldn't write %s" % (yumupdate_file))
except:
print("Unexpected error:", sys.exc_info()[0])
else: else:
# we use call rather than check_call as we don't care if this fails # we use call rather than check_call as we don't care if this fails
# due to yumautoupdate not being installed # due to yumautoupdate not being installed
subprocess.call([SYSTEMCTL_BIN, "disable", "yum-autoupdate"]) if release == '8':
subprocess.call([SYSTEMCTL_BIN, "disable", "dnf-automatic-install.timer"])
else:
subprocess.call([SYSTEMCTL_BIN, "disable", "yum-autoupdate"])
# locmap may not be installed - force install if it's not # locmap may not be installed - force install if it's not
locmap_installed=os.path.isfile('/usr/bin/locmap') locmap_installed=os.path.isfile('/usr/bin/locmap')
release=open('/etc/redhat-release','r').read().split(' ')[3].split('.')[0]
if locmap_installed == False: if locmap_installed == False:
# locmap does not reside in CERN repo on 8, install locmap-release # locmap does not reside in CERN repo on 8, install locmap-release
if release == '8': if release == '8':
...@@ -282,10 +301,6 @@ class CernData(AddonData): ...@@ -282,10 +301,6 @@ class CernData(AddonData):
subprocess.check_call([LOCMAP_BIN, "--enable", "afs"]) subprocess.check_call([LOCMAP_BIN, "--enable", "afs"])
else: else:
subprocess.check_call([LOCMAP_BIN, "--disable", "afs"]) subprocess.check_call([LOCMAP_BIN, "--disable", "afs"])
#if self.eos:
# subprocess.check_call([LOCMAP_BIN, "--enable", "eosclient"])
#else:
# subprocess.check_call([LOCMAP_BIN, "--disable", "eosclient"])
if self.cvmfs: if self.cvmfs:
subprocess.check_call([LOCMAP_BIN, "--enable", "cvmfs"]) subprocess.check_call([LOCMAP_BIN, "--enable", "cvmfs"])
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment