refs #596 fix more bugs, set debconf selections, add support for ubuntu noble

pull/1/head
Natalia Serrano 2024-08-12 12:58:08 +02:00
parent cc5701c870
commit ec2ab82eb1
3 changed files with 40 additions and 31 deletions

View File

@ -14,7 +14,7 @@ svnclientdir = '/tmp/opengnsys_installer/opengnsys/client/boot-tools'
svnclientstructure = '/tmp/opengnsys_installer/opengnsys/client/shared' svnclientstructure = '/tmp/opengnsys_installer/opengnsys/client/shared'
svnclientengine = '/tmp/opengnsys_installer/opengnsys/client/engine' svnclientengine = '/tmp/opengnsys_installer/opengnsys/client/engine'
def boottoolsFsOpengnsys (osdistrib, oscodename, osrelease, osarch, oshttp): def boottoolsFsOpengnsys (ogclientmount, osdistrib, oscodename, osrelease, osarch, oshttp):
print (':'.join ([osdistrib, oscodename, osrelease, osarch, oshttp])) print (':'.join ([osdistrib, oscodename, osrelease, osarch, oshttp]))
print ('Iniciando la personalización con datos del repositorio') print ('Iniciando la personalización con datos del repositorio')

View File

@ -2,8 +2,17 @@
import argparse import argparse
import os import os
import re
import subprocess import subprocess
from boottoolsfunctions import _run
debconf_settings = """
kexec-tools kexec-tools/load_kexec boolean true
openssh-server openssh-server/permit-root-login boolean true
refind refind/install_to_esp boolean false
""".strip()
def _aptget_clean(): def _aptget_clean():
subprocess.run (['apt-get', 'clean']) subprocess.run (['apt-get', 'clean'])
@ -24,13 +33,11 @@ def _aptget_install (pkgs, opts=[]):
def _oghook_deactivate(): def _oghook_deactivate():
#Desactivamos el hook del oginitrd.img para evitar problemas, al final de este escripts se activará #Desactivamos el hook del oginitrd.img para evitar problemas, al final de este escripts se activará
#mv /etc/initramfs-tools/hooks/oghooks /etc/initramfs-tools/ os.rename ('/etc/initramfs-tools/hooks/oghooks', '/etc/initramfs-tools/oghooks')
pass
def _oghook_activate(): def _oghook_activate():
#Activamos el hook del oginitrd.img #Activamos el hook del oginitrd.img
#mv /etc/initramfs-tools/oghooks /etc/initramfs-tools/hooks/ os.rename ('/etc/initramfs-tools/oghooks', '/etc/initramfs-tools/hooks/oghooks')
pass
def _mock_mtab(): def _mock_mtab():
# Preparamos el mtab necesario para la instalacion correcta de paquetes. # Preparamos el mtab necesario para la instalacion correcta de paquetes.
@ -48,8 +55,10 @@ def boottoolsSoftwareInstall (osarch, osrelease):
os.environ['LANG'] = 'C' os.environ['LANG'] = 'C'
os.environ['DEBIAN_FRONTEND'] = 'noninteractive' os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
subprocess.run (['dpkg-divert', '--local', '--rename', '--add', '/sbin/initctl']) stdout, _ = _run (['dpkg-divert', '--list'])
os.symlink ('/bin/true', '/sbin/initctl') if not re.findall (r'local diversion of /sbin/initctl to /sbin/initctl.distrib', stdout):
subprocess.run (['dpkg-divert', '--local', '--rename', '--add', '/sbin/initctl'])
os.symlink ('/bin/true', '/sbin/initctl')
#TEST desactivamos upstart #TEST desactivamos upstart
#apt-get update; apt-get install --no-install-recommends dbus; dbus-uuidgen > /var/lib/dbus/machine-id; dpkg-divert --local --rename --add /sbin/initctl; ln -s /bin/true /sbin/initctl #apt-get update; apt-get install --no-install-recommends dbus; dbus-uuidgen > /var/lib/dbus/machine-id; dpkg-divert --local --rename --add /sbin/initctl; ln -s /bin/true /sbin/initctl
@ -58,9 +67,9 @@ def boottoolsSoftwareInstall (osarch, osrelease):
pkgs32 = [] pkgs32 = []
if 'i386' != osarch: if 'i386' != osarch:
subprocess.run (['dpkg', '--add-architecture', 'i386']) subprocess.run (['dpkg', '--add-architecture', 'i386'])
pkgs32 = 'lib32gcc1 lib32stdc++6 lib32z1 libc6-i386'.split (' ') pkgs32 = 'lib32gcc-s1 lib32stdc++6 lib32z1 libc6-i386'.split (' ') ## he cambiado lib32gcc1 por lib32gcc-s1 pero como queramos crear un oglive viejo, esto va a petar
_aptget_update() _aptget_update() ## esto ya esta hecho...
#Ign:13 http://ppa.launchpad.net/zfs-native/stable/ubuntu noble InRelease #Ign:13 http://ppa.launchpad.net/zfs-native/stable/ubuntu noble InRelease
#Err:15 http://ppa.launchpad.net/zfs-native/stable/ubuntu noble Release #Err:15 http://ppa.launchpad.net/zfs-native/stable/ubuntu noble Release
# 404 Not Found [IP: 185.125.190.80 80] # 404 Not Found [IP: 185.125.190.80 80]
@ -68,26 +77,19 @@ def boottoolsSoftwareInstall (osarch, osrelease):
#E: The repository 'http://ppa.launchpad.net/zfs-native/stable/ubuntu noble Release' does not have a Release file. #E: The repository 'http://ppa.launchpad.net/zfs-native/stable/ubuntu noble Release' does not have a Release file.
#N: Updating from such a repository can't be done securely, and is therefore disabled by default. #N: Updating from such a repository can't be done securely, and is therefore disabled by default.
#N: See apt-secure(8) manpage for repository creation and user configuration details. #N: See apt-secure(8) manpage for repository creation and user configuration details.
_aptget_upgrade()
_oghook_deactivate() _oghook_deactivate()
_aptget_upgrade()
_mock_mtab() _mock_mtab()
return
"""
# Instalamos el kernel. # Instalamos el kernel.
_aptget_install (['linux-image-{}'.format (osrelease), 'linux-headers-{}'.format (osrelease), 'dkms', 'shim-signed', 'openssl']) _aptget_install (['linux-image-{}'.format (osrelease), 'linux-headers-{}'.format (osrelease), 'linux-modules-{}'.format (osrelease), 'linux-modules-extra-{}'.format (osrelease), 'dkms', 'shim-signed', 'openssl'])
_aptget_install (['linux-modules-{}'.format (osrelease), 'linux-modules-extra-{}'.format (osrelease)])
subprocess.run (['debconf-set-selections'], input=debconf_settings, text=True)
# Valores para paquetes interactivos.
cat << EOT | debconf-set-selections --
kexec-tools kexec-tools/load_kexec boolean true
openssh-server openssh-server/permit-root-login boolean true
refind refind/install_to_esp boolean false
EOT
## nati: hace falta --force-confdef para evitar un tema interactivo del /etc/ssh/ssh_config ## nati: hace falta --force-confdef para evitar un tema interactivo del /etc/ssh/ssh_config
_aptget_install (['sshfs', 'kexec-tools'] + pkgs32, opts=['-o', 'DPkg::Options::=--force-confdef']) _aptget_install (['sshfs', 'kexec-tools'] + pkgs32, opts=['-o', 'DPkg::Options::=--force-confdef'])
"""
#comenzamos con la instalación de los paquetes a instalar. #comenzamos con la instalación de los paquetes a instalar.
to_install = {} to_install = {}
for group in `find /usr/bin/boot-tools/listpackages/ -name sw.*`; do for group in `find /usr/bin/boot-tools/listpackages/ -name sw.*`; do

View File

@ -10,12 +10,13 @@ import glob
logger = logging.getLogger ('boottools') logger = logging.getLogger ('boottools')
def _run (args): def _run (args):
cp = subprocess.run (args, capture_output=True) cp = subprocess.run (args, text=True, capture_output=True)
if cp.returncode: if cp.returncode:
logger.error ('stdout "{}" stderr "{}"'.format (cp.stdout, cp.stderr))
logger.error ('command "{}" failed with rc "{}"'.format (' '.join(args), cp.returncode)) logger.error ('command "{}" failed with rc "{}"'.format (' '.join(args), cp.returncode))
raise raise Exception ('command "{}" failed with rc "{}"'.format (' '.join(args), cp.returncode))
stdout = cp.stdout.decode ('utf-8').strip() stdout = cp.stdout.strip()
stderr = cp.stderr.decode ('utf-8').strip() stderr = cp.stderr.strip()
return stdout, stderr return stdout, stderr
def _grep (regex, file): def _grep (regex, file):
@ -131,11 +132,17 @@ def btogGetOsInfo1 (type_client):
osrelease='5.4.0-42-generic' osrelease='5.4.0-42-generic'
osarch='amd64' osarch='amd64'
oshttp='http://es.archive.ubuntu.com/ubuntu/' oshttp='http://es.archive.ubuntu.com/ubuntu/'
elif 'noble' == type_client: # ogLive 1.2.0-rc1 basado en Ubuntu 24.04 y Kernel 6.8.
osdistrib='ubuntu'
oscodename='noble'
osrelease='6.8.0-31-generic'
osarch='amd64'
oshttp='http://es.archive.ubuntu.com/ubuntu/'
elif 'host' == type_client: # ogLive basado en la distribución del servidor. elif 'host' == type_client: # ogLive basado en la distribución del servidor.
osdistrib=platform.freedesktop_os_release()['NAME'] osdistrib=platform.freedesktop_os_release()['NAME']
oscodename=platform.freedesktop_os_release()['VERSION_CODENAME'] oscodename=platform.freedesktop_os_release()['VERSION_CODENAME']
osrelease=platform.uname()[2] osrelease=platform.uname()[2]
osarch=subprocess.run (['dpkg', '--print-architecture'], capture_output=True).stdout.decode ('utf-8').strip() osarch, _=_run (['dpkg', '--print-architecture'])
oshttp='http://es.archive.ubuntu.com/ubuntu/' oshttp='http://es.archive.ubuntu.com/ubuntu/'
else: # Parámetro desconocido else: # Parámetro desconocido
print ('Parámetro no válido.') print ('Parámetro no válido.')
@ -206,10 +213,10 @@ def btogSetFsVirtual (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisks
except: raise Exception ('losetup failed') except: raise Exception ('losetup failed')
logger.info ('Partitioning disk image') logger.info ('Partitioning disk image')
cp = subprocess.run(['bash', '-c', "echo $'n\np\n1\n\n\nt\n83\nw' |fdisk {}".format (diskloop)], capture_output=True) stdout, _ = _run (['bash', '-c', "echo $'n\np\n1\n\n\nt\n83\nw' |fdisk {}".format (diskloop)])
logger.debug ('fdisk output follows: {}'.format (cp.stdout.decode('utf-8'))) logger.debug ('fdisk output follows: {}'.format (stdout))
time.sleep (5) time.sleep (3)
logger.debug ('losetup --detach') logger.debug ('losetup --detach')
try: _run (['losetup', '--detach', diskloop]) try: _run (['losetup', '--detach', diskloop])
except: except:
@ -228,7 +235,7 @@ def btogSetFsVirtual (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisks
except: except:
raise Exception ('Formateando la particion principal del disco virtual: ERROR') raise Exception ('Formateando la particion principal del disco virtual: ERROR')
time.sleep (5) time.sleep (3)
logger.debug ('losetup --detach') logger.debug ('losetup --detach')
try: _run (['losetup', '--detach', partloop]) try: _run (['losetup', '--detach', partloop])
except: except:
@ -293,7 +300,7 @@ def btogSetFsBase (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp):
raise Exception ('rootfs should be mounted') raise Exception ('rootfs should be mounted')
logger.info ('debootstrapping system') logger.info ('debootstrapping system')
logger.debug ('debootstrap --arch="{}" --components=main,universe "{}" "{}" "{}"'.format (osarch, oscodename, btrootfsmnt, oshttp) logger.debug ('debootstrap --arch="{}" --components=main,universe "{}" "{}" "{}"'.format (osarch, oscodename, btrootfsmnt, oshttp))
try: _run (['debootstrap', '--arch={}'.format(osarch), '--components=main,universe', oscodename, btrootfsmnt, oshttp]) try: _run (['debootstrap', '--arch={}'.format(osarch), '--components=main,universe', oscodename, btrootfsmnt, oshttp])
except: except:
if (_is_mounted (btrootfsmnt)): if (_is_mounted (btrootfsmnt)):