refs #596 refactor (u)mounts
parent
c5e9f6858d
commit
c67b7f6e91
|
@ -35,6 +35,10 @@ def _grep (regex, file):
|
|||
def _is_mounted (mntpt):
|
||||
return _grep (mntpt, '/proc/mounts')
|
||||
|
||||
def _mount (dev, mntpt, opts=[]):
|
||||
if not _is_mounted (mntpt):
|
||||
_run (['mount', dev, mntpt] + opts)
|
||||
|
||||
def _umount (mntpt):
|
||||
if (_is_mounted (mntpt)):
|
||||
_run (['umount', mntpt])
|
||||
|
@ -302,17 +306,10 @@ def btogSetFsAccess (btrootfsimg):
|
|||
def btogSetFsBase (btrootfsimg, btrootfsmnt, osarch, oscodename, oshttp):
|
||||
logger.info ('Iniciando la generación del sistema de archivos')
|
||||
|
||||
#mount | grep $BTROOTFSMNT || mount $BTROOTFSIMG $BTROOTFSMNT -o loop,offset=32256
|
||||
if (not _is_mounted (btrootfsmnt)):
|
||||
raise Exception ('rootfs should be mounted')
|
||||
|
||||
logger.info ('debootstrapping system')
|
||||
logger.debug (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}"')
|
||||
try: _run (['debootstrap', f'--arch={osarch}', '--components=main,universe', oscodename, btrootfsmnt, oshttp])
|
||||
except:
|
||||
if (_is_mounted (btrootfsmnt)):
|
||||
_run (['umount', btrootfsmnt])
|
||||
raise Exception (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ha fallado!')
|
||||
except: raise Exception (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ha fallado!')
|
||||
|
||||
logger.info (f'debootstrap --arch="{osarch}" --components=main,universe "{oscodename}" "{btrootfsmnt}" "{oshttp}" : ok')
|
||||
return 0
|
||||
|
@ -441,7 +438,7 @@ def btogIsoGenerator (pxepkg, isolinux_tpl, bttargetdir, nameisoclient):
|
|||
os.mkdir ('/tmp/iso/isolinux/mount')
|
||||
_run (['mount', '-o', 'loop', f'/tmp/iso/isolinux/{pxepkg}.iso', '/tmp/iso/isolinux/mount'])
|
||||
subprocess.run (['cp -a /tmp/iso/isolinux/mount/* /tmp/iso/isolinux'], shell=True)
|
||||
_run (['umount', '/tmp/iso/isolinux/mount'])
|
||||
_umount ('/tmp/iso/isolinux/mount')
|
||||
os.rmdir ('/tmp/iso/isolinux/mount')
|
||||
os.unlink (f'/tmp/iso/isolinux/{pxepkg}.iso')
|
||||
|
||||
|
|
Loading…
Reference in New Issue