diff --git a/chroot-tasks.py b/chroot-tasks.py index fb63750..056cb36 100755 --- a/chroot-tasks.py +++ b/chroot-tasks.py @@ -10,11 +10,6 @@ import subprocess from boottools import utils, apt -config = utils.read_config ('mkoglive.cfg') -if config is None: - sys.exit (1) -debconf_settings = config['General'].get ('debconf_settings') - def _oghook_deactivate(): #Desactivamos el hook del oginitrd.img para evitar problemas, al final de este escripts se activará os.rename ('/etc/initramfs-tools/hooks/oghooks', '/etc/initramfs-tools/oghooks') @@ -77,7 +72,7 @@ def boottoolsSoftwareCompile(): print ('ms-sys') try: utils.run (['which', 'ms-sys']) except: - utils.run (['wget', 'https://sourceforge.net/projects/ms-sys/files/latest/download', '-O', 'ms-sys.tar.gz']) + utils.run (['wget', '--quiet', 'https://sourceforge.net/projects/ms-sys/files/latest/download', '-O', 'ms-sys.tar.gz']) utils.run (['tar', '-xpzf', 'ms-sys.tar.gz']) mssys_dir = subprocess.run (['tar tzf ms-sys.tar.gz |head -n 1'], shell=True, capture_output=True, text=True).stdout.strip() print (f'mssys_dir "{mssys_dir}"') @@ -88,7 +83,7 @@ def boottoolsSoftwareCompile(): print ('spartlnx') try: utils.run (['which', 'spartl64.run']) except: - utils.run (['wget', 'http://damien.guibouret.free.fr/savepart.zip']) + utils.run (['wget', '--quiet', 'http://damien.guibouret.free.fr/savepart.zip']) utils.run (['unzip', '-o', 'savepart.zip', '-d', '/sbin/', 'spartl64.run']) utils.run (['mkdir', '/usr/share/doc/spartlnx']) utils.run (['unzip', '-j', '-o', 'savepart.zip', '-d', '/usr/share/doc/spartlnx/', 'doc/en/*']) @@ -117,9 +112,16 @@ def boottoolsInitrdGenerate (osrelease): if __name__ == '__main__': parser = argparse.ArgumentParser() - parser.add_argument ('--osarch', help='OS architecture', action='store', required=True) - parser.add_argument ('--osrelease', help='OS release', action='store', required=True) + parser.add_argument ('--osarch', help='OS architecture', action='store', required=True) + parser.add_argument ('--osrelease', help='OS release', action='store', required=True) + parser.add_argument ('--config', help='Path to configuration file', action='store') args = parser.parse_args() + + config = utils.read_config (args.config or 'mkoglive.cfg') + if config is None: + sys.exit (1) + debconf_settings = config['General'].get ('debconf_settings') + boottoolsSoftwareInstall (args.osarch, args.osrelease) boottoolsSoftwareCompile() boottoolsInitrdGenerate (args.osrelease) diff --git a/mkoglive.py b/mkoglive.py index 1040b00..a926741 100755 --- a/mkoglive.py +++ b/mkoglive.py @@ -7,6 +7,7 @@ import subprocess import glob import stat import shutil +import argparse curdir = os.path.dirname (__file__) sys.path.insert (0, curdir) @@ -14,9 +15,7 @@ from boottools import utils, apt, btog os.chdir (curdir) -def _logging(): - #logging.root.handlers = [] - +def _logging (lvl='INFO'): numeric_level = getattr (logging, lvl.upper(), None) if numeric_level is None: numeric_level = getattr (logging, 'INFO') @@ -100,10 +99,8 @@ def _copy_og_files (btrootfsmnt, osdistrib, oscodename): def _chroot_tasks (curdir, osrelease, osarch): logger.debug (f'running \'schroot --chroot IMGogclient -- {curdir}/chroot-tasks.py --osrelease "{osrelease}" --osarch "{osarch}"\'') - stdout, _ = utils.run (['schroot', '--chroot', 'IMGogclient', '--', f'{curdir}/chroot-tasks.py', '--osrelease', osrelease, '--osarch', osarch]) - logger.debug (f'chroot-tasks.py stdout follows:') + stdout, _ = utils.run (['schroot', '--chroot', 'IMGogclient', '--', f'{curdir}/chroot-tasks.py', '--osrelease', osrelease, '--osarch', osarch, '--config', args.config or 'mkoglive.cfg']) ## esto deja initrd.img-6.8.0-31-generic y vmlinuz-6.8.0-31-generic en /tmp - for i in stdout.strip().split ('\n'): logger.debug (' ' + i) def _ssh_stuff(): _mount_rootfs() @@ -128,15 +125,20 @@ def _mkinitrd_squashfs_isofs (bttargetdir, osrelease, btrootfsmnt, pxepkg, isoli btog.mkisofs (pxepkg, isolinux_tpl, bttargetdir, nameisoclient) +parser = argparse.ArgumentParser() +parser.add_argument ('--loglevel', help='Log level', action='store') +parser.add_argument ('--codename', help='OS codename', action='store') +parser.add_argument ('--config', help='Path to configuration file', action='store') +args = parser.parse_args() -config = utils.read_config ('mkoglive.cfg') +config = utils.read_config (args.config or 'mkoglive.cfg') if config is None: sys.exit (1) isolinux_tpl = config['General'].get ('isolinux_template') -lvl = config['General'].get ('logging_level') +cfg_loglevel = config['General'].get ('logging_level') -logger = _logging() -type_client = sys.argv[1] if len (sys.argv)>1 else 'host' +logger = _logging (args.loglevel or cfg_loglevel) +type_client = args.codename or 'host' if os.getuid(): logger.error ('ERROR: this program must run under root privileges!!')