Compare commits

...

16 Commits
1.5.0 ... main

Author SHA1 Message Date
Natalia Serrano 8daaefffd1 Merge pull request 'refs #2858 improve detection of BCD files for the menu entries' (#127) from winloader-menu-entry into main
ogclient/pipeline/head This commit looks good Details
ogclient/pipeline/tag This commit looks good Details
Reviewed-on: #127
2025-10-02 14:26:03 +02:00
Natalia Serrano ae48530b95 refs #2858 improve detection of BCD files for the menu entries 2025-10-02 14:23:15 +02:00
Natalia Serrano ab552d571d Merge pull request 'refs #2856 allow to create images in regular ogLive (not ogLiveAdmin)' (#126) from crearimagen-oglive-no-admin into main
ogclient/pipeline/head There was a failure building this commit Details
ogclient/pipeline/tag There was a failure building this commit Details
Reviewed-on: #126
2025-10-02 10:26:56 +02:00
Natalia Serrano 9a0a3c2223 refs #2856 allow to create images in regular ogLive (not ogLiveAdmin) 2025-10-02 10:25:41 +02:00
Natalia Serrano 458c18a8d8 Merge pull request 'refs #2850 add cgi error page' (#125) from browser-err into main
ogclient/pipeline/head This commit looks good Details
ogclient/pipeline/tag This commit looks good Details
Reviewed-on: #125
2025-09-29 15:36:20 +02:00
Natalia Serrano de5d4bc04b refs #2850 add cgi error page 2025-09-29 15:35:46 +02:00
Natalia Serrano bcf69b6bfe Merge pull request 'refs #2848 log less stuff' (#124) from log-less-stuff into main
ogclient/pipeline/head This commit looks good Details
ogclient/pipeline/tag This commit looks good Details
Reviewed-on: #124
2025-09-26 10:51:04 +02:00
Natalia Serrano 616885376d refs #2848 log less stuff 2025-09-26 10:50:43 +02:00
Natalia Serrano 88fe209510 Merge pull request 'refs #2229 #2844 #2846 fix three bugs' (#123) from fix-2-bugs into main
ogclient/pipeline/head This commit looks good Details
ogclient/pipeline/tag This commit looks good Details
Reviewed-on: #123
2025-09-25 13:29:56 +02:00
Natalia Serrano c2bbe97ca1 refs #2229 #2844 #2846 fix three bugs 2025-09-25 13:29:14 +02:00
Natalia Serrano b9e3559039 Merge pull request 'refs #2229 send gitlib progress to ogcore' (#122) from gitlib-progress into main
ogclient/pipeline/head This commit looks good Details
ogclient/pipeline/tag This commit looks good Details
Reviewed-on: #122
2025-09-23 13:15:24 +02:00
Natalia Serrano f338f950e4 refs #2229 send gitlib progress to ogcore 2025-09-23 13:13:06 +02:00
Natalia Serrano dc2251d771 Merge pull request 'refs #2647 improve error message' (#121) from getgitdata-misleading-error into main
ogclient/pipeline/head This commit looks good Details
ogclient/pipeline/tag This commit looks good Details
Reviewed-on: #121
2025-09-12 14:51:07 +02:00
Natalia Serrano 25675c5789 refs #2647 improve error message 2025-09-12 14:50:22 +02:00
Natalia Serrano e32d736a71 Merge pull request 'refs #2778 fix multiple bugs' (#120) from oginit-else-branch into main
ogclient/pipeline/head This commit looks good Details
ogclient/pipeline/tag This commit looks good Details
Reviewed-on: #120
2025-09-12 14:40:58 +02:00
Natalia Serrano c777205e37 refs #2778 fix multiple bugs 2025-09-12 14:37:48 +02:00
13 changed files with 155 additions and 148 deletions

View File

@ -5,6 +5,54 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.7.2] - 2025-10-02
### Fixed
- Improve detection of BCD files for the menu entries
## [1.7.1] - 2025-10-02
### Fixed
- Allow to create images in regular ogLive (not ogLiveAdmin)
## [1.7.0] - 2025-09-29
### Added
- Add CGI error page
## [1.6.2] - 2025-09-26
### Fixed
- Have gitlib log less stuff, to prevent the execution from getting stuck
## [1.6.1] - 2025-09-25
### Fixed
- Fix three bugs
## [1.6.0] - 2025-09-23
### Added
- Send gitlib progress to ogcore
## [1.5.2] - 2025-09-12
### Fixed
- Improved error message
## [1.5.1] - 2025-09-12
### Fixed
- Fixed multiple bugs in a rarely-executed "else" branch
## [1.5.0] - 2025-09-11
### Changed

View File

@ -11,12 +11,11 @@ from NetLib import ogGetIpAddress
ogstatus = os.environ.get ('ogstatus', '')
ogcore = os.environ.get ('ogcore', '')
oglog = os.environ.get ('oglog', '')
oggroup = os.environ.get ('OGGROUP', '')
ogactiveadmin = os.environ.get ('ogactiveadmin', '')
LANG = os.environ.get ('LANG', 'es_ES')
LANG = LANG[0:LANG.index('_')]
LOGLEVEL=5
#LOGLEVEL=5
# Matando plymount para inicir browser o shell
subprocess.run (['pkill', '-9', 'plymouthd'])
@ -37,12 +36,16 @@ if os.path.exists ('/usr/share/OGAgent/opengnsys/linux/OGAgentService.py') and o
subprocess.run (['python3', '-m', 'opengnsys.linux.OGAgentService', 'fg'])
else:
ip = ogGetIpAddress()
OGMENU = ''
for FILE in [index, oggroup, ip]:
OGMENU = None
for FILE in ['index', ip]:
if not FILE: continue
m = f'{ogGlobals.OGCAC}/menus/{FILE}.html'
if os.path.exists (m): OGMENU = m
subprocess.run ([f'{ogGlobals.OPENGNSYS}/bin/launch_browser', m])
if OGMENU:
subprocess.run ([f'/usr/bin/launch_browser', OGMENU])
else:
print ("ogagent not installed and couldn't find any menu to show")
# Si fallo en cliente y modo "admin", cargar shell; si no, salir.
if ogactiveadmin == 'true':

View File

@ -156,7 +156,8 @@ else:
sys.exit (1)
## si no nos definen partición de cache y el disco tiene una, hay que borrarla
if not cache_seen:
## pero solo cuando check_sizes es falso! si check_sizes es true no hay que tocar nada
if not cache_seen and not check_sizes:
c = CacheLib.ogFindCache()
if c:
cache_disk, cache_part = c.split()
@ -187,6 +188,7 @@ if not recreate_partition_table and not CacheLib.ogCheckNewCacheSize (dis, tch):
## size check: check that the newly defined partitions fit in the disk
disk_sectors = DiskLib.ogGetLastSector (dis)
if disk_sectors is None: disk_sectors = 1e15 ## if None, then the disk is empty--for the purposes of size checks, treat it as if it were arbitrarily large
IOSIZE = DiskLib.ogGetIoSize (dis)
if not IOSIZE:
SystemLib.ogRaiseError (['session', 'log'], ogGlobals.OG_ERR_FORMAT, f'Failed to get disk sector size')

View File

@ -73,7 +73,7 @@ if 'REPO' == repo or ogCheckIpAddress (repo):
sys.exit (1)
# Si el destino es REPO y el cliente no está en modo "admin"; activar repositorio para escritura,
if 'REPO' == repo and 'admin' != env_boot:
if 'admin' != env_boot:
retval = subprocess.run ([f'{dirname}/CambiarAcceso', 'admin']).returncode
if retval:
sys.exit (retval)

View File

@ -1,16 +1,14 @@
#!/usr/bin/env python3
import sys
import resource
import logging
import argparse
import ogGlobals
import SystemLib
import DiskLib
import NetLib
from GitLib import OpengnsysGitLibrary, NTFSImplementation, OgProgressPrinterWeb
@ -33,10 +31,8 @@ class OgLogger(logging.StreamHandler):
SystemLib.ogEcho(log_types, log_level, record.getMessage())
def create_image(disk_num, partition_num, repo, image_name, commit_message):
print ('[10] begin')
ntfs_impl = NTFSImplementation.NTFS3G
og_git = OpengnsysGitLibrary(ntfs_implementation = ntfs_impl)
og_git.progress_callback = OgProgressPrinterWeb()
@ -46,14 +42,15 @@ def create_image(disk_num, partition_num, repo, image_name, commit_message):
if device is None:
sys.exit(SystemLib.ogRaiseError([], ogGlobals.OG_ERR_FORMAT, f"Failed to translate disk {disk_num} partition {partition_num} to a device"))
print ('[50] initRepo')
if og_git.initRepo(device, image_name, message = commit_message):
print ('[100] done')
return 0
else:
print ('[100] done')
return 1
def main():
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
try:
# Usamos el mínimo entre 65536 y el límite hard disponible
@ -63,7 +60,6 @@ def main():
except ValueError as e:
print(f"No se pudo aumentar el límite de archivos abiertos: {e}")
parser = argparse.ArgumentParser(
prog = "OpenGnsys Git Image Create",
description = "Creates a git repository from a partition"
@ -75,14 +71,11 @@ def main():
parser.add_argument("--image-name", type=str, metavar="REPO", required=True, help="Name of the new image at the repository")
parser.add_argument("--tag", type=str, metavar="TAG", required=False, help="Tag to automatically create")
parser.add_argument("--message", type=str, metavar="MSG", required=False, default="", help="Commit message")
parser.add_help = True
args = parser.parse_args()
#disk_num, partition_num, image_name, repo, tag = sys.argv[1:6]
logFilePath = "/var/log/opengnsys.CrearImagenGit.log"
ogLog = OgLogger()
@ -100,7 +93,6 @@ def main():
logger.addHandler(fileLog)
logger.addHandler(ogLog)
logger.info("Starting CrearImagenGit")
# TODO:
@ -108,9 +100,6 @@ def main():
# image = nombre repo
retval = create_image(args.disk, args.partition, args.repository, args.image_name, args.message)
sys.exit(retval)
if __name__ == "__main__":

View File

@ -24,7 +24,9 @@ mntpt = ogMount (dsk, par)
git_dir = f'{mntpt}/.git'
if not os.path.exists (git_dir):
ogRaiseError (['log', 'session'], ogGlobals.OG_ERR_FORMAT, f'"{git_dir}" no existe')
if os.path.islink (git_dir): err_msg = f'"{git_dir}" apunta a un destino que no existe'
else: err_msg = f'"{git_dir}" no existe'
ogRaiseError (['log', 'session'], ogGlobals.OG_ERR_FORMAT, err_msg)
sys.exit (1)
p = subprocess.run (['git', '--git-dir', git_dir, 'branch', '--show-current'], capture_output=True, text=True)

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python3
import os
import subprocess
import sys
@ -6,7 +7,6 @@ import time
import resource
import argparse
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
try:
# Usamos el mínimo entre 65536 y el límite hard disponible
@ -22,17 +22,14 @@ extra_paths = [
"/opt/opengnsys/ogrepository/oggit/lib/"
]
# Si estás completamente seguro de que esta ruta no interfiere con la stdlib
# y contiene todos los módulos necesarios, puedes añadirla AL FINAL del path.
path_maybe_problematic = "/opt/oglive/rootfs/opt/opengnsys/lib/python3/"
if os.path.isdir(path_maybe_problematic):
sys.path.append(path_maybe_problematic)
for path in extra_paths:
if os.path.isdir(path):
sys.path.append(path)
#path_maybe_problematic = "/opt/oglive/rootfs/opt/opengnsys/lib/python3/"
#if os.path.isdir(path_maybe_problematic):
# sys.path.append(path_maybe_problematic)
# for path in extra_paths:
# if os.path.isdir(path):
# sys.path.append(path)
import NetLib
import ogGlobals
@ -40,12 +37,8 @@ import SystemLib
import logging
import DiskLib
import NetLib
from GitLib import OpengnsysGitLibrary, NTFSImplementation, OgProgressPrinterWeb
class OgLogger(logging.StreamHandler):
def emit(self, record):
log_types = ["command"]
@ -65,10 +58,8 @@ class OgLogger(logging.StreamHandler):
SystemLib.ogEcho(log_types, log_level, record.getMessage())
def commit_image(disk_num, partition_num, repository, branch, options, msg):
print ('[10] begin')
ntfs_impl = NTFSImplementation.NTFS3G
og_git = OpengnsysGitLibrary(ntfs_implementation = ntfs_impl)
og_git.progress_callback = OgProgressPrinterWeb()
@ -92,17 +83,17 @@ def commit_image(disk_num, partition_num, repository, branch, options, msg):
if not og_git.create_branch(device = device, name = branch):
sys.exit(SystemLib.ogRaiseError([], ogGlobals.OG_ERR_FORMAT, f"Failed to create branch"))
print ('[30] commit')
og_git.commit(device = device, message = msg)
print ('[50] push')
og_git.push(device = device, force = force_push)
except Exception as ex:
sys.exit(SystemLib.ogRaiseError([], ogGlobals.OG_ERR_FORMAT, f"Exception during commit: {ex}"))
print ('[100] done')
return 0
def main():
parser = argparse.ArgumentParser(
prog = "OpenGnsys Git Image Modify",
description = "Commits changes to a partition to a git repository"
@ -111,11 +102,9 @@ def main():
parser.add_argument("--disk", type=int, metavar="DISK", required=True, help="Disk ID")
parser.add_argument("--partition", type=int, metavar="PART", required=True, help="Disk partition")
parser.add_argument("--repository", type=str, metavar="REPO", required=True, help="Address of the Git repository to clone")
parser.add_argument("--branch", type=str, metavar="BRANCH", required=False, help="Branch to automatically create")
parser.add_argument("--options", type=str, metavar="OPTS", required=False, help="Options to branch creation (forcepush)")
parser.add_argument("--message", type=str, metavar="MSG", required=False, default="", help="Commit message")
parser.add_help = True
args = parser.parse_args()
@ -123,7 +112,7 @@ def main():
logFilePath = "/var/log/opengnsys.ModificarImagenGit.log"
ogLog = OgLogger()
ogLog.setLevel(logging.DEBUG)
ogLog.setLevel(logging.INFO)
fileLog = logging.FileHandler(logFilePath)
fileLog.setLevel(logging.DEBUG)
@ -139,10 +128,8 @@ def main():
logger.info("Starting ModificarImagenGit")
retval = commit_image(args.disk, args.partition, args.repository, args.branch, args.options, args.message)
logger.info("ModificarImagenGit done, return code %i", retval)
sys.exit(retval)

View File

@ -1,20 +1,17 @@
#!/usr/bin/env python3
import sys
import resource
import logging
import subprocess
import argparse
import NetLib
import ogGlobals
import SystemLib
import DiskLib
from GitLib import OpengnsysGitLibrary, NTFSImplementation, OgProgressPrinterWeb
import argparse
class OgLogger(logging.StreamHandler):
def emit(self, record):
log_types = ["command"]
@ -34,8 +31,6 @@ class OgLogger(logging.StreamHandler):
SystemLib.ogEcho(log_types, log_level, record.getMessage())
if __name__ == "__main__":
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
try:
@ -46,8 +41,6 @@ if __name__ == "__main__":
except ValueError as e:
print(f"No se pudo aumentar el límite de archivos abiertos: {e}")
parser = argparse.ArgumentParser(
prog = "OpenGnsys Git Image Restore",
description = "Restores an image from Git"
@ -57,19 +50,16 @@ if __name__ == "__main__":
parser.add_argument("--partition", type=int, metavar="PART", required=True, help="Disk partition")
parser.add_argument("--repository", type=str, metavar="REPO", required=True, help="Address of the Git repository to clone")
parser.add_argument("--image-name", type=str, metavar="REPO", required=True, help="Name of the new image at the repository")
parser.add_argument("--branch", type=str, metavar="BRANCH", required=True, help="Branch to check out")
parser.add_argument("--commit", type=str, metavar="COMMIT_ID", required=True, help="Commit to check out")
parser.add_help = True
args = parser.parse_args()
logFilePath = "/var/log/opengnsys.RestaurarImagenGit.log"
ogLog = OgLogger()
ogLog.setLevel(logging.DEBUG)
fileLog = logging.FileHandler(logFilePath)
fileLog.setLevel(logging.DEBUG)
@ -85,8 +75,7 @@ if __name__ == "__main__":
logger.info("Starting RestaurarImagenGit")
print ('[10] begin')
ntfs_impl = NTFSImplementation.NTFS3G
og_git = OpengnsysGitLibrary(ntfs_implementation = ntfs_impl)
og_git.progress_callback = OgProgressPrinterWeb()
@ -98,10 +87,9 @@ if __name__ == "__main__":
if args.repository:
og_git.repo_server = args.repository
print ('[50] cloneRepo')
og_git.cloneRepo(args.image_name, destination = device, boot_device = device, ref = args.commit, branch = args.branch)
print ('[80] configureOs')
subprocess.run(["/opt/opengnsys/scripts/configureOs", str(args.disk), str(args.partition)], check=True)
print ('[100] done')
logger.info("RestaurarImagenGit Finished.")

View File

@ -0,0 +1,12 @@
#!/bin/bash
echo "Content-type: text/html"
echo ""
echo "<html><head><title>OpenGnsys Client $(/opt/opengnsys/functions/ogGetIpAddress)</title>"
echo " <meta charset='utf-8'>"
echo "</head><body>"
echo "<h1>Ocurrió un error durante el arranque del agente</h1>"
echo "<p>Consulte el log del agente para más información</p>"
echo "</body></html>"

View File

@ -14,4 +14,4 @@ echo "<IFRAME SRC='cache.sh' WIDTH=590 HEIGHT=90><A HREF="cache.sh">link</a>
echo "<IFRAME SRC='LogSession.sh' WIDTH=850 HEIGHT=230> <A HREF="LogSession.sh">link</A> </IFRAME>"
echo "<IFRAME SRC='LogCommand.sh' WIDTH=850 HEIGHT=280> <A HREF="LogCommand.sh">link</A> </IFRAME>"
echo "</body>
echo "</body></html>"

View File

@ -10,5 +10,4 @@ echo "<html><head><title>OpenGnsys Client</title></head><body>"
$(wget http://172.17.9.205/opengnsys/varios/menubrowser.php -O /tmp/menu.tmp)
echo "$(cat /tmp/menu.tmp)"
echo "</body>
echo "</body></html>"

View File

@ -8,30 +8,19 @@
# python3.8
# Must have working locales, or unicode strings will fail. Install 'locales', configure /etc/locale.gen, run locale-gen.
#
import os
import sys
import shutil
import argparse
import tempfile
import logging
import subprocess
import json
from pathlib import Path
import base64
import stat
import time
import git
import libarchive
import xattr
@ -41,33 +30,23 @@ import re
import uuid
from tqdm import tqdm
from GitLib.filesystem import *
from GitLib.disk import *
from GitLib.ntfs import *
from GitLib.kernel import parse_kernel_cmdline
import CacheLib
#import requests
from CacheLib import ogMountCache
def _git_op_to_string(op):
op = op & git.RemoteProgress.OP_MASK
if op == git.RemoteProgress.COMPRESSING:
return "Compressing", "Obj"
elif op == git.RemoteProgress.CHECKING_OUT:
return "Checking out", "Obj"
elif op == git.RemoteProgress.COUNTING:
return "Counting", "Obj"
elif op == git.RemoteProgress.RECEIVING:
return "Receiving", "B"
elif op == git.RemoteProgress.WRITING:
return "Writing", "B"
elif op == git.RemoteProgress.RESOLVING:
return "Resolving deltas", "Obj"
if op == git.RemoteProgress.COMPRESSING: return "Compressing", "Obj"
elif op == git.RemoteProgress.CHECKING_OUT: return "Checking out", "Obj"
elif op == git.RemoteProgress.COUNTING: return "Counting", "Obj"
elif op == git.RemoteProgress.RECEIVING: return "Receiving", "B"
elif op == git.RemoteProgress.WRITING: return "Writing", "B"
elif op == git.RemoteProgress.RESOLVING: return "Resolving deltas", "Obj"
return "Unknown", "?"
@ -97,60 +76,44 @@ class OgProgressPrinterWeb(git.RemoteProgress):
"""
def __init__(self):
super().__init__()
#self.ogcore_ip = get_IPcore()
#self.endpoint_url = f"https://{ogcore_ip}:8443/og-repository/webhook"
self.logger = logging.getLogger(f"{__package__}.{self.__class__.__name__}")
#self.jobId = jobId
self.last_ts = time.time()
"""Total stages of the git process. This comes from Git itself."""
self.total_stages = 6
self.simple_progress = 0
self.prev_progress = -1
def _get_stage_number(self, op):
op = op & git.RemoteProgress.OP_MASK
if op == git.RemoteProgress.COUNTING: return 0
elif op == git.RemoteProgress.COMPRESSING: return 1
elif op == git.RemoteProgress.WRITING: return 2
elif op == git.RemoteProgress.CHECKING_OUT: return 3
elif op == git.RemoteProgress.RECEIVING: return 4
elif op == git.RemoteProgress.RESOLVING: return 5
if op == git.RemoteProgress.COUNTING:
return 0
elif op == git.RemoteProgress.COMPRESSING:
return 1
elif op == git.RemoteProgress.WRITING:
return 2
elif op == git.RemoteProgress.CHECKING_OUT:
return 3
elif op == git.RemoteProgress.RECEIVING:
return 4
elif op == git.RemoteProgress.RESOLVING:
return 5
def _send_progress(self, p):
i = int (100*p)
print (f'[{i}] {i}% done')
def update(self, op_code, cur_count, max_count=None, message=""):
# This shouldn't normally fail, but if it ever does, we don't want to fail the entire
# Git operation just because we're unable to report the status.
now = time.time()
if now - self.last_ts < 1: return
stage_portion = (100 / self.total_stages)
stage_portion = (1 / self.total_stages)
if max_count:
self.simple_progress = int((stage_portion * self._get_stage_number(op_code)) + ((stage_portion / max_count) * cur_count))
if self.prev_progress != self.simple_progress:
print(f"[{self.simple_progress}]")
self.prev_progress = self.simple_progress
self.simple_progress = stage_portion * self._get_stage_number(op_code) + (stage_portion * cur_count/max_count)
op_text, _ = _git_op_to_string(op_code)
self.logger.debug(f"Progress: {op_text} ({op_code}) {cur_count}/{max_count}: {message}")
self._send_progress (self.simple_progress)
self.last_ts = now
#try:
# data = json.dumps({"job_id" : self.jobId, "progress" : progress})
# headers = {'Content-Type': 'application/json'}
#
# response = requests.post(self.endpoint_url, data=data, headers=headers, verify=False)
#except Exception as e:
# self.logger.error("Exception %s while trying to report progress", e)
def __del__(self):
self._send_progress (1.0)
class OgProgressPrinterConsole(git.RemoteProgress):
"""
@ -304,7 +267,7 @@ class OpengnsysGitLibrary:
self.repo_image_path = "oggit"
self.ntfs_implementation = ntfs_implementation
self.cache_dir = CacheLib.ogMountCache()
self.cache_dir = ogMountCache()
# Si no hay cache, se va a crear el .git en el FS directamente
@ -464,14 +427,22 @@ class OpengnsysGitLibrary:
if result.returncode == 0:
self.logger.debug("Completed, return code %i", result.returncode)
self.logger.debug("STDOUT: %s", result.stdout)
self.logger.debug("STDERR: %s", result.stderr)
#self.logger.debug("STDOUT: %s", result.stdout)
#self.logger.debug("STDERR: %s", result.stderr)
else:
# An error return code can be returned for reasons like missing files, so we deal this
# as non-fatal.
self.logger.error("Completed, return code %i", result.returncode)
self.logger.error("STDOUT: %s", result.stdout)
#self.logger.error("STDOUT: %s", result.stdout)
fd = open ('/tmp/ntfssecaudit.stdout', 'wb')
fd.write (result.stdout)
fd.close()
self.logger.error("STDERR: %s", result.stderr)
fd = open ('/tmp/ntfssecaudit.stderr', 'wb')
fd.write (result.stderr)
fd.close()
self.fs.temp_remount(mountdata)
@ -541,6 +512,9 @@ class OpengnsysGitLibrary:
boot_device = self.fs.find_boot_device()
boot_mount = self.fs.find_mountpoint(boot_device)
if boot_mount is None:
self.logger.warning(f"Not installing EFI files--boot_mount is None")
return
self.logger.info(f"Installing EFI files in {boot_mount}")
meta_dir = os.path.join(root_directory, ".opengnsys-metadata")
@ -572,6 +546,9 @@ class OpengnsysGitLibrary:
def _efi_copy(self, root_directory, system_specific = False, config_name = None):
meta_dir = os.path.join(root_directory, ".opengnsys-metadata")
boot_device = self.fs.find_boot_device()
if boot_device is None:
self.logger.warning("Not copying EFI--boot_device is None")
return
boot_mount = self.fs.find_mountpoint(boot_device)
efi_files_dir = ""
@ -657,7 +634,7 @@ class OpengnsysGitLibrary:
self.logger.debug(f"Archive: {metadata}")
for entry in metadata:
self.logger.debug(entry)
#self.logger.debug(entry)
if entry.pathname in wanted_files:
self.logger.debug(f"Extracting {entry}")
data = bytearray()
@ -1149,7 +1126,7 @@ class OpengnsysGitLibrary:
with open(os.path.join(meta_dir, "empty_directories.jsonl"), "r", encoding='utf-8') as empties_file:
for line in empties_file:
if line.isspace():
self.logger.debug("Empty line, skipping")
#self.logger.debug("Empty line, skipping")
continue
empties_data = json.loads(line)
@ -1161,12 +1138,12 @@ class OpengnsysGitLibrary:
empty_dir_keep = os.path.join(path, empty_dir, ".opengnsys-keep")
self.logger.debug(f"Empty directory: {empty_dir}")
#self.logger.debug(f"Empty directory: {empty_dir}")
full_empty_dir = os.path.join(path, empty_dir)
Path(full_empty_dir).mkdir(parents=True, exist_ok=True)
if os.path.exists(empty_dir_keep):
self.logger.debug(f"Deleting: {empty_dir_keep}")
#self.logger.debug(f"Deleting: {empty_dir_keep}")
os.unlink(empty_dir_keep)
if not destructive_only:
@ -1763,6 +1740,7 @@ class OpengnsysGitLibrary:
origin = repo.remotes["origin"]
repo.heads.main.set_tracking_branch(origin.refs.main)
#repo.heads["main"].set_tracking_branch(origin.refs["main"])
ret = origin.push(progress=self.progress_callback, force = force)
ret.raise_if_error()
@ -1876,7 +1854,7 @@ if __name__ == '__main__':
logger.setLevel(logging.DEBUG)
streamLog = logging.StreamHandler()
streamLog.setLevel(logging.INFO)
streamLog.setLevel(logging.WARNING)
if not os.path.exists(opengnsys_log_dir):
os.mkdir(opengnsys_log_dir)

View File

@ -462,15 +462,14 @@ def ogGetOsVersion(disk, part):
# Para cargador Windows: buscar versión en fichero BCD (basado en os-prober).
if not version:
type = 'WinLoader'
file = FileLib.ogGetPath (file=f'{mntdir}/boot/bcd')
if not file:
file = FileLib.ogGetPath (file=f'{mntdir}/EFI/Microsoft/boot/bcd')
if file:
find_out = subprocess.run (['find', mntdir, '-type', 'f'], capture_output=True, text=True).stdout
bcd_files = list (filter (lambda x: 'Boot/BCD' in x, find_out.splitlines()))
if bcd_files:
for distrib in 'Windows Recovery', 'Windows Boot':
with open (file, 'rb') as fd:
contents = fd.read()
distrib_utf16_regex = re.sub (r'(.)', '\\1.', distrib)
distrib_utf16_regex = bytes (distrib_utf16_regex, 'ascii')
with open (bcd_files[0], 'rb') as fd:
contents = fd.read()
if re.search (distrib_utf16_regex, contents):
version = f'{distrib} loader'
# Para macOS: detectar kernel y completar con fichero plist de información del sistema.