#!/usr/bin/python3 import os import logging import subprocess import shutil import argparse svnclientdir = '/tmp/opengnsys/oglive_builder' svnclientstructure = '/tmp/opengnsys/shared' svnclientengine = '/tmp/opengnsys/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') 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) 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/') 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)