diff --git a/bin/updater/README.ES.md b/bin/updater/README.ES.md index 321a4f4..7476d08 100644 --- a/bin/updater/README.ES.md +++ b/bin/updater/README.ES.md @@ -39,53 +39,67 @@ re_version = # Portmon v(\d+\.\d+) Los valores utilizados para la configuración son: -| Nombre | Obligatorio | Descripción | -|----------------------|-------------|--------------------------------------------------------------------------------------------------------| -| `folder` | `SI` | Carpeta donde se guardara la herramienta. Si no existe la misma se creara. | -| `url` | `SI` | Web que se usara para realizar los chequeos con las regex. | -| `from` | `NO` | Indica la estrategia usada para el update. Los valores admitidos por el momento son: `web`, `github` o `http`. | -| `local_version` | `NO` | Versión descargada actualmente. Este valor se actualizara con cada update. | -| `re_version` | `NO` | Regex usado para comprobar si hay nuevas versiones en la web de `url`. | -| `re_download` | `NO` | Regex usado para obtener el link de descarga en la web de `url`. | -| `update_url` | `NO` | URL de descarga del update. Ver estrategia usadas para la descarga. | -| `update_file_pass` | `NO` | Usar esta contraseña para descomprimir el update. | -| `merge` | `NO` | Fusionar versión nueva con la local. | -| `pre_update_script` | `NO` | El script ingresado se ejecutara antes del proceso de update. | -| `post_update_script` | `NO` | El script ingresado se ejecutara después del proceso de update. | -| `pre_update` | `NO` | El script ingresado se ejecutara antes del proceso de update. | -| `post_update` | `NO` | El script ingresado se ejecutara después del proceso de update. | -| `post_unpack` | `NO` | El script ingresado se ejecutara después del proceso de unpack. | +| Nombre | Obligatorio | Descripción | +|--------------------|-------------|-----------------------------------------------------------------------------------------------------| +| `folder` | SÍ | Carpeta donde se guardará la herramienta. Se crea si no existe. | +| `url` | SÍ | Página web principal para comprobar versión y/o hacer scraping con regex. | +| `from` | NO | Estrategia a emplear: `web`, `github` o `http`. Por defecto `web`. | +| `local_version` | NO | Versión actualmente instalada. Se actualiza tras cada ejecución exitosa. | +| `re_version` | NO | Regex para extraer la nueva versión del HTML en `url`. | +| `re_download` | NO | Regex para extraer el enlace de descarga del HTML; puede capturar URL completa o ruta relativa. | +| `update_url` | NO | URL base o enlace directo de descarga. Se usa cuando `re_download` da ruta relativa o no hay regex. | +| `update_file_pass` | NO | Contraseña para descomprimir el archivo descargado. | +| `merge` | NO | Si está definido, fusiona los archivos nuevos con los existentes. | +| `pre_update` | NO | Comando o script a ejecutar antes de iniciar la actualización. | +| `post_update` | NO | Comando o script a ejecutar inmediatamente tras completar la descarga. | +| `post_unpack` | NO | Comando o script a ejecutar tras descomprimir el archivo descargado. | -## Estrategia usadas para la descarga -Combinando el uso de `update_url` y `re_download` se consiguen las siguientes estrategias de descarga: +## Estrategia de descarga + +1. **Si `re_download` está definido** + a. Extraer enlace del HTML de `url`. + b. Si el enlace es una URL absoluta válida → usarla. + c. Si es ruta relativa → + - Si `update_url` existe, anteponerla. + - Si no, construirla desde el esquema y host de `url`. + d. Si no hay match inicial y hay `update_url` → obtener HTML de `update_url`, reintentar regex. + e. Si sigue sin match → error. + +2. **Si solo está `update_url`** + Usar `update_url` como enlace de descarga. + +3. **Modo HTTP (`from = http`)** + - Envía una petición **HEAD** a `update_url`. + - Genera un identificador de versión hasheando el encabezado `Last-Modified` o `Content-Length`. + - Si difiere de `local_version` (o `force_download`), usa `update_url` para descargar. + - Si coincide y `force_download` es falso, no hay actualización. + +4. **En otro caso** + Error: no hay ni `re_download` ni `update_url` para determinar el enlace. -1. Usando solo `update_url` se descarga directamente sin ningún procesamiento extra. -2. Usando solo `re_download` se obtiene el link de descarga en la web de `url`. -3. Cuando se usan ambos parámetros se concatena el resultado de `re_download` con `update_url`. -Esto es útil para arreglar los links de descarga de GitHub o Sourceforge. -4. También se dispone de un método de detección de nuevas versiones que en lugar de regex usa las cabeceras http con las que responde el servidor. ## Parámetros de Línea de Comandos El actualizador ofrece un conjunto flexible de parámetros para controlar su comportamiento: -| Parámetro | Descripción | -|--------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| -| `-h, --help` | Muestra este mensaje de ayuda y finaliza. | -| `-v, --version` | Muestra el número de versión del programa y finaliza. | -| `-u [UPDATE ...], --update [UPDATE ...]` | Especifica una lista de herramientas a actualizar. Si no se proporciona, se actualizarán todas. | -| `-dsu, --disable-self-update` | Desactiva la auto-actualización automática del script. | -| `-dfc, --disable-folder-clean` | Evita limpiar la carpeta de herramientas durante las actualizaciones. | -| `-dr, --disable-repack` | Impide empaquetar nuevamente las herramientas después del proceso de actualización. | -| `-dic, --disable-install-check` | Omite la verificación de si las herramientas están instaladas correctamente. | -| `-dpb, --disable-progress-bar` | Desactiva la barra de progreso durante las descargas. | +| Parámetro | Descripción | +|--------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------| +| `-h, --help` | Muestra este mensaje de ayuda y finaliza. | +| `-v, --version` | Muestra el número de versión del programa y finaliza. | +| `-u [UPDATE ...], --update [UPDATE ...]` | Especifica una lista de herramientas a actualizar. Si no se proporciona, se actualizarán todas. | +| `-dsu, --disable-self-update` | Desactiva la auto-actualización automática del script. | +| `-dfc, --disable-folder-clean` | Evita limpiar la carpeta de herramientas durante las actualizaciones. | +| `-dr, --disable-repack` | Impide empaquetar nuevamente las herramientas después del proceso de actualización. | +| `-dic, --disable-install-check` | Omite la verificación de si las herramientas están instaladas correctamente. | +| `-dpb, --disable-progress-bar` | Desactiva la barra de progreso durante las descargas. | | `-sft {full,version,name}, --save-format-type {full,version,name}` | Especifica el tipo de formato para guardar las actualizaciones comprimidas: `full`, `version` o `name`. | -| `-f, --force` | Fuerza la descarga de actualizaciones, incluso si ya están actualizadas. | -| `-uga USE_GITHUB_API, --use-github-api USE_GITHUB_API` | Usa la API de GitHub para actualizaciones, especificando el token para autenticarse. | -| `-udp, --update-default-params` | Actualiza los parámetros predeterminados almacenados en la configuración. | -| `-dmc, --disable-mutex-check` | Permite ejecutar múltiples instancias del script desactivando la verificación de mutex. | -| `-d, --debug` | Activa la salida detallada de depuración para resolver problemas. | +| `-f, --force` | Fuerza la descarga de actualizaciones, incluso si ya están actualizadas. | +| `-uga USE_GITHUB_API, --use-github-api USE_GITHUB_API` | Usa la API de GitHub para actualizaciones, especificando el token para autenticarse. | +| `-udp, --update-default-params` | Actualiza los parámetros predeterminados almacenados en la configuración. | +| `-dmc, --disable-mutex-check` | Permite ejecutar múltiples instancias del script desactivando la verificación de mutex. | +| `-d, --debug` | Activa la salida detallada de depuración para resolver problemas. | + ## Ejemplos diff --git a/bin/updater/README.md b/bin/updater/README.md index e3b9873..e61acda 100644 --- a/bin/updater/README.md +++ b/bin/updater/README.md @@ -39,51 +39,66 @@ re_version = # Portmon v(\d+\.\d+) The values used for configuration are: -| Name | Mandatory | Description | -|--------------------|-----------|------------------------------------------------------------------------------------------------| -| `folder` | `YES` | Folder where the tool will be saved. If it does not exist, it will be created. | -| `url` | `YES` | Web that will be used to perform the checks with the regex. | -| `from` | `NO` | Indicates the strategy used for the update. Currently supported values are: `web`, `github` or `http`. | -| `local_version` | `NO` | Currently downloaded version. This value will be updated with each update. | -| `re_version` | `NO` | Regex used to check for new versions on the web used in `url`. | -| `re_download` | `NO` | Regex used to get the download link on the web used in `url`. | -| `update_url` | `NO` | Update download URL. See "Strategy for download" for more info. | -| `update_file_pass` | `NO` | Use this password to unzip the update. | -| `merge` | `NO` | Merge new version with local. | -| `pre_update` | `NO` | The entered script will be executed before the update process. | -| `post_update` | `NO` | The entered script will be executed after the update process. | -| `post_unpack` | `NO` | The entered script will be executed after unpack the update file. | +| Name | Mandatory | Description | +|--------------------|-----------|----------------------------------------------------------------------------------------------------------------| +| `folder` | YES | Folder where the tool will be saved. If it does not exist, it will be created. | +| `url` | YES | Web page used as the primary source for version check and/or regex scraping. | +| `from` | NO | Strategy to use: `web`, `github` or `http`. Default is `web`. | +| `local_version` | NO | Currently installed version. Updated after each successful run. | +| `re_version` | NO | Regex to extract the new version string from the HTML at `url`. | +| `re_download` | NO | Regex to extract the download link from HTML. Should capture either a full URL or a relative path. | +| `update_url` | NO | Base URL or direct download link. Used when `re_download` yields a relative path or when no regex is provided. | +| `update_file_pass` | NO | Password to unzip the downloaded archive. | +| `merge` | NO | If set, merge the freshly downloaded files into the existing folder. | +| `pre_update` | NO | Script or command to run before performing the update. | +| `post_update` | NO | Script or command to run immediately after the update download completes. | +| `post_unpack` | NO | Script or command to run after unpacking the downloaded archive. | + ## Strategy for download -Combining the use of `update_url` and `re_download` the following download strategies are achieved: +1. **If `re_download` is set** + a. Try to extract link from the initial `url` HTML. + b. If you get a match and it’s a valid absolute URL → use it. + c. If you get a match but it’s a relative path → + - If `update_url` is defined, prepend it. + - Otherwise, build from the original page’s scheme+netloc. + d. If no match on the initial HTML and `update_url` is defined → fetch `update_url` once, retry the same regex. + e. If still no match → raise an error. + +2. **Else if only `update_url` is set** + Use `update_url` directly as the download link. + +3. **HTTP mode (`from = http`)** + - Sends a **HEAD** request to `update_url`. + - Extracts a version fingerprint by hashing either the `Last-Modified` or `Content-Length` header. + - If the hash differs from `local_version` (or `force_download`), uses `update_url` as the download link. + - If the headers match and `force_download` is false, no update is performed. + +4. **Otherwise** + Error out: neither `re_download` nor `update_url` provided, so no download link can be determined. -1. Using only `update_url` it downloads directly without any extra processing. -2. Using only `re_download` you get the download link on the web from `url`. -3. When using both parameters, the result of `re_download` is concatenated with `update_url`. -This is useful for fixing GitHub or Sourceforge download links. -4. A new version detection method is also available that instead of regex uses the http headers with which the server responds. ## Command-line Parameters The updater provides a flexible set of parameters to control its behavior: -| Parameter | Description | -|--------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| -| `-h, --help` | Show this help message and exit. | -| `-v, --version` | Display the program's version number and exit. | -| `-u [UPDATE ...], --update [UPDATE ...]` | Specify a list of tools to update. Defaults to updating all tools if not provided. | -| `-dsu, --disable-self-update` | Disable automatic self-update of this script. | -| `-dfc, --disable-folder-clean` | Skip cleaning the tool's folder during updates. | -| `-dr, --disable-repack` | Prevent repacking of tools after the update process. | -| `-dic, --disable-install-check` | Skip checking if the tools are properly installed. | -| `-dpb, --disable-progress-bar` | Disable the download progress bar for updates. | -| `-sft {full,version,name}, --save-format-type {full,version,name}` | Specify the save format type for compressed updates: `full`, `version`, or `name`. | -| `-f, --force` | Force the download of updates, even if they appear up to date. | -| `-uga USE_GITHUB_API, --use-github-api USE_GITHUB_API` | Use the GitHub API for updates, specifying the token to authenticate. | -| `-udp, --update-default-params` | Update the default parameters stored in the configuration. | -| `-dmc, --disable-mutex-check` | Allow multiple instances of the script to run simultaneously by disabling the mutex check. | -| `-d, --debug` | Enable detailed debug output for troubleshooting. | +| Parameter | Description | +|--------------------------------------------------------------------|--------------------------------------------------------------------------------------------| +| `-h, --help` | Show this help message and exit. | +| `-v, --version` | Display the program's version number and exit. | +| `-u [UPDATE ...], --update [UPDATE ...]` | Specify a list of tools to update. Defaults to updating all tools if not provided. | +| `-dsu, --disable-self-update` | Disable automatic self-update of this script. | +| `-dfc, --disable-folder-clean` | Skip cleaning the tool's folder during updates. | +| `-dr, --disable-repack` | Prevent repacking of tools after the update process. | +| `-dic, --disable-install-check` | Skip checking if the tools are properly installed. | +| `-dpb, --disable-progress-bar` | Disable the download progress bar for updates. | +| `-sft {full,version,name}, --save-format-type {full,version,name}` | Specify the save format type for compressed updates: `full`, `version`, or `name`. | +| `-f, --force` | Force the download of updates, even if they appear up to date. | +| `-uga USE_GITHUB_API, --use-github-api USE_GITHUB_API` | Use the GitHub API for updates, specifying the token to authenticate. | +| `-udp, --update-default-params` | Update the default parameters stored in the configuration. | +| `-dmc, --disable-mutex-check` | Allow multiple instances of the script to run simultaneously by disabling the mutex check. | +| `-d, --debug` | Enable detailed debug output for troubleshooting. | ## Examples diff --git a/bin/updater/updater.exe b/bin/updater/updater.exe index 4017378..cfad50d 100644 Binary files a/bin/updater/updater.exe and b/bin/updater/updater.exe differ