Compare commits
14 Commits
Author | SHA1 | Date |
---|---|---|
|
8daaefffd1 | |
|
ae48530b95 | |
|
ab552d571d | |
|
9a0a3c2223 | |
|
458c18a8d8 | |
|
de5d4bc04b | |
|
bcf69b6bfe | |
|
616885376d | |
|
88fe209510 | |
|
c2bbe97ca1 | |
|
b9e3559039 | |
|
f338f950e4 | |
|
dc2251d771 | |
|
25675c5789 |
42
CHANGELOG.md
42
CHANGELOG.md
|
@ -5,6 +5,48 @@ 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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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.")
|
||||
|
||||
|
||||
|
|
|
@ -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>"
|
|
@ -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>"
|
||||
|
|
|
@ -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>"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue