From 53310a8e5bf5f8e761f925b6722cb2b0365c881a Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Fri, 16 Aug 2024 13:22:34 +0200 Subject: [PATCH] refs #596 remove debconf_settings2, do chdir first --- boottools/btog.py | 4 ++-- chroot-tasks.py | 40 ++++++++++++---------------------------- mkoglive.cfg | 2 -- mkoglive.py | 4 ++-- 4 files changed, 16 insertions(+), 34 deletions(-) diff --git a/boottools/btog.py b/boottools/btog.py index bb2049b..2a36f49 100644 --- a/boottools/btog.py +++ b/boottools/btog.py @@ -251,9 +251,9 @@ def configure_schroot (btrootfsimg): logger.info ('Finalizado: OK') return 0 -# SetfsBase: Genera el sistema root base con debootstrap +# debootstrap: Genera el sistema root base con debootstrap # trabaja sobre un rootfs ya montado -def SetFsBase (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp): +def debootstrap (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp): logger.info ('Iniciando la generación del sistema de archivos') logger.info ('debootstrapping system') diff --git a/chroot-tasks.py b/chroot-tasks.py index 25de7c2..fb63750 100755 --- a/chroot-tasks.py +++ b/chroot-tasks.py @@ -14,7 +14,6 @@ config = utils.read_config ('mkoglive.cfg') if config is None: sys.exit (1) debconf_settings = config['General'].get ('debconf_settings') -debconf_settings2 = config['General'].get ('debconf_settings2') def _oghook_deactivate(): #Desactivamos el hook del oginitrd.img para evitar problemas, al final de este escripts se activará @@ -24,16 +23,6 @@ def _oghook_activate(): #Activamos el hook del oginitrd.img os.rename ('/etc/initramfs-tools/oghooks', '/etc/initramfs-tools/hooks/oghooks') -#def _mock_mtab(): -# # Preparamos el mtab necesario para la instalacion correcta de paquetes. -# #echo "/dev/sda1 / ext4 rw,errors=remount-ro 0 0" > /etc/mtab ## nati: falla porque es un symlink a ../proc/self/mounts -# pass - -#def _restore_mtab(): -# # Dejamos el mtab como al principio -# #echo " " > /etc/mtab -# pass - def boottoolsSoftwareInstall (osarch, osrelease): os.environ['LANGUAGE'] = 'C' os.environ['LC_ALL'] = 'C' @@ -51,18 +40,18 @@ def boottoolsSoftwareInstall (osarch, osrelease): 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 _oghook_deactivate() - #_mock_mtab() - - apt.install ([f'linux-image-{osrelease}', f'linux-headers-{osrelease}', f'linux-modules-{osrelease}', f'linux-modules-extra-{osrelease}', 'dkms', 'shim-signed', 'openssl']) subprocess.run (['debconf-set-selections'], input=debconf_settings, text=True) - - apt.install (['sshfs', 'kexec-tools'] + pkgs32, opts={'DPkg::Options::': '--force-confdef'}) ## hace falta --force-confdef para evitar un tema interactivo del /etc/ssh/ssh_config + utils.run (['dpkg-reconfigure', '--frontend', 'noninteractive', 'console-setup', 'locales']) ## despues de esto, debconf-get-selections devuelve los valores antiguos, no se por que... pkgs = [] for section in config.options('Packages'): pkgs += re.split (r'[ \n]', config['Packages'].get(section).strip()) - apt.install (pkgs) + + apt.install ( + [f'linux-image-{osrelease}', f'linux-headers-{osrelease}', f'linux-modules-{osrelease}', f'linux-modules-extra-{osrelease}', 'dkms', 'shim-signed', 'openssl', 'sshfs', 'kexec-tools'] + pkgs32 + pkgs, + opts={'DPkg::Options::': '--force-confdef'} ## hace falta --force-confdef para evitar un tema interactivo del /etc/ssh/ssh_config + ) # Instalar módulos que algunos paquetes puedan tener pendientes de compilar. stdout, _ = utils.run (['dkms', 'status']) @@ -75,11 +64,13 @@ def boottoolsSoftwareInstall (osarch, osrelease): utils.run (['dkms', 'install', '-m', mod.strip(), '-v', vers.strip()]) _oghook_activate() - #_restore_mtab() apt.clean() apt.autoremove() def boottoolsSoftwareCompile(): + env_language = os.environ['LANGUAGE'] + env_lc_all = os.environ['LC_ALL'] + env_lang = os.environ['LANG'] os.environ['LANGUAGE'] = os.environ['LC_ALL'] = os.environ['LANG'] = 'C' os.chdir ('/tmp') @@ -111,15 +102,9 @@ def boottoolsSoftwareCompile(): os.chdir ('..') apt.remove (['python3-dev', 'python3-setuptools']) - ## TODO restore os.environ and pwd - os.environ['LANGUAGE'] = os.environ['LC_ALL'] = os.environ['LANG'] = 'C' - os.chdir ('/tmp') - -def boottoolsFsLocales(): - subprocess.run (['debconf-set-selections'], input=debconf_settings2, text=True) - - ## despues de esto, debconf-get-selections devuelve los valores antiguos, no se por que... - utils.run (['dpkg-reconfigure', '--frontend', 'noninteractive', 'console-setup', 'locales']) + os.environ['LANGUAGE'] = env_language + os.environ['LC_ALL'] = env_lc_all + os.environ['LANG'] = env_lang def boottoolsInitrdGenerate (osrelease): for f in glob.glob ('/usr/lib/initramfs-tools/bin/*'): @@ -137,5 +122,4 @@ if __name__ == '__main__': args = parser.parse_args() boottoolsSoftwareInstall (args.osarch, args.osrelease) boottoolsSoftwareCompile() - boottoolsFsLocales() boottoolsInitrdGenerate (args.osrelease) diff --git a/mkoglive.cfg b/mkoglive.cfg index 018996a..708a93a 100644 --- a/mkoglive.cfg +++ b/mkoglive.cfg @@ -6,8 +6,6 @@ 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 - -debconf_settings2 = console-setup console-setup/charmap47 select UTF-8 console-setup console-setup/codeset47 select . Combined - Latin; Slavic Cyrillic; Greek console-setup console-setup/fontface47 select VGA diff --git a/mkoglive.py b/mkoglive.py index 32eeef2..9283dce 100755 --- a/mkoglive.py +++ b/mkoglive.py @@ -12,6 +12,8 @@ curdir = os.path.dirname (__file__) sys.path.insert (0, curdir) from boottools import utils, apt, btog +os.chdir (curdir) + def _logging(): #logging.root.handlers = [] @@ -141,8 +143,6 @@ if os.getuid(): logger.error ('ERROR: this program must run under root privileges!!') sys.exit (1) -#os.chdir ('/tmp') - ## this is convenient in case the previous run failed and we want to run this program again try: utils.umount (btrootfsmnt) except: pass