refs #596 fix more bugs, set debconf selections, add support for ubuntu noble
parent
cc5701c870
commit
ec2ab82eb1
|
@ -14,7 +14,7 @@ svnclientdir = '/tmp/opengnsys_installer/opengnsys/client/boot-tools'
|
|||
svnclientstructure = '/tmp/opengnsys_installer/opengnsys/client/shared'
|
||||
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 ('Iniciando la personalización con datos del repositorio')
|
||||
|
|
|
@ -2,8 +2,17 @@
|
|||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
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():
|
||||
subprocess.run (['apt-get', 'clean'])
|
||||
|
||||
|
@ -24,13 +33,11 @@ def _aptget_install (pkgs, opts=[]):
|
|||
|
||||
def _oghook_deactivate():
|
||||
#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/
|
||||
pass
|
||||
os.rename ('/etc/initramfs-tools/hooks/oghooks', '/etc/initramfs-tools/oghooks')
|
||||
|
||||
def _oghook_activate():
|
||||
#Activamos el hook del oginitrd.img
|
||||
#mv /etc/initramfs-tools/oghooks /etc/initramfs-tools/hooks/
|
||||
pass
|
||||
os.rename ('/etc/initramfs-tools/oghooks', '/etc/initramfs-tools/hooks/oghooks')
|
||||
|
||||
def _mock_mtab():
|
||||
# Preparamos el mtab necesario para la instalacion correcta de paquetes.
|
||||
|
@ -48,8 +55,10 @@ def boottoolsSoftwareInstall (osarch, osrelease):
|
|||
os.environ['LANG'] = 'C'
|
||||
os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
|
||||
|
||||
subprocess.run (['dpkg-divert', '--local', '--rename', '--add', '/sbin/initctl'])
|
||||
os.symlink ('/bin/true', '/sbin/initctl')
|
||||
stdout, _ = _run (['dpkg-divert', '--list'])
|
||||
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
|
||||
#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 = []
|
||||
if 'i386' != osarch:
|
||||
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
|
||||
#Err:15 http://ppa.launchpad.net/zfs-native/stable/ubuntu noble Release
|
||||
# 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.
|
||||
#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.
|
||||
_aptget_upgrade()
|
||||
_oghook_deactivate()
|
||||
_aptget_upgrade()
|
||||
_mock_mtab()
|
||||
return
|
||||
|
||||
|
||||
"""
|
||||
# Instalamos el kernel.
|
||||
_aptget_install (['linux-image-{}'.format (osrelease), 'linux-headers-{}'.format (osrelease), 'dkms', 'shim-signed', 'openssl'])
|
||||
_aptget_install (['linux-modules-{}'.format (osrelease), 'linux-modules-extra-{}'.format (osrelease)])
|
||||
_aptget_install (['linux-image-{}'.format (osrelease), 'linux-headers-{}'.format (osrelease), 'linux-modules-{}'.format (osrelease), 'linux-modules-extra-{}'.format (osrelease), 'dkms', 'shim-signed', 'openssl'])
|
||||
|
||||
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
|
||||
_aptget_install (['sshfs', 'kexec-tools'] + pkgs32, opts=['-o', 'DPkg::Options::=--force-confdef'])
|
||||
|
||||
"""
|
||||
#comenzamos con la instalación de los paquetes a instalar.
|
||||
to_install = {}
|
||||
for group in `find /usr/bin/boot-tools/listpackages/ -name sw.*`; do
|
||||
|
|
|
@ -10,12 +10,13 @@ import glob
|
|||
logger = logging.getLogger ('boottools')
|
||||
|
||||
def _run (args):
|
||||
cp = subprocess.run (args, capture_output=True)
|
||||
cp = subprocess.run (args, text=True, capture_output=True)
|
||||
if cp.returncode:
|
||||
logger.error ('stdout "{}" stderr "{}"'.format (cp.stdout, cp.stderr))
|
||||
logger.error ('command "{}" failed with rc "{}"'.format (' '.join(args), cp.returncode))
|
||||
raise
|
||||
stdout = cp.stdout.decode ('utf-8').strip()
|
||||
stderr = cp.stderr.decode ('utf-8').strip()
|
||||
raise Exception ('command "{}" failed with rc "{}"'.format (' '.join(args), cp.returncode))
|
||||
stdout = cp.stdout.strip()
|
||||
stderr = cp.stderr.strip()
|
||||
return stdout, stderr
|
||||
|
||||
def _grep (regex, file):
|
||||
|
@ -131,11 +132,17 @@ def btogGetOsInfo1 (type_client):
|
|||
osrelease='5.4.0-42-generic'
|
||||
osarch='amd64'
|
||||
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.
|
||||
osdistrib=platform.freedesktop_os_release()['NAME']
|
||||
oscodename=platform.freedesktop_os_release()['VERSION_CODENAME']
|
||||
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/'
|
||||
else: # Parámetro desconocido
|
||||
print ('Parámetro no válido.')
|
||||
|
@ -206,10 +213,10 @@ def btogSetFsVirtual (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisks
|
|||
except: raise Exception ('losetup failed')
|
||||
|
||||
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)
|
||||
logger.debug ('fdisk output follows: {}'.format (cp.stdout.decode('utf-8')))
|
||||
stdout, _ = _run (['bash', '-c', "echo $'n\np\n1\n\n\nt\n83\nw' |fdisk {}".format (diskloop)])
|
||||
logger.debug ('fdisk output follows: {}'.format (stdout))
|
||||
|
||||
time.sleep (5)
|
||||
time.sleep (3)
|
||||
logger.debug ('losetup --detach')
|
||||
try: _run (['losetup', '--detach', diskloop])
|
||||
except:
|
||||
|
@ -228,7 +235,7 @@ def btogSetFsVirtual (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisks
|
|||
except:
|
||||
raise Exception ('Formateando la particion principal del disco virtual: ERROR')
|
||||
|
||||
time.sleep (5)
|
||||
time.sleep (3)
|
||||
logger.debug ('losetup --detach')
|
||||
try: _run (['losetup', '--detach', partloop])
|
||||
except:
|
||||
|
@ -293,7 +300,7 @@ def btogSetFsBase (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp):
|
|||
raise Exception ('rootfs should be mounted')
|
||||
|
||||
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])
|
||||
except:
|
||||
if (_is_mounted (btrootfsmnt)):
|
||||
|
|
Loading…
Reference in New Issue