oglive-builder/02-boottoolsFsOpengnsys.py

75 lines
4.2 KiB
Python

#!/usr/bin/python3
import os
import logging
import subprocess
import shutil
import argparse
#VERSIONBOOTTOOLS="ogLive"
nameisoclientfile = '/tmp/opengnsys_info_rootfs'
namehostclientfile = '/tmp/opengnsys_chroot'
svnclientdir = '/tmp/opengnsys_installer/opengnsys/client/boot-tools'
svnclientstructure = '/tmp/opengnsys_installer/opengnsys/client/shared'
svnclientengine = '/tmp/opengnsys_installer/opengnsys/client/engine'
def boottoolsFsOpengnsys (ogclientmount, osdistrib, oscodename, osrelease, osarch, oshttp):
print (':'.join ([osdistrib, oscodename, osrelease, osarch, oshttp]))
print ('Iniciando la personalización con datos del repositorio')
#sed -e "s/OSCODENAME/$OSCODENAME/g" ${SVNCLIENTDIR}/includes/etc/apt/sources.list.${OSDISTRIB,,} > ${SVNCLIENTDIR}/includes/etc/apt/sources.list
sources_list_in = '{}/includes/etc/apt/sources.list.{}'.format (svnclientdir, osdistrib.lower())
sources_list_out = '{}/includes/etc/apt/sources.list'.format (svnclientdir)
fdin = open (sources_list_in, 'r')
fdout = open (sources_list_out, 'w')
while True:
l = fdin.readline()
if not l: break
fdout.write (l.replace ('OSCODENAME', oscodename))
fdin.close()
fdout.close()
subprocess.run ('chmod -R 775 {}/includes/usr/bin/*'.format (svnclientdir), shell=True)
os.makedirs ('{}/opt/opengnsys/lib/engine/bin/'.format (ogclientmount), exist_ok=True)
os.makedirs ('{}/usr/local/etc' .format (ogclientmount), exist_ok=True)
os.makedirs ('{}/usr/local/lib' .format (ogclientmount), exist_ok=True)
os.makedirs ('{}/usr/local/plugins' .format (ogclientmount), exist_ok=True)
subprocess.run ('rsync -aH {}/includes/* {}/' .format (svnclientdir, ogclientmount), shell=True)
subprocess.run ('rsync -aH {}/* {}/opt/opengnsys/' .format (svnclientstructure, ogclientmount), shell=True)
subprocess.run ('rsync -aH {}/* {}/opt/opengnsys/lib/engine/bin/'.format (svnclientengine, ogclientmount), shell=True)
# Si no existe, copiar pci.ids.
if not os.path.exists ('{}/etc/pci.ids'.format (ogclientmount)):
shutil.copy ('{}/lib/pci.ids'.format (svnclientstructure), '{}/etc/'.format (ogclientmount))
# Dependencias Qt para el Browser.
subprocess.run ('rsync -aH {}/etc/*.qmap {}/usr/local/etc' .format (svnclientstructure, ogclientmount), shell=True)
subprocess.run ('rsync -aH {}/lib/qtlib/* {}/usr/local/lib' .format (svnclientstructure, ogclientmount), shell=True)
subprocess.run ('rsync -aH {}/lib/fonts {}/usr/local/lib' .format (svnclientstructure, ogclientmount), shell=True)
subprocess.run ('rsync -aH {}/lib/qtplugins/* {}/usr/local/plugins'.format (svnclientstructure, ogclientmount), shell=True)
# Browser y ogAdmClient.
if os.path.exists ('{}/bin/browser'.format (svnclientstructure)):
shutil.copy ('{}/bin/browser'.format (svnclientstructure), '{}/bin/'.format (ogclientmount))
if os.path.exists ('{}/bin/ogAdmClient'.format (svnclientstructure)):
shutil.copy ('{}/bin/ogAdmClient'.format (svnclientstructure), '{}/bin/'.format (ogclientmount))
# El fichero de configuración debe sustituir a los 2 ficheros (borrar las 2 líneas).
#echo "${VERSIONBOOTTOOLS}-${OSCODENAME}-${OSRELEASE}-${GITRELEASE}" > $nameisoclientfile
#echo "${VERSIONBOOTTOOLS}-${OSCODENAME}-${GITRELEASE}" > $namehostclientfile
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument ('--mntpt', help='rootfs mount point', action='store', required=True)
parser.add_argument ('--osdistrib', help='OS distribution', action='store', required=True)
parser.add_argument ('--oscodename', help='OS codename', 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 ('--oshttp', help='OS HTTP source', action='store', required=True)
args = parser.parse_args()
boottoolsFsOpengnsys (args.mntpt, args.osdistrib, args.oscodename, args.osrelease, args.osarch, args.oshttp)