refs #596 rename files and functions
parent
0aa118a88b
commit
d1822ec5fb
|
@ -161,7 +161,7 @@ def GetOsInfo2 (ogrepo_dir, versionboottools, oscodename, osrelease, osarch):
|
||||||
namehostclient = '-'.join ([versionboottools, oscodename, gitrelease])
|
namehostclient = '-'.join ([versionboottools, oscodename, gitrelease])
|
||||||
return gitrelease, nameisoclient, namehostclient
|
return gitrelease, nameisoclient, namehostclient
|
||||||
|
|
||||||
def SetFsVirtual (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisksize, bttargetdir, osarch):
|
def mkrootfs (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisksize, bttargetdir, osarch):
|
||||||
logger.info (f'Creación y formateo del disco virtual "{btrootfsimg}" "{btvirtualdisksize}" MB')
|
logger.info (f'Creación y formateo del disco virtual "{btrootfsimg}" "{btvirtualdisksize}" MB')
|
||||||
|
|
||||||
try: utils.umount (btrootfsmnt)
|
try: utils.umount (btrootfsmnt)
|
||||||
|
@ -230,7 +230,7 @@ def SetFsVirtual (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisksize,
|
||||||
logger.info (f'"{btrootfsimg}" "{btvirtualdisksize}" MB : OK')
|
logger.info (f'"{btrootfsimg}" "{btvirtualdisksize}" MB : OK')
|
||||||
|
|
||||||
#SetFsAcces: habilita el acceso al sistema root del cliente con schroot
|
#SetFsAcces: habilita el acceso al sistema root del cliente con schroot
|
||||||
def SetFsAccess (btrootfsimg):
|
def configure_schroot (btrootfsimg):
|
||||||
if (utils.grep (btrootfsimg, '/etc/schroot/schroot.conf')):
|
if (utils.grep (btrootfsimg, '/etc/schroot/schroot.conf')):
|
||||||
return
|
return
|
||||||
logger.info ('Iniciando la configuración del schroot')
|
logger.info ('Iniciando la configuración del schroot')
|
||||||
|
@ -264,8 +264,8 @@ def SetFsBase (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp):
|
||||||
logger.info (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ok')
|
logger.info (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ok')
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def FsOpengnsys (builder, og_shared, og_engine, ogclientmount, osdistrib, oscodename):
|
def copy_og_files (builder, og_shared, og_engine, ogclientmount, osdistrib, oscodename):
|
||||||
print ('Iniciando la personalización con datos del repositorio')
|
logger.info ('Iniciando la personalización con datos del repositorio')
|
||||||
|
|
||||||
sources_list_in = f'{builder}/includes/etc/apt/sources.list.{osdistrib.lower()}'
|
sources_list_in = f'{builder}/includes/etc/apt/sources.list.{osdistrib.lower()}'
|
||||||
sources_list_out = f'{builder}/includes/etc/apt/sources.list'
|
sources_list_out = f'{builder}/includes/etc/apt/sources.list'
|
||||||
|
@ -302,7 +302,7 @@ def FsOpengnsys (builder, og_shared, og_engine, ogclientmount, osdistrib, oscode
|
||||||
if os.path.exists (f'{og_shared}/bin/browser'): shutil.copy (f'{og_shared}/bin/browser', f'{ogclientmount}/bin/')
|
if os.path.exists (f'{og_shared}/bin/browser'): shutil.copy (f'{og_shared}/bin/browser', f'{ogclientmount}/bin/')
|
||||||
if os.path.exists (f'{og_shared}/bin/ogAdmClient'): shutil.copy (f'{og_shared}/bin/ogAdmClient', f'{ogclientmount}/bin/')
|
if os.path.exists (f'{og_shared}/bin/ogAdmClient'): shutil.copy (f'{og_shared}/bin/ogAdmClient', f'{ogclientmount}/bin/')
|
||||||
|
|
||||||
def SshServer (btrootfsmnt):
|
def ssh_server (btrootfsmnt):
|
||||||
if not os.path.exists ('/root/.ssh/id_rsa'): ## crea un par de claves en la VM, no en el chroot
|
if not os.path.exists ('/root/.ssh/id_rsa'): ## crea un par de claves en la VM, no en el chroot
|
||||||
utils.run (['ssh-keygen', '-q', '-f', '/root/.ssh/id_rsa', '-N', ''])
|
utils.run (['ssh-keygen', '-q', '-f', '/root/.ssh/id_rsa', '-N', ''])
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ def SshServer (btrootfsmnt):
|
||||||
else:
|
else:
|
||||||
logger.error ('no key publica og')
|
logger.error ('no key publica og')
|
||||||
|
|
||||||
def SshClient (btrootfsmnt):
|
def ssh_client (btrootfsmnt):
|
||||||
if not os.path.exists (f'{btrootfsmnt}/root/.ssh/id_rsa'):
|
if not os.path.exists (f'{btrootfsmnt}/root/.ssh/id_rsa'):
|
||||||
utils.run (['ssh-keygen', '-q', '-f', f'{btrootfsmnt}/root/.ssh/id_rsa', '-N', '']) ## crea un par de claves en el chroot
|
utils.run (['ssh-keygen', '-q', '-f', f'{btrootfsmnt}/root/.ssh/id_rsa', '-N', '']) ## crea un par de claves en el chroot
|
||||||
|
|
||||||
|
@ -349,8 +349,8 @@ def SshClient (btrootfsmnt):
|
||||||
## TODO: exportamos la publica a los repos
|
## TODO: exportamos la publica a los repos
|
||||||
#cp /root/.ssh/id_rsa.pub /tmp/rsa.ogclient.pub
|
#cp /root/.ssh/id_rsa.pub /tmp/rsa.ogclient.pub
|
||||||
|
|
||||||
#FsInitrd genera un initrd.
|
#move_initrd genera un initrd.
|
||||||
def FsInitrd (bttargetdir, osrelease):
|
def move_initrd (bttargetdir, osrelease):
|
||||||
#echo "cp /tmp/*-${OSRELEASE} ${BTTARGETDIR}"
|
#echo "cp /tmp/*-${OSRELEASE} ${BTTARGETDIR}"
|
||||||
#cp /tmp/*-${OSRELEASE} ${BTTARGETDIR} ## esto copia algo??
|
#cp /tmp/*-${OSRELEASE} ${BTTARGETDIR} ## esto copia algo??
|
||||||
|
|
||||||
|
@ -373,8 +373,8 @@ def FsInitrd (bttargetdir, osrelease):
|
||||||
for f in glob.glob (f'{bttargetdir}/oginitrd*') + glob.glob (f'{bttargetdir}/vmlinuz*'):
|
for f in glob.glob (f'{bttargetdir}/oginitrd*') + glob.glob (f'{bttargetdir}/vmlinuz*'):
|
||||||
os.chmod (f, 0o755)
|
os.chmod (f, 0o755)
|
||||||
|
|
||||||
#FsSqfs convierte el sistema root en sqfs
|
#mksquashfs convierte el sistema root en sqfs
|
||||||
def FsSqfs (bttargetdir, btrootfsmnt):
|
def mksquashfs (bttargetdir, btrootfsmnt):
|
||||||
logger.info ('Iniciando la creación del sistema de archivos en sqfs')
|
logger.info ('Iniciando la creación del sistema de archivos en sqfs')
|
||||||
|
|
||||||
# si ya existe un sqfs lo renombramos
|
# si ya existe un sqfs lo renombramos
|
||||||
|
@ -387,8 +387,8 @@ def FsSqfs (bttargetdir, btrootfsmnt):
|
||||||
|
|
||||||
utils.write_md5 (f'{bttargetdir}/ogclient.sqfs')
|
utils.write_md5 (f'{bttargetdir}/ogclient.sqfs')
|
||||||
|
|
||||||
# IsoGenerator genera la iso del cliente
|
# mkisofs genera la iso del cliente
|
||||||
def IsoGenerator (pxepkg, isolinux_tpl, bttargetdir, nameisoclient):
|
def mkisofs (pxepkg, isolinux_tpl, bttargetdir, nameisoclient):
|
||||||
#Preparamos los gestores de arranque
|
#Preparamos los gestores de arranque
|
||||||
try: os.makedirs ('/tmp/iso/isolinux', exist_ok=True)
|
try: os.makedirs ('/tmp/iso/isolinux', exist_ok=True)
|
||||||
except: raise
|
except: raise
|
|
@ -8,9 +8,9 @@ import sys
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from boottoolsfunctions import utils, apt
|
from boottools import utils, apt
|
||||||
|
|
||||||
config = utils.read_config ('boottoolsgenerator.cfg')
|
config = utils.read_config ('mkoglive.cfg')
|
||||||
if config is None:
|
if config is None:
|
||||||
sys.exit (1)
|
sys.exit (1)
|
||||||
debconf_settings = config['General'].get ('debconf_settings')
|
debconf_settings = config['General'].get ('debconf_settings')
|
|
@ -10,7 +10,7 @@ import shutil
|
||||||
|
|
||||||
curdir = os.path.dirname (__file__)
|
curdir = os.path.dirname (__file__)
|
||||||
sys.path.insert (0, curdir)
|
sys.path.insert (0, curdir)
|
||||||
from boottoolsfunctions import utils, apt, btog
|
from boottools import utils, apt, btog
|
||||||
|
|
||||||
def _logging():
|
def _logging():
|
||||||
#logging.root.handlers = []
|
#logging.root.handlers = []
|
||||||
|
@ -58,14 +58,14 @@ def _mkrootfs():
|
||||||
rc = subprocess.run (f'file "{btrootfsimg}" |grep -q "partition 1 *: ID=0x83"', shell=True).returncode
|
rc = subprocess.run (f'file "{btrootfsimg}" |grep -q "partition 1 *: ID=0x83"', shell=True).returncode
|
||||||
print (rc)
|
print (rc)
|
||||||
if (rc): ## 'file|grep' failed
|
if (rc): ## 'file|grep' failed
|
||||||
try: btog.SetFsVirtual (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisksize, bttargetdir, osarch)
|
try: btog.mkrootfs (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisksize, bttargetdir, osarch)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error (str (e))
|
logger.error (str (e))
|
||||||
sys.exit (1)
|
sys.exit (1)
|
||||||
|
|
||||||
def _schroot (btrootfsimg):
|
def _schroot (btrootfsimg):
|
||||||
logger.info ('Stage 3.2 - configure schroot in the VM')
|
logger.info ('Stage 3.2 - configure schroot in the VM')
|
||||||
btog.SetFsAccess (btrootfsimg)
|
btog.configure_schroot (btrootfsimg)
|
||||||
|
|
||||||
## para hacer schroot --cosas, el mntpt tiene que estar desmontado
|
## para hacer schroot --cosas, el mntpt tiene que estar desmontado
|
||||||
## si está montado da un pete tal que 'E: 10mount: mount: /run/schroot/mount/IMGogclient-7fbf51a2-e37e-48e5-8e5d-83f8901fc7ed: wrong fs type, bad option, bad superblock on /dev/loop1, missing codepage or helper program, or other error.'
|
## si está montado da un pete tal que 'E: 10mount: mount: /run/schroot/mount/IMGogclient-7fbf51a2-e37e-48e5-8e5d-83f8901fc7ed: wrong fs type, bad option, bad superblock on /dev/loop1, missing codepage or helper program, or other error.'
|
||||||
|
@ -76,9 +76,9 @@ def _debootstrap():
|
||||||
logger.debug ('Running \'schroot --chroot IMGogclient -- stat /etc\'')
|
logger.debug ('Running \'schroot --chroot IMGogclient -- stat /etc\'')
|
||||||
cp = subprocess.run (['schroot', '--chroot', 'IMGogclient', '--', 'stat', '/etc'])
|
cp = subprocess.run (['schroot', '--chroot', 'IMGogclient', '--', 'stat', '/etc'])
|
||||||
if (cp.returncode):
|
if (cp.returncode):
|
||||||
logger.debug (f'schroot returned code "{cp.returncode}", calling btog.SetFsBase()')
|
logger.debug (f'schroot returned code "{cp.returncode}", calling btog.debootstrap()')
|
||||||
_mount_rootfs()
|
_mount_rootfs()
|
||||||
try: btog.SetFsBase (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp)
|
try: btog.debootstrap (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error (str (e))
|
logger.error (str (e))
|
||||||
sys.exit (1)
|
sys.exit (1)
|
||||||
|
@ -89,25 +89,25 @@ def _initramfs_version (gitrelease, osrelease, btdir):
|
||||||
#sed -i "1 s/$/ $GITRELEASE ($OSRELEASE)/" ${BTDIR}/includes/etc/initramfs-tools/scripts/VERSION.txt
|
#sed -i "1 s/$/ $GITRELEASE ($OSRELEASE)/" ${BTDIR}/includes/etc/initramfs-tools/scripts/VERSION.txt
|
||||||
utils.run (['sed', '-i', f'1 s/$/ {gitrelease} ({osrelease})/', f'{btdir}/includes/etc/initramfs-tools/scripts/VERSION.txt'])
|
utils.run (['sed', '-i', f'1 s/$/ {gitrelease} ({osrelease})/', f'{btdir}/includes/etc/initramfs-tools/scripts/VERSION.txt'])
|
||||||
|
|
||||||
def _copy_files (btrootfsmnt, osdistrib, oscodename):
|
def _copy_og_files (btrootfsmnt, osdistrib, oscodename):
|
||||||
_mount_rootfs()
|
_mount_rootfs()
|
||||||
builder = '/tmp/opengnsys/oglive_builder'
|
builder = '/tmp/opengnsys/oglive_builder'
|
||||||
og_shared = '/tmp/opengnsys/shared'
|
og_shared = '/tmp/opengnsys/shared'
|
||||||
og_engine = '/tmp/opengnsys/engine'
|
og_engine = '/tmp/opengnsys/engine'
|
||||||
btog.FsOpengnsys (builder, og_shared, og_engine, btrootfsmnt, osdistrib, oscodename)
|
btog.copy_og_files (builder, og_shared, og_engine, btrootfsmnt, osdistrib, oscodename)
|
||||||
utils.umount (btrootfsmnt)
|
utils.umount (btrootfsmnt)
|
||||||
|
|
||||||
def _chroot_tasks (curdir, osrelease, osarch):
|
def _chroot_tasks (curdir, osrelease, osarch):
|
||||||
logger.debug (f'running \'schroot --chroot IMGogclient -- {curdir}/03-boottoolsSoftwareInstall.py --osrelease "{osrelease}" --osarch "{osarch}"\'')
|
logger.debug (f'running \'schroot --chroot IMGogclient -- {curdir}/chroot-tasks.py --osrelease "{osrelease}" --osarch "{osarch}"\'')
|
||||||
stdout, _ = utils.run (['schroot', '--chroot', 'IMGogclient', '--', f'{curdir}/03-boottoolsSoftwareInstall.py', '--osrelease', osrelease, '--osarch', osarch])
|
stdout, _ = utils.run (['schroot', '--chroot', 'IMGogclient', '--', f'{curdir}/chroot-tasks.py', '--osrelease', osrelease, '--osarch', osarch])
|
||||||
logger.debug (f'03-boottoolsSoftwareInstall stdout follows:')
|
logger.debug (f'chroot-tasks.py stdout follows:')
|
||||||
## esto deja initrd.img-6.8.0-31-generic y vmlinuz-6.8.0-31-generic en /tmp
|
## 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)
|
for i in stdout.strip().split ('\n'): logger.debug (' ' + i)
|
||||||
|
|
||||||
def _ssh_stuff():
|
def _ssh_stuff():
|
||||||
_mount_rootfs()
|
_mount_rootfs()
|
||||||
btog.SshServer (btrootfsmnt)
|
btog.ssh_server (btrootfsmnt)
|
||||||
btog.SshClient (btrootfsmnt)
|
btog.ssh_client (btrootfsmnt)
|
||||||
utils.umount (btrootfsmnt)
|
utils.umount (btrootfsmnt)
|
||||||
## el resultado es:
|
## el resultado es:
|
||||||
## - hay un nuevo par de claves en la VM /root/.ssh
|
## - hay un nuevo par de claves en la VM /root/.ssh
|
||||||
|
@ -117,18 +117,18 @@ def _ssh_stuff():
|
||||||
def _mkinitrd_squashfs_isofs (bttargetdir, osrelease, btrootfsmnt, pxepkg, isolinux_tpl, nameisoclient):
|
def _mkinitrd_squashfs_isofs (bttargetdir, osrelease, btrootfsmnt, pxepkg, isolinux_tpl, nameisoclient):
|
||||||
logger.info ('Stage 6.1 - Put initrd in place')
|
logger.info ('Stage 6.1 - Put initrd in place')
|
||||||
_mount_rootfs()
|
_mount_rootfs()
|
||||||
btog.FsInitrd (bttargetdir, osrelease)
|
btog.move_initrd (bttargetdir, osrelease)
|
||||||
|
|
||||||
logger.info ('Stage 6.2 - make squash filesystem')
|
logger.info ('Stage 6.2 - make squash filesystem')
|
||||||
btog.FsSqfs (bttargetdir, btrootfsmnt)
|
btog.mksquashfs (bttargetdir, btrootfsmnt)
|
||||||
utils.umount (btrootfsmnt)
|
utils.umount (btrootfsmnt)
|
||||||
|
|
||||||
logger.info ('Stage 6.3 - make iso filesystem')
|
logger.info ('Stage 6.3 - make iso filesystem')
|
||||||
btog.IsoGenerator (pxepkg, isolinux_tpl, bttargetdir, nameisoclient)
|
btog.mkisofs (pxepkg, isolinux_tpl, bttargetdir, nameisoclient)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
config = utils.read_config ('boottoolsgenerator.cfg')
|
config = utils.read_config ('mkoglive.cfg')
|
||||||
if config is None:
|
if config is None:
|
||||||
sys.exit (1)
|
sys.exit (1)
|
||||||
isolinux_tpl = config['General'].get ('isolinux_template')
|
isolinux_tpl = config['General'].get ('isolinux_template')
|
||||||
|
@ -173,7 +173,7 @@ _debootstrap()
|
||||||
|
|
||||||
logger.info ('STAGE 4 - copy files to the rootfs')
|
logger.info ('STAGE 4 - copy files to the rootfs')
|
||||||
_initramfs_version (gitrelease, osrelease, btdir)
|
_initramfs_version (gitrelease, osrelease, btdir)
|
||||||
_copy_files (btrootfsmnt, osdistrib, oscodename)
|
_copy_og_files (btrootfsmnt, osdistrib, oscodename)
|
||||||
|
|
||||||
logger.info ('STAGE 5 - perform tasks within the chroot')
|
logger.info ('STAGE 5 - perform tasks within the chroot')
|
||||||
_chroot_tasks (curdir, osrelease, osarch)
|
_chroot_tasks (curdir, osrelease, osarch)
|
Loading…
Reference in New Issue