73 lines
4.0 KiB
Python
73 lines
4.0 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 = f'{svnclientdir}/includes/etc/apt/sources.list.{osdistrib.lower()}'
|
|
sources_list_out = f'{svnclientdir}/includes/etc/apt/sources.list'
|
|
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 (f'chmod -R 775 {svnclientdir}/includes/usr/bin/*', shell=True)
|
|
|
|
os.makedirs (f'{ogclientmount}/opt/opengnsys/lib/engine/bin/', exist_ok=True)
|
|
os.makedirs (f'{ogclientmount}/usr/local/etc', exist_ok=True)
|
|
os.makedirs (f'{ogclientmount}/usr/local/lib', exist_ok=True)
|
|
os.makedirs (f'{ogclientmount}/usr/local/plugins', exist_ok=True)
|
|
|
|
subprocess.run (f'rsync -aH {svnclientdir}/includes/* {ogclientmount}/' , shell=True)
|
|
subprocess.run (f'rsync -aH {svnclientstructure}/* {ogclientmount}/opt/opengnsys/' , shell=True)
|
|
subprocess.run (f'rsync -aH {svnclientengine}/* {ogclientmount}/opt/opengnsys/lib/engine/bin/', shell=True)
|
|
|
|
# Si no existe, copiar pci.ids.
|
|
if not os.path.exists (f'{ogclientmount}/etc/pci.ids'):
|
|
shutil.copy (f'{svnclientstructure}/lib/pci.ids', f'{ogclientmount}/etc/')
|
|
|
|
# Dependencias Qt para el Browser.
|
|
subprocess.run (f'rsync -aH {svnclientstructure}/etc/*.qmap {ogclientmount}/usr/local/etc', shell=True)
|
|
subprocess.run (f'rsync -aH {svnclientstructure}/lib/qtlib/* {ogclientmount}/usr/local/lib', shell=True)
|
|
subprocess.run (f'rsync -aH {svnclientstructure}/lib/fonts {ogclientmount}/usr/local/lib', shell=True)
|
|
subprocess.run (f'rsync -aH {svnclientstructure}/lib/qtplugins/* {ogclientmount}/usr/local/plugins', shell=True)
|
|
|
|
# Browser y ogAdmClient.
|
|
if os.path.exists (f'{svnclientstructure}/bin/browser'): shutil.copy (f'{svnclientstructure}/bin/browser', f'{ogclientmount}/bin/')
|
|
if os.path.exists (f'{svnclientstructure}/bin/ogAdmClient'): shutil.copy (f'{svnclientstructure}/bin/ogAdmClient', f'{ogclientmount}/bin/')
|
|
|
|
# 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)
|