From 7473ade86640d955ab72ade6b1fa782d86b4ccdf Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 20 Feb 2024 00:33:47 +0400 Subject: [PATCH 01/75] get latest version body --- update.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 update.sh diff --git a/update.sh b/update.sh new file mode 100644 index 00000000..37ec9714 --- /dev/null +++ b/update.sh @@ -0,0 +1,11 @@ +#!/bin/bash +dp0="$(realpath "$(dirname "$0")")" +dp0_tools="$dp0/.tools" && source "$dp0_tools/env_tools.sh" +set -e +cd "$dp0" + + +latest_version=https://api.github.com/repos/hemnstill/AutoinstallCreator/releases/tags/latest-master +echo Get latest version: "$latest_version" ... +download_url=$($curl --silent --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.(?=\\n")' | head -n1) +echo "$download_url" From 957cd6fedd0478505eff739ac9e85e7f56658940 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 23 Feb 2024 20:35:13 +0400 Subject: [PATCH 02/75] version_number version_hash --- update.bat | 4 ++++ update.sh | 24 ++++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 update.bat diff --git a/update.bat b/update.bat new file mode 100644 index 00000000..e98d57ca --- /dev/null +++ b/update.bat @@ -0,0 +1,4 @@ +@echo off +"%~dp0.tools\busybox.exe" bash "%~dp0update.sh" + +exit /b %errorlevel% diff --git a/update.sh b/update.sh index 37ec9714..c4bc8213 100644 --- a/update.sh +++ b/update.sh @@ -4,8 +4,24 @@ dp0_tools="$dp0/.tools" && source "$dp0_tools/env_tools.sh" set -e cd "$dp0" - -latest_version=https://api.github.com/repos/hemnstill/AutoinstallCreator/releases/tags/latest-master +self_name=AutoinstallCreator +latest_version=https://api.github.com/repos/hemnstill/$self_name/releases/tags/latest-master echo Get latest version: "$latest_version" ... -download_url=$($curl --silent --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.(?=\\n")' | head -n1) -echo "$download_url" +version_body=$($curl --silent --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.(?=\\n")' | head -n 1) +echo "version_body: $version_body" +[[ -z "$version_body" ]] && { + echo "Cannot get 'version_body'" + exit 1 +} + +version_number=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.)[^\s]+.(?=\.)" | head -n 1) +[[ -z "$version_number" ]] && { + echo "Cannot get 'version_number' from $version_body" + exit 1 +} + +version_hash=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.$version_number\.)[^\s]+." | head -n 1) +[[ -z "$version_hash" ]] && { + echo "Cannot get 'version_hash' from $version_body" + exit 1 +} From 37be8db961711032daf3e320a2e546d029e0b683 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 23 Feb 2024 21:37:56 +0400 Subject: [PATCH 03/75] add version.txt to release.sh --- .gitignore | 1 + _AutoinstallCreator/release.sh | 8 ++++++-- update.sh | 9 +++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 29f3ea79..549b8c60 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ __pycache__ .tools/python/ _AutoinstallCreator/*.txt +_AutoinstallCreator/AutoinstallCreator* *.exe *.dll diff --git a/_AutoinstallCreator/release.sh b/_AutoinstallCreator/release.sh index 529702da..c1837ae0 100755 --- a/_AutoinstallCreator/release.sh +++ b/_AutoinstallCreator/release.sh @@ -9,6 +9,10 @@ self_count="$(cd "$dp0/.." && git rev-list --count HEAD)" self_hash="$(cd "$dp0/.." && git show --abbrev=10 --no-patch --pretty=%h HEAD)" self_version=$self_name.$self_count.$self_hash +self_version_filepath=$dp0/version.txt + +{ printf "$self_version" +} > "$self_version_filepath" tool_version=release-2.4.5-cmd download_url="https://github.com/hemnstill/makeself/archive/refs/tags/$tool_version.tar.gz" @@ -19,7 +23,7 @@ makeself_sh_path="$makeself_target_path/makeself.sh" [[ ! -f "$makeself_version_path" ]] && { echo "::group::prepare sources $download_url" - wget "$download_url" -O "$makeself_version_path" + $curl --silent --location "$download_url" --output "$makeself_version_path" tar -xf "$makeself_version_path" } @@ -28,7 +32,7 @@ rm -rf "$temp_dir_path" && mkdir -p "$temp_dir_path" release_version_dirpath="$temp_dir_path/$self_version" tmp_version_path="$temp_dir_path/tmp_version.zip" -(cd "$dp0/.." && git archive --format zip -1 --output "$tmp_version_path" HEAD) +(cd "$dp0/.." && git archive --prefix "_$self_name/" --add-file="$self_version_filepath" --prefix "" --format zip -1 --output "$tmp_version_path" HEAD) "$p7z" x "$tmp_version_path" "-o$release_version_dirpath" diff --git a/update.sh b/update.sh index c4bc8213..e1aadd37 100644 --- a/update.sh +++ b/update.sh @@ -14,14 +14,15 @@ echo "version_body: $version_body" exit 1 } -version_number=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.)[^\s]+.(?=\.)" | head -n 1) -[[ -z "$version_number" ]] && { - echo "Cannot get 'version_number' from $version_body" +version_count=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.)[^\s]+.(?=\.)" | head -n 1) +[[ -z "$version_count" ]] && { + echo "Cannot get 'version_count' from $version_body" exit 1 } -version_hash=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.$version_number\.)[^\s]+." | head -n 1) +version_hash=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.$version_count\.)[^\s]+." | head -n 1) [[ -z "$version_hash" ]] && { echo "Cannot get 'version_hash' from $version_body" exit 1 } + From c66bd76afc00b4da39c8cb991bf24a17eaa0b751 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 23 Feb 2024 21:47:27 +0400 Subject: [PATCH 04/75] get self_version_body --- update.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index e1aadd37..c64bab85 100644 --- a/update.sh +++ b/update.sh @@ -5,6 +5,24 @@ set -e cd "$dp0" self_name=AutoinstallCreator + +self_version_body=$(head -n 1 "$dp0/_$self_name/version.txt") +echo "self_version_body: $self_version_body" +[[ -z "$self_version_body" ]] && { + echo "Cannot get 'self_version_body'" + exit 1 +} +self_version_count=$(echo "$self_version_body" | "$grep" --only-matching "(?<=$self_name\.)[^\s]+.(?=\.)" | head -n 1) +[[ -z "$self_version_count" ]] && { + echo "Cannot get 'self_version_count' from $self_version_body" + exit 1 +} +self_version_hash=$(echo "$self_version_body" | "$grep" --only-matching "(?<=$self_name\.$self_version_count\.)[^\s]+." | head -n 1) +[[ -z "$self_version_hash" ]] && { + echo "Cannot get 'self_version_hash' from $self_version_body" + exit 1 +} + latest_version=https://api.github.com/repos/hemnstill/$self_name/releases/tags/latest-master echo Get latest version: "$latest_version" ... version_body=$($curl --silent --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.(?=\\n")' | head -n 1) @@ -13,13 +31,11 @@ echo "version_body: $version_body" echo "Cannot get 'version_body'" exit 1 } - version_count=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.)[^\s]+.(?=\.)" | head -n 1) [[ -z "$version_count" ]] && { echo "Cannot get 'version_count' from $version_body" exit 1 } - version_hash=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.$version_count\.)[^\s]+." | head -n 1) [[ -z "$version_hash" ]] && { echo "Cannot get 'version_hash' from $version_body" From e8d46e47d081d372525ad6bddd74402103c2967b Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 23 Feb 2024 22:02:50 +0400 Subject: [PATCH 05/75] compare version --- update.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/update.sh b/update.sh index c64bab85..62eda22d 100644 --- a/update.sh +++ b/update.sh @@ -42,3 +42,14 @@ version_hash=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.$ exit 1 } +if [[ $self_version_count -gt $version_count ]]; then + echo "nothing to do. self_version_count: $self_version_count, version_count: $version_count" + exit 2 +fi + +if [[ $self_version_count -eq $version_count ]] && [[ $self_version_hash == $version_hash ]]; then + echo "version is up to date" + exit 0 +fi + +echo "found new version: $self_version_count.$self_version_hash -> $version_count.$version_hash" From 0f0c8df8c2157351a426817c414f37aa0e566ac3 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 23 Feb 2024 23:09:16 +0400 Subject: [PATCH 06/75] own_files.txt: Finishing update process. Stage 2 --- _AutoinstallCreator/release.sh | 10 ++++++--- update.bat | 2 +- update.sh | 39 +++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/_AutoinstallCreator/release.sh b/_AutoinstallCreator/release.sh index c1837ae0..76ecdafb 100755 --- a/_AutoinstallCreator/release.sh +++ b/_AutoinstallCreator/release.sh @@ -9,10 +9,14 @@ self_count="$(cd "$dp0/.." && git rev-list --count HEAD)" self_hash="$(cd "$dp0/.." && git show --abbrev=10 --no-patch --pretty=%h HEAD)" self_version=$self_name.$self_count.$self_hash -self_version_filepath=$dp0/version.txt +version_filepath=$dp0/version.txt +own_files_filepath=$dp0/own_files.txt { printf "$self_version" -} > "$self_version_filepath" +} > "$version_filepath" + +{ git log --pretty=format: --name-only --diff-filter=A +} > "$own_files_filepath" tool_version=release-2.4.5-cmd download_url="https://github.com/hemnstill/makeself/archive/refs/tags/$tool_version.tar.gz" @@ -32,7 +36,7 @@ rm -rf "$temp_dir_path" && mkdir -p "$temp_dir_path" release_version_dirpath="$temp_dir_path/$self_version" tmp_version_path="$temp_dir_path/tmp_version.zip" -(cd "$dp0/.." && git archive --prefix "_$self_name/" --add-file="$self_version_filepath" --prefix "" --format zip -1 --output "$tmp_version_path" HEAD) +(cd "$dp0/.." && git archive --prefix "_$self_name/" --add-file="$version_filepath" --add-file="$own_files_filepath" --prefix "" --format zip -1 --output "$tmp_version_path" HEAD) "$p7z" x "$tmp_version_path" "-o$release_version_dirpath" diff --git a/update.bat b/update.bat index e98d57ca..cce9992b 100644 --- a/update.bat +++ b/update.bat @@ -1,4 +1,4 @@ @echo off -"%~dp0.tools\busybox.exe" bash "%~dp0update.sh" +"%~dp0.tools\busybox.exe" bash "%~dp0update.sh" %* exit /b %errorlevel% diff --git a/update.sh b/update.sh index 62eda22d..390233e2 100644 --- a/update.sh +++ b/update.sh @@ -5,7 +5,36 @@ set -e cd "$dp0" self_name=AutoinstallCreator +# relative_version_filepath="_$self_name/version.txt" +relative_own_files_filepath="_$self_name/own_files.txt" +# Finishing update process. Stage 2 +update_path=$1 +if [[ ! -z "$update_path" ]]; then + update_path=$(realpath "$1") + echo "update_path: $update_path" + + if [[ $update_path == $dp0 ]]; then + echo "update failed. Cannot update to current directory" + exit 1 + fi + + if [[ ! -f "$update_path/$relative_own_files_filepath" ]]; then + echo "update failed. File not found: '$update_path/$relative_own_files_filepath'" + exit 1 + fi + + if [[ ! -f "$update_path/update.sh" ]]; then + echo "update failed. file not found: '$update_path/update.sh'" + exit 1 + fi + + echo Finishing update process + + exit 0 +fi + +# Starting update process. Stage 1 self_version_body=$(head -n 1 "$dp0/_$self_name/version.txt") echo "self_version_body: $self_version_body" [[ -z "$self_version_body" ]] && { @@ -52,4 +81,12 @@ if [[ $self_version_count -eq $version_count ]] && [[ $self_version_hash == $ver exit 0 fi -echo "found new version: $self_version_count.$self_version_hash -> $version_count.$version_hash" +echo "found new version: $self_version_count.$self_version_hash -> $version_count.$version_hash" +download_url=$($curl --silent --location "$latest_version" | "$grep" --only-matching '(?<="browser_download_url":\s")[^,]+.\.sh(?=")' | head -1) +[[ -z "$download_url" ]] && { + echo "Cannot get release version" + exit 1 +} + +echo "Downloading: $download_url ..." +(cd "$dp0/_$self_name" && $curl --location "$download_url" --remote-name) From d3cf01642072401bb437fa98b8ff20a748a646da Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 23 Feb 2024 23:42:02 +0400 Subject: [PATCH 07/75] extract new version and run update.sh --- update.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/update.sh b/update.sh index 390233e2..b2808e52 100644 --- a/update.sh +++ b/update.sh @@ -5,13 +5,14 @@ set -e cd "$dp0" self_name=AutoinstallCreator -# relative_version_filepath="_$self_name/version.txt" relative_own_files_filepath="_$self_name/own_files.txt" # Finishing update process. Stage 2 -update_path=$1 -if [[ ! -z "$update_path" ]]; then - update_path=$(realpath "$1") +self_package_filepath=$1 +update_path=$2 +if [[ ! -z "$self_package_filepath" ]] || [[ ! -z "$update_path" ]]; then + self_package_filepath=$(realpath "$self_package_filepath") + update_path=$(realpath "$update_path") echo "update_path: $update_path" if [[ $update_path == $dp0 ]]; then @@ -19,17 +20,17 @@ if [[ ! -z "$update_path" ]]; then exit 1 fi - if [[ ! -f "$update_path/$relative_own_files_filepath" ]]; then - echo "update failed. File not found: '$update_path/$relative_own_files_filepath'" + if [[ ! -f "$self_package_filepath" ]]; then + echo "update failed. Self package not found: '$update_path/$self_package_filepath'" exit 1 fi - if [[ ! -f "$update_path/update.sh" ]]; then - echo "update failed. file not found: '$update_path/update.sh'" + if [[ ! -f "$update_path/$relative_own_files_filepath" ]]; then + echo "update failed. File not found: '$update_path/$relative_own_files_filepath'" exit 1 fi - echo Finishing update process + echo "Finishing update process" exit 0 fi @@ -89,4 +90,9 @@ download_url=$($curl --silent --location "$latest_version" | "$grep" --only-matc } echo "Downloading: $download_url ..." -(cd "$dp0/_$self_name" && $curl --location "$download_url" --remote-name) +$curl --location "$download_url" --output "$dp0/_$self_name/$self_name.sh" + +echo "extracting to: $dp0/_$self_name/$version_body" +(cd "$dp0/_$self_name" && bash "./$self_name.sh") + +bash "$dp0/_$self_name/$version_body/update.sh" "$dp0/_$self_name/$self_name.sh" "$dp0" From 135172fb363aac5c92e99120de312f5147213f97 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 23 Feb 2024 23:45:09 +0400 Subject: [PATCH 08/75] update.sh + tests --- _AutoinstallCreator/io_tools.py | 156 +++++++++++++++++++++++++++++ _AutoinstallCreator/release.sh | 11 +- _AutoinstallCreator/test_update.py | 81 +++++++++++++++ update.bat | 4 +- update.sh | 73 +++++++++----- 5 files changed, 292 insertions(+), 33 deletions(-) create mode 100644 _AutoinstallCreator/io_tools.py create mode 100644 _AutoinstallCreator/test_update.py diff --git a/_AutoinstallCreator/io_tools.py b/_AutoinstallCreator/io_tools.py new file mode 100644 index 00000000..8e880b0c --- /dev/null +++ b/_AutoinstallCreator/io_tools.py @@ -0,0 +1,156 @@ +import os +import pathlib +import shutil +import time +import zipfile +import importlib +from types import ModuleType + +from typing import Type, Callable, Union +from os import path as os_path + + +def _create_or_clean_dir(dir_path: str) -> bool: + _dir_path = pathlib.Path(dir_path) + if _dir_path.is_file(): + _dir_path.unlink() + + if not _dir_path.exists(): + _dir_path.mkdir(parents=True, exist_ok=True) + return True + + return _clean_dir(dir_path) + + +def _clean_dir(dir_path: str) -> bool: + _dir_path = pathlib.Path(dir_path) + for path in _dir_path.iterdir(): + if path.is_file(): + path.unlink() + elif path.is_dir(): + shutil.rmtree(path) + return not any(_dir_path.iterdir()) + + +def wait_for(action: Callable[[], bool], err_message: Union[str, Callable[..., str]], timeout: float, retry_timeout: float, exception: Type[Exception]) -> bool: + start = time.monotonic() + last_exception_message: str = '' + while True: + try: + result = action() + if result: + return result + except exception as e: + last_exception_message = f'{e}' + finally: + elapsed_time = time.monotonic() - start + if elapsed_time > timeout: + if callable(err_message): + err_message = err_message() + print(f"{err_message}, timeout: {elapsed_time:.2f}s\n{last_exception_message}") + return False # pylint: disable=W0150 # NOSONAR + + time.sleep(retry_timeout) + + +def _get_clean_dir_error_message(dir_path: str) -> str: + dir_path_is_empty = not any(pathlib.Path(dir_path).iterdir()) + if dir_path_is_empty: + return f"Directory '{dir_path}' was cleaned, but timeout expired" + + return f"Cannot clean directory: '{dir_path}'" + + +def try_create_or_clean_dir(dir_path: str, timeout_in_seconds: float = 5, retry_timeout_in_seconds: float = 0.25) -> bool: + wait_for(lambda: _create_or_clean_dir(dir_path), + err_message=lambda: _get_clean_dir_error_message(dir_path), + timeout=timeout_in_seconds, + retry_timeout=retry_timeout_in_seconds, + exception=OSError) + dir_path_is_empty = not any(pathlib.Path(dir_path).iterdir()) + return dir_path_is_empty + + +def try_remove_dir(dir_path: str, retry_count: int = 1) -> bool: + if not os_path.exists(dir_path): + return True + + retries = range(retry_count) + for _ in retries: + try: + if _clean_dir(dir_path): + shutil.rmtree(dir_path) + return True + except OSError: + pass + return False + + +def extract_archive(archive_file_name: str, target_path: str) -> None: + with zipfile.ZipFile(archive_file_name, 'r') as zip_file: + zip_file.extractall(target_path) + + +def read_text(file_path: Union[str, pathlib.Path], encoding: str = 'utf-8') -> str: + return pathlib.Path(file_path).read_text(encoding=encoding) + + +def write_text(file_path: Union[str, pathlib.Path], data: str, encoding: str = 'utf-8') -> int: + return pathlib.Path(file_path).write_text(data=data, encoding=encoding) + + +def import_package_modules(package_file_path: str, package_name: str) -> list[ModuleType]: + extension = '.py' + imported_modules = [] + for p in sorted(pathlib.Path(os.path.dirname(package_file_path)).iterdir()): + if p.name.endswith(extension) and p.is_file(): + module = p.name[:-len(extension)] + if module != '__init__': + imported_modules.append(importlib.import_module(f".{module}", package_name)) + return imported_modules + + +def byte_to_humanreadable_format(num: Union[int, float], metric: bool = False, precision: int = 1) -> str: + """ + Human-readable formatting of bytes, using binary (powers of 1024) + or metric (powers of 1000) representation. + """ + metric_labels: list[str] = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] + binary_labels: list[str] = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] + precision_offsets: list[float] = [0.5, 0.05, 0.005, 0.0005] # PREDEFINED FOR SPEED. + precision_formats: list[str] = ["{}{:.0f} {}", "{}{:.1f} {}", "{}{:.2f} {}", "{}{:.3f} {}"] # PREDEFINED FOR SPEED. + + assert isinstance(num, (int, float)), "num must be an int or float" + assert isinstance(metric, bool), "metric must be a bool" + assert isinstance(precision, int) and 0 <= precision <= 3, "precision must be an int (range 0-3)" + + unit_labels = metric_labels if metric else binary_labels + last_label = unit_labels[-1] + unit_step = 1000 if metric else 1024 + unit_step_thresh = unit_step - precision_offsets[precision] + + is_negative = num < 0 + if is_negative: # Faster than ternary assignment or always running abs(). + num = abs(num) + + for unit in unit_labels: + if num < unit_step_thresh: + # VERY IMPORTANT: + # Only accepts the CURRENT unit if we're BELOW the threshold where + # float rounding behavior would place us into the NEXT unit: F.ex. + # when rounding a float to 1 decimal, any number ">= 1023.95" will + # be rounded to "1024.0". Obviously we don't want ugly output such + # as "1024.0 KiB", since the proper term for that is "1.0 MiB". + break + if unit != last_label: + # We only shrink the number if we HAVEN'T reached the last unit. + # NOTE: These looped divisions accumulate floating point rounding + # errors, but each new division pushes the rounding errors further + # and further down in the decimals, so it doesn't matter at all. + num /= unit_step + + return precision_formats[precision].format("-" if is_negative else "", num, unit) + + +def get_name_without_extensions(file_path: str) -> str: + return pathlib.Path(pathlib.Path(file_path).stem).stem diff --git a/_AutoinstallCreator/release.sh b/_AutoinstallCreator/release.sh index 76ecdafb..e7605f83 100755 --- a/_AutoinstallCreator/release.sh +++ b/_AutoinstallCreator/release.sh @@ -10,13 +10,14 @@ self_hash="$(cd "$dp0/.." && git show --abbrev=10 --no-patch --pretty=%h HEAD)" self_version=$self_name.$self_count.$self_hash version_filepath=$dp0/version.txt -own_files_filepath=$dp0/own_files.txt +orphaned_files_filepath=$dp0/orphaned_files.txt { printf "$self_version" } > "$version_filepath" -{ git log --pretty=format: --name-only --diff-filter=A -} > "$own_files_filepath" +{ comm -23 <(git log --pretty=format: --name-only --diff-filter=A | sort) \ + <(cd "$dp0/.." && git ls-tree -r HEAD --name-only | sort) | uniq -u +} > "$orphaned_files_filepath" tool_version=release-2.4.5-cmd download_url="https://github.com/hemnstill/makeself/archive/refs/tags/$tool_version.tar.gz" @@ -36,7 +37,7 @@ rm -rf "$temp_dir_path" && mkdir -p "$temp_dir_path" release_version_dirpath="$temp_dir_path/$self_version" tmp_version_path="$temp_dir_path/tmp_version.zip" -(cd "$dp0/.." && git archive --prefix "_$self_name/" --add-file="$version_filepath" --add-file="$own_files_filepath" --prefix "" --format zip -1 --output "$tmp_version_path" HEAD) +(cd "$dp0/.." && git archive --prefix "_$self_name/" --add-file="$version_filepath" --add-file="$orphaned_files_filepath" --prefix "" --format zip -1 --output "$tmp_version_path" HEAD) "$p7z" x "$tmp_version_path" "-o$release_version_dirpath" @@ -56,7 +57,7 @@ header_arg="" && $is_windows_os && { "$self_name" \ echo "$self_version has extracted itself" -echo version "'$self_version'" created. +echo version created: "$self_version" echo "$self_version" > "$dp0/../body.md" echo "::set-output name=artifact_path::$artifact_file_path" diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py new file mode 100644 index 00000000..54b3c1b3 --- /dev/null +++ b/_AutoinstallCreator/test_update.py @@ -0,0 +1,81 @@ +import os +import pathlib +import shutil +import subprocess +import unittest + +from _AutoinstallCreator import io_tools + +_self_path: str = os.path.dirname(os.path.realpath(__file__)) +_self_tmp_path: str = os.path.join(_self_path, '.tmp') +_root_path: str = os.path.dirname(_self_path) +_tools_path: str = os.path.join(_root_path, '.tools') +busybox_exe_path: str = os.path.join(_tools_path, 'busybox.exe') + + +def get_version_from_stdout(b_stdout: bytes) -> str: + for b_line in b_stdout.splitlines(): + if b_line.startswith(b'version created:'): + version_line = b_line.decode().strip() + prefix, _, raw_version = version_line.partition(':') + return raw_version.strip() + + +def update_completed(update_log_path: str, version_str: str) -> bool: + update_log = io_tools.read_text(update_log_path) + return update_log.endswith(f'\nUpdate complete: {version_str}\n') + + +class TestUpdate(unittest.TestCase): + + @classmethod + def setUpClass(cls) -> None: + pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) + pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) + + result = subprocess.run([busybox_exe_path, 'bash', os.path.join(_self_path, 'release.sh')], + check=True, stdout=subprocess.PIPE) + cls.version_str = get_version_from_stdout(result.stdout) + + def setUp(self): + self.test_old_version = 'AutoinstallCreator.11.test_old_version' + self.assertTrue(self.version_str.startswith('AutoinstallCreator.')) + self.assertTrue(io_tools.try_create_or_clean_dir(_self_tmp_path)) + self.package_filepath = os.path.join(_self_tmp_path, 'AutoinstallCreator.sh.bat') + shutil.copyfile(os.path.join(_self_path, 'AutoinstallCreator.sh.bat'), self.package_filepath) + + def test_version_up_to_date(self): + subprocess.run([busybox_exe_path, 'bash', self.package_filepath], cwd=_self_tmp_path) + + result = subprocess.run([busybox_exe_path, 'bash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')], + env={ + **os.environ, + 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, + 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath + }, + check=True, stdout=subprocess.PIPE) + self.assertTrue(result.stdout.endswith(b'\nVersion is up to date\n')) + + def test_update_to_new_version(self): + subprocess.run([busybox_exe_path, 'bash', self.package_filepath, '--target', self.test_old_version], + cwd=_self_tmp_path) + + io_tools.write_text(os.path.join(_self_tmp_path, self.test_old_version, '_AutoinstallCreator', 'version.txt'), + self.test_old_version) + + result = subprocess.run([os.path.join(_self_tmp_path, self.test_old_version, 'update.bat')], + env={ + **os.environ, + 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, + 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath + }, + check=True, stdout=subprocess.PIPE) + + self.assertIn(f'\nFound new version: {self.test_old_version} -> {self.version_str}\n'.encode(), result.stdout) + + update_log_filepath = os.path.join(_self_tmp_path, self.test_old_version, '_update.log') + self.assertTrue(io_tools.wait_for(lambda: update_completed(update_log_filepath, self.version_str), + err_message='Update failed', + timeout=10, + retry_timeout=0.5, + exception=OSError)) diff --git a/update.bat b/update.bat index cce9992b..0a5f6bc5 100644 --- a/update.bat +++ b/update.bat @@ -1,4 +1,6 @@ @echo off -"%~dp0.tools\busybox.exe" bash "%~dp0update.sh" %* +echo f | xcopy /Y /Q /R "%~dp0update.sh" "%~dp0update_old.tmp" +echo f | xcopy /Y /Q /R "%~dp0.tools\busybox.exe" "%~dp0.tools\busybox_old.exe" +"%~dp0.tools\busybox_old.exe" bash "%~dp0update_old.tmp" %* exit /b %errorlevel% diff --git a/update.sh b/update.sh index b2808e52..fa5aefc8 100644 --- a/update.sh +++ b/update.sh @@ -5,33 +5,41 @@ set -e cd "$dp0" self_name=AutoinstallCreator -relative_own_files_filepath="_$self_name/own_files.txt" +relative_version_filepath="_$self_name/version.txt" +package_ext=".sh" && $is_windows_os && package_ext=".sh.bat" +package_grep_ext="\.sh" && $is_windows_os && package_grep_ext="\.sh\.bat" # Finishing update process. Stage 2 -self_package_filepath=$1 -update_path=$2 -if [[ ! -z "$self_package_filepath" ]] || [[ ! -z "$update_path" ]]; then - self_package_filepath=$(realpath "$self_package_filepath") - update_path=$(realpath "$update_path") - echo "update_path: $update_path" - - if [[ $update_path == $dp0 ]]; then - echo "update failed. Cannot update to current directory" - exit 1 - fi +#self_package_filepath=$1 +target_path=$1 +if [[ ! -z "$target_path" ]]; then + target_path=$(realpath "$target_path") - if [[ ! -f "$self_package_filepath" ]]; then - echo "update failed. Self package not found: '$update_path/$self_package_filepath'" + echo "Finishing update from: $dp0" + echo "Target path: $target_path" + + if [[ $target_path == $dp0 ]]; then + echo "Update failed. Cannot update to current directory" exit 1 fi - if [[ ! -f "$update_path/$relative_own_files_filepath" ]]; then - echo "update failed. File not found: '$update_path/$relative_own_files_filepath'" + if [[ ! -f "$target_path/$relative_version_filepath" ]]; then + echo "Update failed. Version not found: '$target_path/$relative_version_filepath'" exit 1 fi - echo "Finishing update process" + echo "Copying new files" + find "$dp0" -mindepth 1 -maxdepth 1 ! -name "tmp_*" \ + -exec cp -rf "{}" "$target_path/" + + + echo "Removing orphaned files" + orphaned_files=$(cat $dp0/_$self_name/orphaned_files.txt) + for orphaned_file in $orphaned_files + do + rm -f "$dp0/$orphaned_file" + done + echo "Update complete: $(cat $target_path/_$self_name/version.txt)" exit 0 fi @@ -55,8 +63,11 @@ self_version_hash=$(echo "$self_version_body" | "$grep" --only-matching "(?<=$se latest_version=https://api.github.com/repos/hemnstill/$self_name/releases/tags/latest-master echo Get latest version: "$latest_version" ... -version_body=$($curl --silent --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.(?=\\n")' | head -n 1) -echo "version_body: $version_body" +version_body="$MOCK_AUTOINSTALLCREATOR_VERSION_BODY" +if [[ -z $version_body ]]; then + version_body=$($curl --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.(?=\\n")' | head -n 1) +fi +echo "Version_body: $version_body" [[ -z "$version_body" ]] && { echo "Cannot get 'version_body'" exit 1 @@ -73,26 +84,34 @@ version_hash=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.$ } if [[ $self_version_count -gt $version_count ]]; then - echo "nothing to do. self_version_count: $self_version_count, version_count: $version_count" + echo "Nothing to do. self_version_count: $self_version_count, version_count: $version_count" exit 2 fi if [[ $self_version_count -eq $version_count ]] && [[ $self_version_hash == $version_hash ]]; then - echo "version is up to date" + echo "Version is up to date" exit 0 fi -echo "found new version: $self_version_count.$self_version_hash -> $version_count.$version_hash" -download_url=$($curl --silent --location "$latest_version" | "$grep" --only-matching '(?<="browser_download_url":\s")[^,]+.\.sh(?=")' | head -1) +echo "Found new version: $self_version_body -> $version_body" +grep_pattern="(?<=\"browser_download_url\":\s\")[^,]+.$package_grep_ext(?=\")" +download_url=$($curl --silent --location "$latest_version" | "$grep" --only-matching $grep_pattern | head -n 1) [[ -z "$download_url" ]] && { echo "Cannot get release version" exit 1 } echo "Downloading: $download_url ..." -$curl --location "$download_url" --output "$dp0/_$self_name/$self_name.sh" +package_filepath="$MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH" +if [[ -z $MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH ]]; then + package_filepath="$dp0/_$self_name/$self_name$package_ext" + $curl --location "$download_url" --output "$package_filepath" +fi + +echo "Extracting to: $dp0/_$self_name/$version_body" +(bash "$package_filepath" --target "$dp0/_$self_name/tmp_$version_body") + +echo "Running extracted 'update.sh'" +bash "$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >& $dp0/_update.log -echo "extracting to: $dp0/_$self_name/$version_body" -(cd "$dp0/_$self_name" && bash "./$self_name.sh") -bash "$dp0/_$self_name/$version_body/update.sh" "$dp0/_$self_name/$self_name.sh" "$dp0" From 6525d721488f1d7836e899df4feb33984e7b24aa Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Mon, 26 Feb 2024 22:04:33 +0400 Subject: [PATCH 09/75] cut -d --- update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index fa5aefc8..3f725f2c 100644 --- a/update.sh +++ b/update.sh @@ -61,11 +61,11 @@ self_version_hash=$(echo "$self_version_body" | "$grep" --only-matching "(?<=$se exit 1 } -latest_version=https://api.github.com/repos/hemnstill/$self_name/releases/tags/latest-master +latest_version=https://api.github.com/repos/hemnstill/$self_name/releases/tags/self_update_v1 echo Get latest version: "$latest_version" ... version_body="$MOCK_AUTOINSTALLCREATOR_VERSION_BODY" if [[ -z $version_body ]]; then - version_body=$($curl --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.(?=\\n")' | head -n 1) + version_body=$($curl --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.' | cut -d '\r\n' -f 1 | head -n 1) fi echo "Version_body: $version_body" [[ -z "$version_body" ]] && { From c8f8e051d79077e053ea34f026d9f687f82746c1 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Mon, 26 Feb 2024 22:11:13 +0400 Subject: [PATCH 10/75] MOCK_AUTOINSTALLCREATOR_GITHUB_TAG --- _AutoinstallCreator/.gitignore | 1 + update.sh | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/_AutoinstallCreator/.gitignore b/_AutoinstallCreator/.gitignore index d271483a..3998e29b 100644 --- a/_AutoinstallCreator/.gitignore +++ b/_AutoinstallCreator/.gitignore @@ -1,3 +1,4 @@ release_version/ makeself-*/ *.bat +tmp_* diff --git a/update.sh b/update.sh index 3f725f2c..d5864ec8 100644 --- a/update.sh +++ b/update.sh @@ -61,7 +61,12 @@ self_version_hash=$(echo "$self_version_body" | "$grep" --only-matching "(?<=$se exit 1 } -latest_version=https://api.github.com/repos/hemnstill/$self_name/releases/tags/self_update_v1 +github_tag=$MOCK_AUTOINSTALLCREATOR_GITHUB_TAG +if [[ -z $MOCK_AUTOINSTALLCREATOR_GITHUB_TAG ]]; then + github_tag=latest-master +fi + +latest_version="https://api.github.com/repos/hemnstill/$self_name/releases/tags/$github_tag" echo Get latest version: "$latest_version" ... version_body="$MOCK_AUTOINSTALLCREATOR_VERSION_BODY" if [[ -z $version_body ]]; then From c4b844081cbc948648dff1d7e569786ad8055e49 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Mon, 26 Feb 2024 22:19:00 +0400 Subject: [PATCH 11/75] tests --- .tests/test_tools_linux.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tests/test_tools_linux.sh b/.tests/test_tools_linux.sh index 94079868..3d8bea3a 100755 --- a/.tests/test_tools_linux.sh +++ b/.tests/test_tools_linux.sh @@ -18,11 +18,11 @@ test7zVersion() { if [[ "$is_alpine_os" == true ]]; then assertEquals " 7-Zip (z) 21.07 (x64) : Copyright (c) 1999-2021 Igor Pavlov : 2021-12-26 - 64-bit locale=C UTF8=- Threads:2, ASM" "$actual_version" # editorconfig-checker-disable-line + 64-bit locale=C UTF8=- Threads:4, ASM" "$actual_version" # editorconfig-checker-disable-line else assertEquals " 7-Zip (z) 21.07 (x64) : Copyright (c) 1999-2021 Igor Pavlov : 2021-12-26 - 64-bit locale=C.UTF-8 Threads:2, ASM" "$actual_version" # editorconfig-checker-disable-line + 64-bit locale=C.UTF-8 Threads:4, ASM" "$actual_version" # editorconfig-checker-disable-line fi } From 4017016df6c932be58d34bacaf69f79cc7a519b1 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Mon, 26 Feb 2024 22:26:46 +0400 Subject: [PATCH 12/75] --silent get version body --- update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.sh b/update.sh index d5864ec8..7a294ee3 100644 --- a/update.sh +++ b/update.sh @@ -70,7 +70,7 @@ latest_version="https://api.github.com/repos/hemnstill/$self_name/releases/tags/ echo Get latest version: "$latest_version" ... version_body="$MOCK_AUTOINSTALLCREATOR_VERSION_BODY" if [[ -z $version_body ]]; then - version_body=$($curl --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.' | cut -d '\r\n' -f 1 | head -n 1) + version_body=$($curl --silent --location "$latest_version" | "$grep" --only-matching '(?<="body":\s")[^,]+.' | cut -d '\r\n' -f 1 | head -n 1) fi echo "Version_body: $version_body" [[ -z "$version_body" ]] && { From 32e3ffd16e6216c025dd332d23b27524efcdb473 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Mon, 26 Feb 2024 22:35:55 +0400 Subject: [PATCH 13/75] allow downgrade --- update.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/update.sh b/update.sh index 7a294ee3..185e70d1 100644 --- a/update.sh +++ b/update.sh @@ -88,17 +88,20 @@ version_hash=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.$ exit 1 } -if [[ $self_version_count -gt $version_count ]]; then - echo "Nothing to do. self_version_count: $self_version_count, version_count: $version_count" - exit 2 -fi - if [[ $self_version_count -eq $version_count ]] && [[ $self_version_hash == $version_hash ]]; then echo "Version is up to date" exit 0 fi -echo "Found new version: $self_version_body -> $version_body" + +found_msg_prefix="Found new version" +if [[ $self_version_count -gt $version_count ]]; then + found_msg_prefix="Downgrade version" + echo "Warning. Downgrade to old version!" + sleep 10 +fi + +echo "$found_msg_prefix: $self_version_body -> $version_body" grep_pattern="(?<=\"browser_download_url\":\s\")[^,]+.$package_grep_ext(?=\")" download_url=$($curl --silent --location "$latest_version" | "$grep" --only-matching $grep_pattern | head -n 1) [[ -z "$download_url" ]] && { From 98b9720a4372f1adbd518d60968ebc2a781da562 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Mon, 26 Feb 2024 23:58:38 +0400 Subject: [PATCH 14/75] python -m unittests --- .tests/ci-test-run.sh | 2 ++ _AutoinstallCreator/test_update.py | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.tests/ci-test-run.sh b/.tests/ci-test-run.sh index facd3b7e..a012c48c 100755 --- a/.tests/ci-test-run.sh +++ b/.tests/ci-test-run.sh @@ -8,4 +8,6 @@ set -e "$dp0/test-tools.sh" || exit 1 +python -m unittests || exit 1 + "$dp0/test-run.sh" -- testInternalCreate || exit 1 diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 54b3c1b3..4ac2b1db 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -2,16 +2,22 @@ import pathlib import shutil import subprocess +import sys import unittest -from _AutoinstallCreator import io_tools _self_path: str = os.path.dirname(os.path.realpath(__file__)) + _self_tmp_path: str = os.path.join(_self_path, '.tmp') _root_path: str = os.path.dirname(_self_path) _tools_path: str = os.path.join(_root_path, '.tools') busybox_exe_path: str = os.path.join(_tools_path, 'busybox.exe') +if _root_path not in sys.path: + sys.path.append(_root_path) + +from _AutoinstallCreator import io_tools + def get_version_from_stdout(b_stdout: bytes) -> str: for b_line in b_stdout.splitlines(): From 4a8047c34319cb1774573f327e19725e075bf898 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:13:10 +0400 Subject: [PATCH 15/75] python3 --- .github/workflows/ci-test-run.yml | 2 +- .tests/ci-test-run.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index da01dc79..75ddc36c 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -31,7 +31,7 @@ jobs: if: matrix.artifact == 'ubuntu' run: | apt update - apt install -y busybox dos2unix + apt install -y busybox dos2unix python3 - name: Install Alpine packages if: matrix.artifact == 'alpine' diff --git a/.tests/ci-test-run.sh b/.tests/ci-test-run.sh index a012c48c..27451db9 100755 --- a/.tests/ci-test-run.sh +++ b/.tests/ci-test-run.sh @@ -8,6 +8,6 @@ set -e "$dp0/test-tools.sh" || exit 1 -python -m unittests || exit 1 +python3 -m unittests || exit 1 "$dp0/test-run.sh" -- testInternalCreate || exit 1 From 7f50f88d5de0ca592c5f64f90a3148cf99b65bda Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:14:22 +0400 Subject: [PATCH 16/75] python3 --- .github/workflows/ci-test-run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 75ddc36c..0d900236 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -36,7 +36,7 @@ jobs: - name: Install Alpine packages if: matrix.artifact == 'alpine' run: | - apk add --no-cache bash + apk add --no-cache bash python3 - uses: actions/checkout@v3 From 94ea72eec20ad3fce541357fbecae6c9a24c9be9 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:18:53 +0400 Subject: [PATCH 17/75] python3-dev --- .github/workflows/ci-test-run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 0d900236..c5bf96fc 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -36,7 +36,7 @@ jobs: - name: Install Alpine packages if: matrix.artifact == 'alpine' run: | - apk add --no-cache bash python3 + apk add --no-cache bash python3-dev - uses: actions/checkout@v3 From 3cf0964600439761fe4e2808dcce4f9e8337efed Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:20:46 +0400 Subject: [PATCH 18/75] ~ --- .github/workflows/ci-test-run.yml | 2 +- .tests/ci-test-run.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index c5bf96fc..0d900236 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -36,7 +36,7 @@ jobs: - name: Install Alpine packages if: matrix.artifact == 'alpine' run: | - apk add --no-cache bash python3-dev + apk add --no-cache bash python3 - uses: actions/checkout@v3 diff --git a/.tests/ci-test-run.sh b/.tests/ci-test-run.sh index 27451db9..4fe4c0b2 100755 --- a/.tests/ci-test-run.sh +++ b/.tests/ci-test-run.sh @@ -8,6 +8,6 @@ set -e "$dp0/test-tools.sh" || exit 1 -python3 -m unittests || exit 1 +python3 -m unittest || exit 1 "$dp0/test-run.sh" -- testInternalCreate || exit 1 From b7a2b6d932f4205561fdea2c2e2c28fe2e9b9c24 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:28:30 +0400 Subject: [PATCH 19/75] cd --- .tests/ci-test-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tests/ci-test-run.sh b/.tests/ci-test-run.sh index 4fe4c0b2..941825b7 100755 --- a/.tests/ci-test-run.sh +++ b/.tests/ci-test-run.sh @@ -8,6 +8,6 @@ set -e "$dp0/test-tools.sh" || exit 1 -python3 -m unittest || exit 1 +cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1 "$dp0/test-run.sh" -- testInternalCreate || exit 1 From cf1e485bbb8cd61a92d5b706f1879f3ec80054ef Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:32:17 +0400 Subject: [PATCH 20/75] busybox_exe_path --- _AutoinstallCreator/test_update.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 4ac2b1db..469e49c4 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -5,13 +5,15 @@ import sys import unittest - _self_path: str = os.path.dirname(os.path.realpath(__file__)) _self_tmp_path: str = os.path.join(_self_path, '.tmp') _root_path: str = os.path.dirname(_self_path) _tools_path: str = os.path.join(_root_path, '.tools') -busybox_exe_path: str = os.path.join(_tools_path, 'busybox.exe') + +busybox_exe_path = 'busybox' +if sys.platform.startswith('win'): + busybox_exe_path: str = os.path.join(_tools_path, 'busybox.exe') if _root_path not in sys.path: sys.path.append(_root_path) @@ -81,7 +83,7 @@ def test_update_to_new_version(self): update_log_filepath = os.path.join(_self_tmp_path, self.test_old_version, '_update.log') self.assertTrue(io_tools.wait_for(lambda: update_completed(update_log_filepath, self.version_str), - err_message='Update failed', - timeout=10, - retry_timeout=0.5, - exception=OSError)) + err_message='Update failed', + timeout=10, + retry_timeout=0.5, + exception=OSError)) From aafbb2b55afbf30857490cbd4f9d270aedd5561b Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:33:49 +0400 Subject: [PATCH 21/75] ash --- _AutoinstallCreator/test_update.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 469e49c4..4aaa5ef7 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -11,9 +11,11 @@ _root_path: str = os.path.dirname(_self_path) _tools_path: str = os.path.join(_root_path, '.tools') -busybox_exe_path = 'busybox' +busybox_exe_path: str = 'busybox' +update_script_name: str = 'update.sh' if sys.platform.startswith('win'): - busybox_exe_path: str = os.path.join(_tools_path, 'busybox.exe') + busybox_exe_path = os.path.join(_tools_path, 'busybox.exe') + update_script_name = 'update.bat' if _root_path not in sys.path: sys.path.append(_root_path) @@ -41,7 +43,7 @@ def setUpClass(cls) -> None: pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) - result = subprocess.run([busybox_exe_path, 'bash', os.path.join(_self_path, 'release.sh')], + result = subprocess.run([busybox_exe_path, 'ash', os.path.join(_self_path, 'release.sh')], check=True, stdout=subprocess.PIPE) cls.version_str = get_version_from_stdout(result.stdout) @@ -53,9 +55,9 @@ def setUp(self): shutil.copyfile(os.path.join(_self_path, 'AutoinstallCreator.sh.bat'), self.package_filepath) def test_version_up_to_date(self): - subprocess.run([busybox_exe_path, 'bash', self.package_filepath], cwd=_self_tmp_path) + subprocess.run([busybox_exe_path, 'ash', self.package_filepath], cwd=_self_tmp_path) - result = subprocess.run([busybox_exe_path, 'bash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')], + result = subprocess.run([busybox_exe_path, 'ash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')], env={ **os.environ, 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, @@ -65,13 +67,13 @@ def test_version_up_to_date(self): self.assertTrue(result.stdout.endswith(b'\nVersion is up to date\n')) def test_update_to_new_version(self): - subprocess.run([busybox_exe_path, 'bash', self.package_filepath, '--target', self.test_old_version], + subprocess.run([busybox_exe_path, 'ash', self.package_filepath, '--target', self.test_old_version], cwd=_self_tmp_path) io_tools.write_text(os.path.join(_self_tmp_path, self.test_old_version, '_AutoinstallCreator', 'version.txt'), self.test_old_version) - result = subprocess.run([os.path.join(_self_tmp_path, self.test_old_version, 'update.bat')], + result = subprocess.run([os.path.join(_self_tmp_path, self.test_old_version, update_script_name)], env={ **os.environ, 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, From 8ebe198a9b93c77b1c66f80a12056393613873a2 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:40:27 +0400 Subject: [PATCH 22/75] git --- .github/workflows/ci-test-run.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 0d900236..b5f1aabc 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -31,12 +31,12 @@ jobs: if: matrix.artifact == 'ubuntu' run: | apt update - apt install -y busybox dos2unix python3 + apt install -y busybox dos2unix python3 git - name: Install Alpine packages if: matrix.artifact == 'alpine' run: | - apk add --no-cache bash python3 + apk add --no-cache bash python3 git - uses: actions/checkout@v3 From 8216342e8d436e1ff34808ade1831bef681a8c9e Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:42:08 +0400 Subject: [PATCH 23/75] git config --global --add safe.directory --- .github/workflows/ci-test-run.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index b5f1aabc..6d60bd55 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -32,11 +32,13 @@ jobs: run: | apt update apt install -y busybox dos2unix python3 git + git config --global --add safe.directory '*' - name: Install Alpine packages if: matrix.artifact == 'alpine' run: | apk add --no-cache bash python3 git + git config --global --add safe.directory '*' - uses: actions/checkout@v3 From 1766a8c9537e7e497a218bdf2f53dfa3ac3a8fb3 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:46:31 +0400 Subject: [PATCH 24/75] libarchive-tools --- .github/workflows/ci-test-run.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 6d60bd55..4bd1e3bb 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -31,13 +31,13 @@ jobs: if: matrix.artifact == 'ubuntu' run: | apt update - apt install -y busybox dos2unix python3 git + apt install -y busybox dos2unix libarchive-tools python3 git git config --global --add safe.directory '*' - name: Install Alpine packages if: matrix.artifact == 'alpine' run: | - apk add --no-cache bash python3 git + apk add --no-cache bash libarchive-tools python3 git git config --global --add safe.directory '*' - uses: actions/checkout@v3 From 20c7e963d91177e00301b967febe79d57037d76e Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:48:51 +0400 Subject: [PATCH 25/75] package_name --- _AutoinstallCreator/test_update.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 4aaa5ef7..293241fe 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -13,9 +13,11 @@ busybox_exe_path: str = 'busybox' update_script_name: str = 'update.sh' +package_name = 'AutoinstallCreator.sh' if sys.platform.startswith('win'): busybox_exe_path = os.path.join(_tools_path, 'busybox.exe') update_script_name = 'update.bat' + package_name = 'AutoinstallCreator.sh.bat' if _root_path not in sys.path: sys.path.append(_root_path) @@ -51,8 +53,8 @@ def setUp(self): self.test_old_version = 'AutoinstallCreator.11.test_old_version' self.assertTrue(self.version_str.startswith('AutoinstallCreator.')) self.assertTrue(io_tools.try_create_or_clean_dir(_self_tmp_path)) - self.package_filepath = os.path.join(_self_tmp_path, 'AutoinstallCreator.sh.bat') - shutil.copyfile(os.path.join(_self_path, 'AutoinstallCreator.sh.bat'), self.package_filepath) + self.package_filepath = os.path.join(_self_tmp_path, package_name) + shutil.copyfile(os.path.join(_self_path, package_name), self.package_filepath) def test_version_up_to_date(self): subprocess.run([busybox_exe_path, 'ash', self.package_filepath], cwd=_self_tmp_path) From ce3e5867b8cd3653b6000296a1f07b83c3ce5cd1 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:49:54 +0400 Subject: [PATCH 26/75] +x --- update.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 update.sh diff --git a/update.sh b/update.sh old mode 100644 new mode 100755 From ea3d653773575fa19ff25be47d09ef54202447b7 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:53:35 +0400 Subject: [PATCH 27/75] -bash --- update.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/update.sh b/update.sh index 185e70d1..0a8c23c7 100755 --- a/update.sh +++ b/update.sh @@ -10,7 +10,6 @@ package_ext=".sh" && $is_windows_os && package_ext=".sh.bat" package_grep_ext="\.sh" && $is_windows_os && package_grep_ext="\.sh\.bat" # Finishing update process. Stage 2 -#self_package_filepath=$1 target_path=$1 if [[ ! -z "$target_path" ]]; then target_path=$(realpath "$target_path") @@ -117,9 +116,9 @@ if [[ -z $MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH ]]; then fi echo "Extracting to: $dp0/_$self_name/$version_body" -(bash "$package_filepath" --target "$dp0/_$self_name/tmp_$version_body") +"$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" echo "Running extracted 'update.sh'" -bash "$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >& $dp0/_update.log +"$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >& $dp0/_update.log From e858bb6060da4ad9528258ef37bd043488bb377e Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:55:00 +0400 Subject: [PATCH 28/75] 18 --- _AutoinstallCreator/release.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/_AutoinstallCreator/release.sh b/_AutoinstallCreator/release.sh index e7605f83..ed9d70e2 100755 --- a/_AutoinstallCreator/release.sh +++ b/_AutoinstallCreator/release.sh @@ -15,8 +15,7 @@ orphaned_files_filepath=$dp0/orphaned_files.txt { printf "$self_version" } > "$version_filepath" -{ comm -23 <(git log --pretty=format: --name-only --diff-filter=A | sort) \ - <(cd "$dp0/.." && git ls-tree -r HEAD --name-only | sort) | uniq -u +{ comm -23 <(git log --pretty=format: --name-only --diff-filter=A | sort) <(cd "$dp0/.." && git ls-tree -r HEAD --name-only | sort) | uniq -u } > "$orphaned_files_filepath" tool_version=release-2.4.5-cmd From 9bfa912bea8d6989528ad594a53318767023986e Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 00:56:26 +0400 Subject: [PATCH 29/75] +x --- _AutoinstallCreator/release.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/_AutoinstallCreator/release.sh b/_AutoinstallCreator/release.sh index ed9d70e2..80e5be1e 100755 --- a/_AutoinstallCreator/release.sh +++ b/_AutoinstallCreator/release.sh @@ -56,6 +56,8 @@ header_arg="" && $is_windows_os && { "$self_name" \ echo "$self_version has extracted itself" +chmod +x "$artifact_file_path" + echo version created: "$self_version" echo "$self_version" > "$dp0/../body.md" From 729143f82f9bbddc9357ef7ac913dc32d783d866 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 01:02:53 +0400 Subject: [PATCH 30/75] ~bash --- _AutoinstallCreator/test_update.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 293241fe..0d085d5d 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -45,7 +45,7 @@ def setUpClass(cls) -> None: pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) - result = subprocess.run([busybox_exe_path, 'ash', os.path.join(_self_path, 'release.sh')], + result = subprocess.run(['bash', os.path.join(_self_path, 'release.sh')], check=True, stdout=subprocess.PIPE) cls.version_str = get_version_from_stdout(result.stdout) @@ -57,9 +57,9 @@ def setUp(self): shutil.copyfile(os.path.join(_self_path, package_name), self.package_filepath) def test_version_up_to_date(self): - subprocess.run([busybox_exe_path, 'ash', self.package_filepath], cwd=_self_tmp_path) + subprocess.run(['bash', self.package_filepath], cwd=_self_tmp_path) - result = subprocess.run([busybox_exe_path, 'ash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')], + result = subprocess.run(['bash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')], env={ **os.environ, 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, @@ -69,7 +69,7 @@ def test_version_up_to_date(self): self.assertTrue(result.stdout.endswith(b'\nVersion is up to date\n')) def test_update_to_new_version(self): - subprocess.run([busybox_exe_path, 'ash', self.package_filepath, '--target', self.test_old_version], + subprocess.run(['bash', self.package_filepath, '--target', self.test_old_version], cwd=_self_tmp_path) io_tools.write_text(os.path.join(_self_tmp_path, self.test_old_version, '_AutoinstallCreator', 'version.txt'), From ef9a335182716823c68f19bb991a386c341be9fe Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 01:12:14 +0400 Subject: [PATCH 31/75] if windows --- .tests/ci-test-run.sh | 4 +++- _AutoinstallCreator/test_update.py | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.tests/ci-test-run.sh b/.tests/ci-test-run.sh index 941825b7..ea13df35 100755 --- a/.tests/ci-test-run.sh +++ b/.tests/ci-test-run.sh @@ -8,6 +8,8 @@ set -e "$dp0/test-tools.sh" || exit 1 -cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1 +if [[ "$is_windows_os" == true ]]; then + cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1 +fi "$dp0/test-run.sh" -- testInternalCreate || exit 1 diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 0d085d5d..69b3f968 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -11,11 +11,11 @@ _root_path: str = os.path.dirname(_self_path) _tools_path: str = os.path.join(_root_path, '.tools') -busybox_exe_path: str = 'busybox' +busybox_exe_path_arg: list[str] = [] update_script_name: str = 'update.sh' package_name = 'AutoinstallCreator.sh' if sys.platform.startswith('win'): - busybox_exe_path = os.path.join(_tools_path, 'busybox.exe') + busybox_exe_path_arg = [os.path.join(_tools_path, 'busybox.exe')] update_script_name = 'update.bat' package_name = 'AutoinstallCreator.sh.bat' @@ -45,7 +45,7 @@ def setUpClass(cls) -> None: pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) - result = subprocess.run(['bash', os.path.join(_self_path, 'release.sh')], + result = subprocess.run(busybox_exe_path_arg + ['bash', os.path.join(_self_path, 'release.sh')], check=True, stdout=subprocess.PIPE) cls.version_str = get_version_from_stdout(result.stdout) @@ -57,9 +57,9 @@ def setUp(self): shutil.copyfile(os.path.join(_self_path, package_name), self.package_filepath) def test_version_up_to_date(self): - subprocess.run(['bash', self.package_filepath], cwd=_self_tmp_path) + subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath], cwd=_self_tmp_path) - result = subprocess.run(['bash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')], + result = subprocess.run(busybox_exe_path_arg + ['bash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')], env={ **os.environ, 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, @@ -69,7 +69,7 @@ def test_version_up_to_date(self): self.assertTrue(result.stdout.endswith(b'\nVersion is up to date\n')) def test_update_to_new_version(self): - subprocess.run(['bash', self.package_filepath, '--target', self.test_old_version], + subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath, '--target', self.test_old_version], cwd=_self_tmp_path) io_tools.write_text(os.path.join(_self_tmp_path, self.test_old_version, '_AutoinstallCreator', 'version.txt'), From dc00dac349daf98b690657bfd64de2252e39bfd0 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 01:18:33 +0400 Subject: [PATCH 32/75] fetch-depth: 0 --- .github/workflows/ci-test-run.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 4bd1e3bb..1a82b07f 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -41,6 +41,8 @@ jobs: git config --global --add safe.directory '*' - uses: actions/checkout@v3 + with: + fetch-depth: 0 # need for self_count - name: ci test-run (non windows) if: matrix.os != 'windows-latest' From cf9588a756a19fc68060022d3391fcce79772f6a Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 01:33:53 +0400 Subject: [PATCH 33/75] - +x --- _AutoinstallCreator/release.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/_AutoinstallCreator/release.sh b/_AutoinstallCreator/release.sh index 80e5be1e..ed9d70e2 100755 --- a/_AutoinstallCreator/release.sh +++ b/_AutoinstallCreator/release.sh @@ -56,8 +56,6 @@ header_arg="" && $is_windows_os && { "$self_name" \ echo "$self_version has extracted itself" -chmod +x "$artifact_file_path" - echo version created: "$self_version" echo "$self_version" > "$dp0/../body.md" From 905d70f91fb8bd6d847e8d27aced2caf70b2fced Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 01:35:02 +0400 Subject: [PATCH 34/75] ~ --- _AutoinstallCreator/release.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_AutoinstallCreator/release.sh b/_AutoinstallCreator/release.sh index ed9d70e2..e7605f83 100755 --- a/_AutoinstallCreator/release.sh +++ b/_AutoinstallCreator/release.sh @@ -15,7 +15,8 @@ orphaned_files_filepath=$dp0/orphaned_files.txt { printf "$self_version" } > "$version_filepath" -{ comm -23 <(git log --pretty=format: --name-only --diff-filter=A | sort) <(cd "$dp0/.." && git ls-tree -r HEAD --name-only | sort) | uniq -u +{ comm -23 <(git log --pretty=format: --name-only --diff-filter=A | sort) \ + <(cd "$dp0/.." && git ls-tree -r HEAD --name-only | sort) | uniq -u } > "$orphaned_files_filepath" tool_version=release-2.4.5-cmd From be6cd8031ce0208552d7226ba7199b7e42bb581d Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 01:48:15 +0400 Subject: [PATCH 35/75] bb --- _AutoinstallCreator/test_update.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 69b3f968..a0fefdec 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -70,7 +70,12 @@ def test_version_up_to_date(self): def test_update_to_new_version(self): subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath, '--target', self.test_old_version], - cwd=_self_tmp_path) + cwd=_self_tmp_path, + env={ + **os.environ, + 'BB_OVERRIDE_APPLETS': 'tar' + }, + ) io_tools.write_text(os.path.join(_self_tmp_path, self.test_old_version, '_AutoinstallCreator', 'version.txt'), self.test_old_version) From 3a113629d9651e14c4684c8c93e1b107d603558d Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 01:50:27 +0400 Subject: [PATCH 36/75] +bash --- update.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 0a8c23c7..95d733c6 100755 --- a/update.sh +++ b/update.sh @@ -116,9 +116,9 @@ if [[ -z $MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH ]]; then fi echo "Extracting to: $dp0/_$self_name/$version_body" -"$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" +bash "$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" echo "Running extracted 'update.sh'" -"$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >& $dp0/_update.log +bash "$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >& $dp0/_update.log From 71fb7b2ed93b043890bf1baac810a95813f51dd7 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 01:56:14 +0400 Subject: [PATCH 37/75] env --- _AutoinstallCreator/test_update.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index a0fefdec..d1ed4c45 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -46,6 +46,10 @@ def setUpClass(cls) -> None: pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) result = subprocess.run(busybox_exe_path_arg + ['bash', os.path.join(_self_path, 'release.sh')], + env={ + **os.environ, + 'BB_OVERRIDE_APPLETS': 'tar' + }, check=True, stdout=subprocess.PIPE) cls.version_str = get_version_from_stdout(result.stdout) From bad7112802e472531fa98e7c9e0cf87653e6ee29 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 01:59:03 +0400 Subject: [PATCH 38/75] skip --- _AutoinstallCreator/test_update.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index d1ed4c45..c1156bdd 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -61,7 +61,12 @@ def setUp(self): shutil.copyfile(os.path.join(_self_path, package_name), self.package_filepath) def test_version_up_to_date(self): - subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath], cwd=_self_tmp_path) + subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath], + env={ + **os.environ, + 'BB_OVERRIDE_APPLETS': 'tar' + }, + cwd=_self_tmp_path) result = subprocess.run(busybox_exe_path_arg + ['bash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')], env={ @@ -72,6 +77,7 @@ def test_version_up_to_date(self): check=True, stdout=subprocess.PIPE) self.assertTrue(result.stdout.endswith(b'\nVersion is up to date\n')) + @unittest.skip('dbg') def test_update_to_new_version(self): subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath, '--target', self.test_old_version], cwd=_self_tmp_path, From fb5ce0e96c9a4ab492b893aa9d626d5e32ef4d2c Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 02:04:51 +0400 Subject: [PATCH 39/75] sh? --- _AutoinstallCreator/test_update.py | 4 ++-- update.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index c1156bdd..5019c21b 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -61,7 +61,7 @@ def setUp(self): shutil.copyfile(os.path.join(_self_path, package_name), self.package_filepath) def test_version_up_to_date(self): - subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath], + subprocess.run(busybox_exe_path_arg + ['sh', self.package_filepath], env={ **os.environ, 'BB_OVERRIDE_APPLETS': 'tar' @@ -79,7 +79,7 @@ def test_version_up_to_date(self): @unittest.skip('dbg') def test_update_to_new_version(self): - subprocess.run(busybox_exe_path_arg + ['bash', self.package_filepath, '--target', self.test_old_version], + subprocess.run(busybox_exe_path_arg + ['sh', self.package_filepath, '--target', self.test_old_version], cwd=_self_tmp_path, env={ **os.environ, diff --git a/update.sh b/update.sh index 95d733c6..b1cd96f4 100755 --- a/update.sh +++ b/update.sh @@ -116,7 +116,7 @@ if [[ -z $MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH ]]; then fi echo "Extracting to: $dp0/_$self_name/$version_body" -bash "$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" +sh "$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" echo "Running extracted 'update.sh'" bash "$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >& $dp0/_update.log From dfd877f315a54c9f3e1d40fb345af041f2c1c733 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 02:06:32 +0400 Subject: [PATCH 40/75] -nanoserver --- .tests/ci-test-run.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.tests/ci-test-run.sh b/.tests/ci-test-run.sh index ea13df35..d5e159f1 100755 --- a/.tests/ci-test-run.sh +++ b/.tests/ci-test-run.sh @@ -8,7 +8,9 @@ set -e "$dp0/test-tools.sh" || exit 1 -if [[ "$is_windows_os" == true ]]; then +is_nanoserver_os=false && $is_windows_os && [[ ! -f "C:\Windows\notepad.exe" ]] && is_nanoserver_os=true + +if [[ "$is_windows_os" == true ]] && [[ "$is_nanoserver_os" == false ]]; then cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1 fi From de542c7c319b4e2488cee91c7d460d42ea4b0978 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Tue, 27 Feb 2024 02:24:22 +0400 Subject: [PATCH 41/75] try windows-2019 --- .github/workflows/ci-test-run.yml | 2 +- _AutoinstallCreator/io_tools.py | 53 ------------------------------ _AutoinstallCreator/test_update.py | 6 ++-- 3 files changed, 4 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 1a82b07f..a49446de 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -19,7 +19,7 @@ jobs: container: 'alpine:3.15.0' artifact: 'alpine' - - os: windows-latest + - os: windows-2019 artifact: 'windows' - os: windows-latest diff --git a/_AutoinstallCreator/io_tools.py b/_AutoinstallCreator/io_tools.py index 8e880b0c..48c0b1bb 100644 --- a/_AutoinstallCreator/io_tools.py +++ b/_AutoinstallCreator/io_tools.py @@ -99,58 +99,5 @@ def write_text(file_path: Union[str, pathlib.Path], data: str, encoding: str = ' return pathlib.Path(file_path).write_text(data=data, encoding=encoding) -def import_package_modules(package_file_path: str, package_name: str) -> list[ModuleType]: - extension = '.py' - imported_modules = [] - for p in sorted(pathlib.Path(os.path.dirname(package_file_path)).iterdir()): - if p.name.endswith(extension) and p.is_file(): - module = p.name[:-len(extension)] - if module != '__init__': - imported_modules.append(importlib.import_module(f".{module}", package_name)) - return imported_modules - - -def byte_to_humanreadable_format(num: Union[int, float], metric: bool = False, precision: int = 1) -> str: - """ - Human-readable formatting of bytes, using binary (powers of 1024) - or metric (powers of 1000) representation. - """ - metric_labels: list[str] = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"] - binary_labels: list[str] = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"] - precision_offsets: list[float] = [0.5, 0.05, 0.005, 0.0005] # PREDEFINED FOR SPEED. - precision_formats: list[str] = ["{}{:.0f} {}", "{}{:.1f} {}", "{}{:.2f} {}", "{}{:.3f} {}"] # PREDEFINED FOR SPEED. - - assert isinstance(num, (int, float)), "num must be an int or float" - assert isinstance(metric, bool), "metric must be a bool" - assert isinstance(precision, int) and 0 <= precision <= 3, "precision must be an int (range 0-3)" - - unit_labels = metric_labels if metric else binary_labels - last_label = unit_labels[-1] - unit_step = 1000 if metric else 1024 - unit_step_thresh = unit_step - precision_offsets[precision] - - is_negative = num < 0 - if is_negative: # Faster than ternary assignment or always running abs(). - num = abs(num) - - for unit in unit_labels: - if num < unit_step_thresh: - # VERY IMPORTANT: - # Only accepts the CURRENT unit if we're BELOW the threshold where - # float rounding behavior would place us into the NEXT unit: F.ex. - # when rounding a float to 1 decimal, any number ">= 1023.95" will - # be rounded to "1024.0". Obviously we don't want ugly output such - # as "1024.0 KiB", since the proper term for that is "1.0 MiB". - break - if unit != last_label: - # We only shrink the number if we HAVEN'T reached the last unit. - # NOTE: These looped divisions accumulate floating point rounding - # errors, but each new division pushes the rounding errors further - # and further down in the decimals, so it doesn't matter at all. - num /= unit_step - - return precision_formats[precision].format("-" if is_negative else "", num, unit) - - def get_name_without_extensions(file_path: str) -> str: return pathlib.Path(pathlib.Path(file_path).stem).stem diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 5019c21b..0df702ab 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -11,7 +11,7 @@ _root_path: str = os.path.dirname(_self_path) _tools_path: str = os.path.join(_root_path, '.tools') -busybox_exe_path_arg: list[str] = [] +busybox_exe_path_arg = [] update_script_name: str = 'update.sh' package_name = 'AutoinstallCreator.sh' if sys.platform.startswith('win'): @@ -42,8 +42,8 @@ class TestUpdate(unittest.TestCase): @classmethod def setUpClass(cls) -> None: - pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) - pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) + #pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) + #pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) result = subprocess.run(busybox_exe_path_arg + ['bash', os.path.join(_self_path, 'release.sh')], env={ From 8af86dfb66db7b362697c1d121a81f1ac8bebee9 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 1 Mar 2024 00:10:53 +0400 Subject: [PATCH 42/75] revert and test linux first --- .github/workflows/ci-test-run.yml | 2 +- .tests/ci-test-run.sh | 4 +--- _AutoinstallCreator/test_update.py | 38 ++++++++++-------------------- update.sh | 4 ++-- 4 files changed, 16 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index a49446de..1a82b07f 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -19,7 +19,7 @@ jobs: container: 'alpine:3.15.0' artifact: 'alpine' - - os: windows-2019 + - os: windows-latest artifact: 'windows' - os: windows-latest diff --git a/.tests/ci-test-run.sh b/.tests/ci-test-run.sh index d5e159f1..77413205 100755 --- a/.tests/ci-test-run.sh +++ b/.tests/ci-test-run.sh @@ -8,9 +8,7 @@ set -e "$dp0/test-tools.sh" || exit 1 -is_nanoserver_os=false && $is_windows_os && [[ ! -f "C:\Windows\notepad.exe" ]] && is_nanoserver_os=true - -if [[ "$is_windows_os" == true ]] && [[ "$is_nanoserver_os" == false ]]; then +if [[ "$is_windows_os" == false ]]; then cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1 fi diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 0df702ab..392c60f5 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -11,11 +11,11 @@ _root_path: str = os.path.dirname(_self_path) _tools_path: str = os.path.join(_root_path, '.tools') -busybox_exe_path_arg = [] +busybox_exe_path_arg: list[str] = ['x-terminal-emulator', '-e'] update_script_name: str = 'update.sh' package_name = 'AutoinstallCreator.sh' if sys.platform.startswith('win'): - busybox_exe_path_arg = [os.path.join(_tools_path, 'busybox.exe')] + busybox_exe_path_arg = [os.path.join(_tools_path, 'busybox.exe'), 'bash'] update_script_name = 'update.bat' package_name = 'AutoinstallCreator.sh.bat' @@ -42,14 +42,10 @@ class TestUpdate(unittest.TestCase): @classmethod def setUpClass(cls) -> None: - #pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) - #pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) + pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) + pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) - result = subprocess.run(busybox_exe_path_arg + ['bash', os.path.join(_self_path, 'release.sh')], - env={ - **os.environ, - 'BB_OVERRIDE_APPLETS': 'tar' - }, + result = subprocess.run(busybox_exe_path_arg + [os.path.join(_self_path, 'release.sh')], check=True, stdout=subprocess.PIPE) cls.version_str = get_version_from_stdout(result.stdout) @@ -58,34 +54,24 @@ def setUp(self): self.assertTrue(self.version_str.startswith('AutoinstallCreator.')) self.assertTrue(io_tools.try_create_or_clean_dir(_self_tmp_path)) self.package_filepath = os.path.join(_self_tmp_path, package_name) - shutil.copyfile(os.path.join(_self_path, package_name), self.package_filepath) + shutil.copy2(os.path.join(_self_path, package_name), self.package_filepath) def test_version_up_to_date(self): - subprocess.run(busybox_exe_path_arg + ['sh', self.package_filepath], - env={ - **os.environ, - 'BB_OVERRIDE_APPLETS': 'tar' - }, - cwd=_self_tmp_path) + subprocess.run(busybox_exe_path_arg + [self.package_filepath], + cwd=_self_tmp_path, + check=True) - result = subprocess.run(busybox_exe_path_arg + ['bash', os.path.join(_self_tmp_path, self.version_str, 'update.sh')], + result = subprocess.run(busybox_exe_path_arg + [os.path.join(_self_tmp_path, self.version_str, 'update.sh')], env={ - **os.environ, 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath }, check=True, stdout=subprocess.PIPE) self.assertTrue(result.stdout.endswith(b'\nVersion is up to date\n')) - @unittest.skip('dbg') def test_update_to_new_version(self): - subprocess.run(busybox_exe_path_arg + ['sh', self.package_filepath, '--target', self.test_old_version], - cwd=_self_tmp_path, - env={ - **os.environ, - 'BB_OVERRIDE_APPLETS': 'tar' - }, - ) + subprocess.run(busybox_exe_path_arg + [self.package_filepath, '--target', self.test_old_version], + cwd=_self_tmp_path) io_tools.write_text(os.path.join(_self_tmp_path, self.test_old_version, '_AutoinstallCreator', 'version.txt'), self.test_old_version) diff --git a/update.sh b/update.sh index b1cd96f4..0a8c23c7 100755 --- a/update.sh +++ b/update.sh @@ -116,9 +116,9 @@ if [[ -z $MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH ]]; then fi echo "Extracting to: $dp0/_$self_name/$version_body" -sh "$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" +"$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" echo "Running extracted 'update.sh'" -bash "$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >& $dp0/_update.log +"$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >& $dp0/_update.log From 69b6dbf83ed5bd0889f6ad4739a6249297af6dc8 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 1 Mar 2024 00:11:24 +0400 Subject: [PATCH 43/75] ignore .log --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 549b8c60..248e8165 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,8 @@ _AutoinstallCreator/AutoinstallCreator* *.tar.zst *.old *.md +*.log + .idea/ .empty uTorrent/*.lng From f72157c144fe5c0b9b7405d8b6e6bae3e8c6a1f3 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 1 Mar 2024 00:12:31 +0400 Subject: [PATCH 44/75] disable release trigger --- .github/workflows/ci-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 14fa58c3..a8217f2d 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -1,6 +1,6 @@ name: ci release -on: [pull_request, workflow_dispatch] +on: [workflow_dispatch] jobs: self-release: From 2f5d927f438ff465c5856a1fb5e4d0413607a3f1 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 1 Mar 2024 00:20:57 +0400 Subject: [PATCH 45/75] disable alpine --- .github/workflows/ci-test-run.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 1a82b07f..bf65b500 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -15,9 +15,9 @@ jobs: container: 'ubuntu:22.04' artifact: 'ubuntu' - - os: ubuntu-latest - container: 'alpine:3.15.0' - artifact: 'alpine' +# - os: ubuntu-latest +# container: 'alpine:3.15.0' +# artifact: 'alpine' - os: windows-latest artifact: 'windows' From 2cf3c341f651d2eb4a820a7168a5724ea8912758 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 1 Mar 2024 00:23:02 +0400 Subject: [PATCH 46/75] check status from _update.log use xterm --- .github/workflows/ci-test-run.yml | 2 +- _AutoinstallCreator/test_update.py | 65 ++++++++++++++++-------------- update.sh | 6 +-- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index bf65b500..58d300e5 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -31,7 +31,7 @@ jobs: if: matrix.artifact == 'ubuntu' run: | apt update - apt install -y busybox dos2unix libarchive-tools python3 git + apt install -y busybox dos2unix libarchive-tools python3 git xterm git config --global --add safe.directory '*' - name: Install Alpine packages diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 392c60f5..6ddb22dc 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -7,11 +7,13 @@ _self_path: str = os.path.dirname(os.path.realpath(__file__)) +_self_body_path = os.path.join(os.path.dirname(_self_path), 'body.md') + _self_tmp_path: str = os.path.join(_self_path, '.tmp') _root_path: str = os.path.dirname(_self_path) _tools_path: str = os.path.join(_root_path, '.tools') -busybox_exe_path_arg: list[str] = ['x-terminal-emulator', '-e'] +busybox_exe_path_arg: list[str] = ['xterm', '-e'] update_script_name: str = 'update.sh' package_name = 'AutoinstallCreator.sh' if sys.platform.startswith('win'): @@ -25,49 +27,55 @@ from _AutoinstallCreator import io_tools -def get_version_from_stdout(b_stdout: bytes) -> str: - for b_line in b_stdout.splitlines(): - if b_line.startswith(b'version created:'): - version_line = b_line.decode().strip() - prefix, _, raw_version = version_line.partition(':') - return raw_version.strip() - - def update_completed(update_log_path: str, version_str: str) -> bool: update_log = io_tools.read_text(update_log_path) return update_log.endswith(f'\nUpdate complete: {version_str}\n') +def version_is_up_to_date(update_log_path: str, version_str: str) -> bool: + update_log = io_tools.read_text(update_log_path).strip() + return update_log == f'Version is up to date: {version_str}' + + class TestUpdate(unittest.TestCase): @classmethod def setUpClass(cls) -> None: pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) + pathlib.Path(_self_body_path).unlink(missing_ok=True) - result = subprocess.run(busybox_exe_path_arg + [os.path.join(_self_path, 'release.sh')], - check=True, stdout=subprocess.PIPE) - cls.version_str = get_version_from_stdout(result.stdout) + subprocess.run(busybox_exe_path_arg + [os.path.join(_self_path, 'release.sh')], + check=True) + cls.version_str = io_tools.read_text(_self_body_path).strip('\r\n') + if not cls.version_str: + raise ValueError('cannot get version from release.sh') def setUp(self): self.test_old_version = 'AutoinstallCreator.11.test_old_version' self.assertTrue(self.version_str.startswith('AutoinstallCreator.')) self.assertTrue(io_tools.try_create_or_clean_dir(_self_tmp_path)) self.package_filepath = os.path.join(_self_tmp_path, package_name) + self.old_update_log_filepath = os.path.join(_self_tmp_path, self.test_old_version, '_update.log') + self.update_log_filepath = os.path.join(_self_tmp_path, self.version_str, '_update.log') shutil.copy2(os.path.join(_self_path, package_name), self.package_filepath) + pathlib.Path(self.old_update_log_filepath).unlink(missing_ok=True) + pathlib.Path(self.update_log_filepath).unlink(missing_ok=True) + + def test_version_up_to_date(self): subprocess.run(busybox_exe_path_arg + [self.package_filepath], cwd=_self_tmp_path, check=True) - result = subprocess.run(busybox_exe_path_arg + [os.path.join(_self_tmp_path, self.version_str, 'update.sh')], - env={ - 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, - 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath - }, - check=True, stdout=subprocess.PIPE) - self.assertTrue(result.stdout.endswith(b'\nVersion is up to date\n')) + subprocess.run(busybox_exe_path_arg + [os.path.join(_self_tmp_path, self.version_str, 'update.sh')], + env={ + 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, + 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath + }, + check=True) + self.assertTrue(version_is_up_to_date(self.update_log_filepath, self.version_str)) def test_update_to_new_version(self): subprocess.run(busybox_exe_path_arg + [self.package_filepath, '--target', self.test_old_version], @@ -76,18 +84,15 @@ def test_update_to_new_version(self): io_tools.write_text(os.path.join(_self_tmp_path, self.test_old_version, '_AutoinstallCreator', 'version.txt'), self.test_old_version) - result = subprocess.run([os.path.join(_self_tmp_path, self.test_old_version, update_script_name)], - env={ - **os.environ, - 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, - 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath - }, - check=True, stdout=subprocess.PIPE) - - self.assertIn(f'\nFound new version: {self.test_old_version} -> {self.version_str}\n'.encode(), result.stdout) + subprocess.run([os.path.join(_self_tmp_path, self.test_old_version, update_script_name)], + env={ + **os.environ, + 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, + 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath + }, + check=True) - update_log_filepath = os.path.join(_self_tmp_path, self.test_old_version, '_update.log') - self.assertTrue(io_tools.wait_for(lambda: update_completed(update_log_filepath, self.version_str), + self.assertTrue(io_tools.wait_for(lambda: update_completed(self.old_update_log_filepath, self.version_str), err_message='Update failed', timeout=10, retry_timeout=0.5, diff --git a/update.sh b/update.sh index 0a8c23c7..eee33d6d 100755 --- a/update.sh +++ b/update.sh @@ -88,7 +88,7 @@ version_hash=$(echo "$version_body" | "$grep" --only-matching "(?<=$self_name\.$ } if [[ $self_version_count -eq $version_count ]] && [[ $self_version_hash == $version_hash ]]; then - echo "Version is up to date" + echo "Version is up to date: $version_body" > $dp0/_update.log 2>&1 exit 0 fi @@ -116,9 +116,9 @@ if [[ -z $MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH ]]; then fi echo "Extracting to: $dp0/_$self_name/$version_body" -"$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" +"$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" > $dp0/_update.log 2>&1 echo "Running extracted 'update.sh'" -"$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >& $dp0/_update.log +"$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >> $dp0/_update.log 2>&1 From 75ae5215364a9312805a4e2dea10547fd17260e1 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 1 Mar 2024 23:25:57 +0400 Subject: [PATCH 47/75] =?UTF-8?q?+=20=E2=86=92=20\;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _AutoinstallCreator/test_update.py | 3 ++- update.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 6ddb22dc..d1593bc0 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -69,8 +69,9 @@ def test_version_up_to_date(self): cwd=_self_tmp_path, check=True) - subprocess.run(busybox_exe_path_arg + [os.path.join(_self_tmp_path, self.version_str, 'update.sh')], + subprocess.run([os.path.join(_self_tmp_path, self.version_str, update_script_name)], env={ + **os.environ, 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath }, diff --git a/update.sh b/update.sh index eee33d6d..21852fac 100755 --- a/update.sh +++ b/update.sh @@ -29,7 +29,7 @@ if [[ ! -z "$target_path" ]]; then echo "Copying new files" find "$dp0" -mindepth 1 -maxdepth 1 ! -name "tmp_*" \ - -exec cp -rf "{}" "$target_path/" + + -exec cp -rf "{}" "$target_path/" \; echo "Removing orphaned files" orphaned_files=$(cat $dp0/_$self_name/orphaned_files.txt) From 4081920709d6e2ead8ce4070905d064ec214f4d1 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 1 Mar 2024 23:31:33 +0400 Subject: [PATCH 48/75] check xterm --- .github/workflows/ci-test-run.yml | 2 +- _AutoinstallCreator/test_update.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 58d300e5..bf65b500 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -31,7 +31,7 @@ jobs: if: matrix.artifact == 'ubuntu' run: | apt update - apt install -y busybox dos2unix libarchive-tools python3 git xterm + apt install -y busybox dos2unix libarchive-tools python3 git git config --global --add safe.directory '*' - name: Install Alpine packages diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index d1593bc0..fcea90ba 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -13,7 +13,7 @@ _root_path: str = os.path.dirname(_self_path) _tools_path: str = os.path.join(_root_path, '.tools') -busybox_exe_path_arg: list[str] = ['xterm', '-e'] +busybox_exe_path_arg: list[str] = [] update_script_name: str = 'update.sh' package_name = 'AutoinstallCreator.sh' if sys.platform.startswith('win'): @@ -41,10 +41,16 @@ class TestUpdate(unittest.TestCase): @classmethod def setUpClass(cls) -> None: + global busybox_exe_path_arg + pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) pathlib.Path(_self_body_path).unlink(missing_ok=True) + if not sys.platform.startswith('win'): + if shutil.which('xterm'): + busybox_exe_path_arg = ['xterm', '-e'] + subprocess.run(busybox_exe_path_arg + [os.path.join(_self_path, 'release.sh')], check=True) cls.version_str = io_tools.read_text(_self_body_path).strip('\r\n') From 50302e1c0fd58ed8a9c38e6b31800f03fbf5bb66 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 1 Mar 2024 23:39:38 +0400 Subject: [PATCH 49/75] enable windows tests --- .tests/ci-test-run.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.tests/ci-test-run.sh b/.tests/ci-test-run.sh index 77413205..941825b7 100755 --- a/.tests/ci-test-run.sh +++ b/.tests/ci-test-run.sh @@ -8,8 +8,6 @@ set -e "$dp0/test-tools.sh" || exit 1 -if [[ "$is_windows_os" == false ]]; then - cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1 -fi +cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1 "$dp0/test-run.sh" -- testInternalCreate || exit 1 From 4b1913395dc0fcb1475f5c63195ff1916573fd4c Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Fri, 1 Mar 2024 23:47:53 +0400 Subject: [PATCH 50/75] - nanoserver --- .github/workflows/ci-test-run.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index bf65b500..8eb8c364 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -21,9 +21,9 @@ jobs: - os: windows-latest artifact: 'windows' - - - os: windows-latest - artifact: 'nanoserver' +# +# - os: windows-latest +# artifact: 'nanoserver' container: ${{ matrix.container }} steps: From 80366b7fb826e6071161f4ef0986f5633a7f94f0 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 00:08:45 +0400 Subject: [PATCH 51/75] 'gnome-terminal', '--wait' --- _AutoinstallCreator/test_update.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index fcea90ba..fc18c914 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -48,8 +48,8 @@ def setUpClass(cls) -> None: pathlib.Path(_self_body_path).unlink(missing_ok=True) if not sys.platform.startswith('win'): - if shutil.which('xterm'): - busybox_exe_path_arg = ['xterm', '-e'] + if shutil.which('gnome-terminal'): + busybox_exe_path_arg = ['gnome-terminal', '--wait', '--'] subprocess.run(busybox_exe_path_arg + [os.path.join(_self_path, 'release.sh')], check=True) @@ -69,7 +69,6 @@ def setUp(self): pathlib.Path(self.old_update_log_filepath).unlink(missing_ok=True) pathlib.Path(self.update_log_filepath).unlink(missing_ok=True) - def test_version_up_to_date(self): subprocess.run(busybox_exe_path_arg + [self.package_filepath], cwd=_self_tmp_path, @@ -86,7 +85,8 @@ def test_version_up_to_date(self): def test_update_to_new_version(self): subprocess.run(busybox_exe_path_arg + [self.package_filepath, '--target', self.test_old_version], - cwd=_self_tmp_path) + cwd=_self_tmp_path, + check=True) io_tools.write_text(os.path.join(_self_tmp_path, self.test_old_version, '_AutoinstallCreator', 'version.txt'), self.test_old_version) From 5769bb463eb6e29904eea5ee631d1837d67dcb7b Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 00:30:42 +0400 Subject: [PATCH 52/75] MOCK_AUTOINSTALLCREATOR_XTERM --- _AutoinstallCreator/test_update.py | 10 +++++++--- update.sh | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index fc18c914..0b84338d 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -16,6 +16,7 @@ busybox_exe_path_arg: list[str] = [] update_script_name: str = 'update.sh' package_name = 'AutoinstallCreator.sh' +mock_xterm = '' if sys.platform.startswith('win'): busybox_exe_path_arg = [os.path.join(_tools_path, 'busybox.exe'), 'bash'] update_script_name = 'update.bat' @@ -41,7 +42,7 @@ class TestUpdate(unittest.TestCase): @classmethod def setUpClass(cls) -> None: - global busybox_exe_path_arg + global busybox_exe_path_arg, mock_xterm pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh')).unlink(missing_ok=True) pathlib.Path(os.path.join(_self_path, 'AutoinstallCreator.sh.bat')).unlink(missing_ok=True) @@ -50,6 +51,7 @@ def setUpClass(cls) -> None: if not sys.platform.startswith('win'): if shutil.which('gnome-terminal'): busybox_exe_path_arg = ['gnome-terminal', '--wait', '--'] + mock_xterm = 'gnome-terminal --wait -- ' subprocess.run(busybox_exe_path_arg + [os.path.join(_self_path, 'release.sh')], check=True) @@ -78,7 +80,8 @@ def test_version_up_to_date(self): env={ **os.environ, 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, - 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath + 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath, + 'MOCK_AUTOINSTALLCREATOR_XTERM': mock_xterm }, check=True) self.assertTrue(version_is_up_to_date(self.update_log_filepath, self.version_str)) @@ -95,7 +98,8 @@ def test_update_to_new_version(self): env={ **os.environ, 'MOCK_AUTOINSTALLCREATOR_VERSION_BODY': self.version_str, - 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath + 'MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH': self.package_filepath, + 'MOCK_AUTOINSTALLCREATOR_XTERM': mock_xterm }, check=True) diff --git a/update.sh b/update.sh index 21852fac..03d6b72e 100755 --- a/update.sh +++ b/update.sh @@ -116,7 +116,7 @@ if [[ -z $MOCK_AUTOINSTALLCREATOR_PACKAGE_FILEPATH ]]; then fi echo "Extracting to: $dp0/_$self_name/$version_body" -"$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" > $dp0/_update.log 2>&1 +$MOCK_AUTOINSTALLCREATOR_XTERM "$package_filepath" --target "$dp0/_$self_name/tmp_$version_body" > $dp0/_update.log 2>&1 echo "Running extracted 'update.sh'" "$dp0/_$self_name/tmp_$version_body/update.sh" "$dp0" >> $dp0/_update.log 2>&1 From ec2a807721987bde30b66fdc86cc5d773c769b44 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 00:38:49 +0400 Subject: [PATCH 53/75] -windows +alpine --- .github/workflows/ci-test-run.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 8eb8c364..09d2a968 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -15,12 +15,12 @@ jobs: container: 'ubuntu:22.04' artifact: 'ubuntu' -# - os: ubuntu-latest -# container: 'alpine:3.15.0' -# artifact: 'alpine' + - os: ubuntu-latest + container: 'alpine:3.15.0' + artifact: 'alpine' - - os: windows-latest - artifact: 'windows' +# - os: windows-latest +# artifact: 'windows' # # - os: windows-latest # artifact: 'nanoserver' From 0aa6ace2730252ce9d8f45b81f2bebac7527ffea Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 00:40:02 +0400 Subject: [PATCH 54/75] - ::group:: prepare sources --- _AutoinstallCreator/release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_AutoinstallCreator/release.sh b/_AutoinstallCreator/release.sh index e7605f83..a59990ad 100755 --- a/_AutoinstallCreator/release.sh +++ b/_AutoinstallCreator/release.sh @@ -27,7 +27,7 @@ makeself_target_path="$dp0/makeself-$tool_version" makeself_sh_path="$makeself_target_path/makeself.sh" [[ ! -f "$makeself_version_path" ]] && { - echo "::group::prepare sources $download_url" + echo "prepare sources $download_url" $curl --silent --location "$download_url" --output "$makeself_version_path" tar -xf "$makeself_version_path" } From d796cf6d834679b5066e558303ed0ee99b964cb3 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 00:44:14 +0400 Subject: [PATCH 55/75] +windows -linux --- .github/workflows/ci-test-run.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 09d2a968..45c967ae 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -11,17 +11,17 @@ jobs: strategy: matrix: include: - - os: ubuntu-latest - container: 'ubuntu:22.04' - artifact: 'ubuntu' +# - os: ubuntu-latest +# container: 'ubuntu:22.04' +# artifact: 'ubuntu' +# +# - os: ubuntu-latest +# container: 'alpine:3.15.0' +# artifact: 'alpine' - - os: ubuntu-latest - container: 'alpine:3.15.0' - artifact: 'alpine' + - os: windows-latest + artifact: 'windows' -# - os: windows-latest -# artifact: 'windows' -# # - os: windows-latest # artifact: 'nanoserver' From fe4a57ba93d4bdc52206113e824a2d5e0d7da59c Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 00:54:53 +0400 Subject: [PATCH 56/75] try core.autocrlf false --- .github/workflows/ci-test-run.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 45c967ae..01cfb5c1 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -51,7 +51,9 @@ jobs: - name: ci test-run (windows) if: matrix.artifact == 'windows' shell: cmd - run: call .tests\ci-test-run.bat + run: | + git config --global core.autocrlf false + call .tests\ci-test-run.bat - name: pull (nanoserver) container ${{ env.IMAGE_NAME }} if: matrix.artifact == 'nanoserver' From 364d8738ab4184e928a8a3c18cd9b71cd824cbd9 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 01:01:59 +0400 Subject: [PATCH 57/75] which sha --- _AutoinstallCreator/test_sha256.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 _AutoinstallCreator/test_sha256.py diff --git a/_AutoinstallCreator/test_sha256.py b/_AutoinstallCreator/test_sha256.py new file mode 100644 index 00000000..11a64889 --- /dev/null +++ b/_AutoinstallCreator/test_sha256.py @@ -0,0 +1,13 @@ +import os +import pathlib +import shutil +import subprocess +import sys +import unittest + + +class TestSha256(unittest.TestCase): + def test_sha256_info(self): + print(f"shasum: {shutil.which('shasum')}") + print(f"sha256sum: {shutil.which('sha256sum')}") + From e2d73f9a9f3b468bf311dbbfd06973ed0aa707d1 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 01:07:00 +0400 Subject: [PATCH 58/75] remove wrong sha256sum --- .github/workflows/ci-test-run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 01cfb5c1..afa9decd 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -52,7 +52,7 @@ jobs: if: matrix.artifact == 'windows' shell: cmd run: | - git config --global core.autocrlf false + rm -f "C:\Strawberry\perl\bin\shasum.BAT" call .tests\ci-test-run.bat - name: pull (nanoserver) container ${{ env.IMAGE_NAME }} From 3be4dea20cde713ad2f3c8668ec1b3c0f9ea0432 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 01:19:23 +0400 Subject: [PATCH 59/75] +nanoserver --- .github/workflows/ci-test-run.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index afa9decd..24e38675 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -22,8 +22,8 @@ jobs: - os: windows-latest artifact: 'windows' -# - os: windows-latest -# artifact: 'nanoserver' + - os: windows-latest + artifact: 'nanoserver' container: ${{ matrix.container }} steps: @@ -63,7 +63,11 @@ jobs: - name: ci test-run (nanoserver) if: matrix.artifact == 'nanoserver' - run: docker container run --rm -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat + run: | + curl --location "https://github.com/hemnstill/StandaloneTools/releases/download/python-3.12.1/build-msvc.tar.gz" --output "python.tar.gz" + tar -xf "python.tar.gz" --directory "C:\app\.tests" + echo f | xcopy /Y /Q /R "C:\app\.tests\python.exe" "C:\app\.tests\python3.exe" + docker container run --rm -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: needs: test From 4d1f8798ff9ee61ded166e3e66d327859f2fd476 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 01:22:41 +0400 Subject: [PATCH 60/75] ${{ github.workspace }} --- .github/workflows/ci-test-run.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 24e38675..64c207f2 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -64,9 +64,10 @@ jobs: - name: ci test-run (nanoserver) if: matrix.artifact == 'nanoserver' run: | + cd "${{ github.workspace }}\_AutoinstallCreator" curl --location "https://github.com/hemnstill/StandaloneTools/releases/download/python-3.12.1/build-msvc.tar.gz" --output "python.tar.gz" - tar -xf "python.tar.gz" --directory "C:\app\.tests" - echo f | xcopy /Y /Q /R "C:\app\.tests\python.exe" "C:\app\.tests\python3.exe" + tar -xf "python.tar.gz" --strip-components 2 + echo f | xcopy /Y /Q /R "python.exe" "python3.exe" docker container run --rm -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: From e5f006452ba84b94876c127788548b810259a1c7 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:09:03 +0400 Subject: [PATCH 61/75] ci-init.bat --- .github/workflows/ci-test-run.yml | 18 ++++++++++++++---- .tests/ci-test-run.bat | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 64c207f2..dfd9dca8 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -64,10 +64,20 @@ jobs: - name: ci test-run (nanoserver) if: matrix.artifact == 'nanoserver' run: | - cd "${{ github.workspace }}\_AutoinstallCreator" - curl --location "https://github.com/hemnstill/StandaloneTools/releases/download/python-3.12.1/build-msvc.tar.gz" --output "python.tar.gz" - tar -xf "python.tar.gz" --strip-components 2 - echo f | xcopy /Y /Q /R "python.exe" "python3.exe" + >"${{ github.workspace }}\.tests\ci-init.bat" ( + echo mkdir -p C:\Python + echo cd C:\Python + echo curl --location "https://github.com/hemnstill/StandaloneTools/releases/download/python-3.12.1/build-msvc.tar.gz" --output "python.tar.gz" + echo tar -xf "python.tar.gz" --strip-components 2 + echo echo f | xcopy /Y /Q /R "python.exe" "python3.exe" + + echo mkdir -p C:\git + echo cd C:\git + echo curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" + echo tar -xf "git.zip" + echo setx /M Path "C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;%PATH%" + ) + docker container run --rm -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: diff --git a/.tests/ci-test-run.bat b/.tests/ci-test-run.bat index 5bd876e1..a2ba20f6 100644 --- a/.tests/ci-test-run.bat +++ b/.tests/ci-test-run.bat @@ -1,4 +1,7 @@ @echo off + +if exist "%~dp0\ci-init.bat" call "%~dp0\ci-init.bat" + "%~dp0..\.tools\busybox.exe" bash "%~dp0ci-test-run.sh" %* exit /b %errorlevel% From cc57ca1dd642577e4c750496d9da4fd16feda8dc Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:15:49 +0400 Subject: [PATCH 62/75] ^ --- .github/workflows/ci-test-run.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index dfd9dca8..aea1f272 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -64,7 +64,7 @@ jobs: - name: ci test-run (nanoserver) if: matrix.artifact == 'nanoserver' run: | - >"${{ github.workspace }}\.tests\ci-init.bat" ( + >"${{ github.workspace }}\.tests\ci-init.bat" ^( echo mkdir -p C:\Python echo cd C:\Python echo curl --location "https://github.com/hemnstill/StandaloneTools/releases/download/python-3.12.1/build-msvc.tar.gz" --output "python.tar.gz" @@ -76,7 +76,7 @@ jobs: echo curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" echo tar -xf "git.zip" echo setx /M Path "C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;%PATH%" - ) + ^) docker container run --rm -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat From 864847871112a272076c2604bf3b581d8f1fa782 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:20:20 +0400 Subject: [PATCH 63/75] .example --- .github/workflows/ci-test-run.yml | 15 +-------------- .tests/ci-init-nanoserver.bat.example | 9 +++++++++ 2 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 .tests/ci-init-nanoserver.bat.example diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index aea1f272..b655f367 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -64,20 +64,7 @@ jobs: - name: ci test-run (nanoserver) if: matrix.artifact == 'nanoserver' run: | - >"${{ github.workspace }}\.tests\ci-init.bat" ^( - echo mkdir -p C:\Python - echo cd C:\Python - echo curl --location "https://github.com/hemnstill/StandaloneTools/releases/download/python-3.12.1/build-msvc.tar.gz" --output "python.tar.gz" - echo tar -xf "python.tar.gz" --strip-components 2 - echo echo f | xcopy /Y /Q /R "python.exe" "python3.exe" - - echo mkdir -p C:\git - echo cd C:\git - echo curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" - echo tar -xf "git.zip" - echo setx /M Path "C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;%PATH%" - ^) - + echo f | xcopy /Y /Q /R "${{ github.workspace }}\.tests\ci-init-nanoserver.bat.example" "${{ github.workspace }}\.tests\ci-init.bat" docker container run --rm -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: diff --git a/.tests/ci-init-nanoserver.bat.example b/.tests/ci-init-nanoserver.bat.example new file mode 100644 index 00000000..8749278c --- /dev/null +++ b/.tests/ci-init-nanoserver.bat.example @@ -0,0 +1,9 @@ +mkdir -p C:\Python && cd C:\Python +curl --location "https://github.com/hemnstill/StandaloneTools/releases/download/python-3.12.1/build-msvc.tar.gz" --output "python.tar.gz" +tar -xf "python.tar.gz" --strip-components 2 +echo f | xcopy /Y /Q /R "python.exe" "python3.exe" + +mkdir -p C:\git && cd C:\git +curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" +tar -xf "git.zip" +setx /M Path "C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;%PATH%" From 4dfa10e44c419a9955ba379710a431d30b479a4d Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:26:02 +0400 Subject: [PATCH 64/75] e path --- .github/workflows/ci-test-run.yml | 2 +- .tests/ci-init-nanoserver.bat.example | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index b655f367..93239617 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -65,7 +65,7 @@ jobs: if: matrix.artifact == 'nanoserver' run: | echo f | xcopy /Y /Q /R "${{ github.workspace }}\.tests\ci-init-nanoserver.bat.example" "${{ github.workspace }}\.tests\ci-init.bat" - docker container run --rm -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat + docker container run --rm -e PATH='"C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;%PATH%"' -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: needs: test diff --git a/.tests/ci-init-nanoserver.bat.example b/.tests/ci-init-nanoserver.bat.example index 8749278c..3cb9f4d8 100644 --- a/.tests/ci-init-nanoserver.bat.example +++ b/.tests/ci-init-nanoserver.bat.example @@ -6,4 +6,3 @@ echo f | xcopy /Y /Q /R "python.exe" "python3.exe" mkdir -p C:\git && cd C:\git curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" tar -xf "git.zip" -setx /M Path "C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;%PATH%" From db59443a913e1a897db44e7e345405ef30e7b3c0 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:27:26 +0400 Subject: [PATCH 65/75] ^^ --- .github/workflows/ci-test-run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 93239617..0371dc45 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -65,7 +65,7 @@ jobs: if: matrix.artifact == 'nanoserver' run: | echo f | xcopy /Y /Q /R "${{ github.workspace }}\.tests\ci-init-nanoserver.bat.example" "${{ github.workspace }}\.tests\ci-init.bat" - docker container run --rm -e PATH='"C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;%PATH%"' -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat + docker container run --rm -e PATH='"C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;^%PATH^%"' -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: needs: test From c398cbec01300a56005e6ec39fb04ab1ae7c1968 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:28:19 +0400 Subject: [PATCH 66/75] ~ --- .github/workflows/ci-test-run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 0371dc45..6bc29d1a 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -65,7 +65,7 @@ jobs: if: matrix.artifact == 'nanoserver' run: | echo f | xcopy /Y /Q /R "${{ github.workspace }}\.tests\ci-init-nanoserver.bat.example" "${{ github.workspace }}\.tests\ci-init.bat" - docker container run --rm -e PATH='"C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;^%PATH^%"' -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat + docker container run --rm -e PATH="C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;%PATH%" -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: needs: test From 271e02a3b21f79bad8079e0cf901da9a15633372 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:32:09 +0400 Subject: [PATCH 67/75] -%PATH% --- .github/workflows/ci-test-run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 6bc29d1a..c4267801 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -65,7 +65,7 @@ jobs: if: matrix.artifact == 'nanoserver' run: | echo f | xcopy /Y /Q /R "${{ github.workspace }}\.tests\ci-init-nanoserver.bat.example" "${{ github.workspace }}\.tests\ci-init.bat" - docker container run --rm -e PATH="C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;%PATH%" -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat + docker container run --rm -e PATH="C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;C:\Windows;C:\Windows\System32" -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: needs: test From 391aaab9cd83a89a5ddf770ef2837fc13526c555 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:34:48 +0400 Subject: [PATCH 68/75] add global unsafe --- .tests/ci-init-nanoserver.bat.example | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.tests/ci-init-nanoserver.bat.example b/.tests/ci-init-nanoserver.bat.example index 3cb9f4d8..403c277f 100644 --- a/.tests/ci-init-nanoserver.bat.example +++ b/.tests/ci-init-nanoserver.bat.example @@ -6,3 +6,5 @@ echo f | xcopy /Y /Q /R "python.exe" "python3.exe" mkdir -p C:\git && cd C:\git curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" tar -xf "git.zip" + +C:\git\mingw64\bin\git config --global --add safe.directory '*' From ae8928edff2b094451fc85191193603d1e4e6867 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:35:23 +0400 Subject: [PATCH 69/75] ~ --- .github/workflows/ci-test-run.yml | 2 +- .tests/ci-init-nanoserver.bat.example | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index c4267801..9ab50358 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -65,7 +65,7 @@ jobs: if: matrix.artifact == 'nanoserver' run: | echo f | xcopy /Y /Q /R "${{ github.workspace }}\.tests\ci-init-nanoserver.bat.example" "${{ github.workspace }}\.tests\ci-init.bat" - docker container run --rm -e PATH="C:\Python;C:\git\bin;C:\git\usr\bin;C:\git\mingw64\bin;C:\Windows;C:\Windows\System32" -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat + docker container run --rm -e PATH="C:\Python;C:\git\mingw64\bin;C:\Windows;C:\Windows\System32" -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: needs: test diff --git a/.tests/ci-init-nanoserver.bat.example b/.tests/ci-init-nanoserver.bat.example index 403c277f..43cbee02 100644 --- a/.tests/ci-init-nanoserver.bat.example +++ b/.tests/ci-init-nanoserver.bat.example @@ -7,4 +7,4 @@ mkdir -p C:\git && cd C:\git curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" tar -xf "git.zip" -C:\git\mingw64\bin\git config --global --add safe.directory '*' +C:\git\mingw64\bin\git config --global --add safe.directory "*" From f3f2e8c2f88c94512d50de8672499437ddf8accb Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:43:25 +0400 Subject: [PATCH 70/75] -v --- .tests/ci-test-run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tests/ci-test-run.sh b/.tests/ci-test-run.sh index 941825b7..e9a31a7a 100755 --- a/.tests/ci-test-run.sh +++ b/.tests/ci-test-run.sh @@ -8,6 +8,6 @@ set -e "$dp0/test-tools.sh" || exit 1 -cd "$dp0/../_AutoinstallCreator" && python3 -m unittest || exit 1 +cd "$dp0/../_AutoinstallCreator" && python3 -m unittest -v || exit 1 "$dp0/test-run.sh" -- testInternalCreate || exit 1 From 7af4b058813cb68c2151875f6d1f29d456993cc7 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:53:03 +0400 Subject: [PATCH 71/75] tearDown --- _AutoinstallCreator/test_update.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 0b84338d..43c2c8a6 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -108,3 +108,12 @@ def test_update_to_new_version(self): timeout=10, retry_timeout=0.5, exception=OSError)) + + def tearDown(self): + if os.path.isfile(self.old_update_log_filepath): + print(f'''old_update_log_filepath: +{io_tools.read_text(self.old_update_log_filepath)}''') + + if os.path.isfile(self.update_log_filepath): + print(f'''old_update_log_filepath: +{io_tools.read_text(self.update_log_filepath)}''') From 6e12f6158cf3ae82a9d8b43c9923aa0c01ab0e62 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 02:58:50 +0400 Subject: [PATCH 72/75] copy certutil.exe --- .github/workflows/ci-test-run.yml | 1 + .tests/ci-init-nanoserver.bat.example | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 9ab50358..827002f0 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -65,6 +65,7 @@ jobs: if: matrix.artifact == 'nanoserver' run: | echo f | xcopy /Y /Q /R "${{ github.workspace }}\.tests\ci-init-nanoserver.bat.example" "${{ github.workspace }}\.tests\ci-init.bat" + echo f | xcopy /Y /Q /R C:\Windows\System32\certutil.exe ${{ github.workspace }}\certutil.exe docker container run --rm -e PATH="C:\Python;C:\git\mingw64\bin;C:\Windows;C:\Windows\System32" -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat test-create: diff --git a/.tests/ci-init-nanoserver.bat.example b/.tests/ci-init-nanoserver.bat.example index 43cbee02..ebb0ee43 100644 --- a/.tests/ci-init-nanoserver.bat.example +++ b/.tests/ci-init-nanoserver.bat.example @@ -7,4 +7,6 @@ mkdir -p C:\git && cd C:\git curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" tar -xf "git.zip" +echo f | xcopy /Y /Q /R C:\app\certutil.exe C:\Python\certutil.exe + C:\git\mingw64\bin\git config --global --add safe.directory "*" From 58c5a93e31d5b89912bbc8c71dffb986dbbf299e Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 09:44:03 +0400 Subject: [PATCH 73/75] ci-test-run-nanoserver.bat --- .github/workflows/ci-test-run.yml | 4 +--- ...-nanoserver.bat.example => ci-test-run-nanoserver.bat} | 8 +++++++- _AutoinstallCreator/test_update.py | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) rename .tests/{ci-init-nanoserver.bat.example => ci-test-run-nanoserver.bat} (76%) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 827002f0..2c3853b9 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -64,9 +64,7 @@ jobs: - name: ci test-run (nanoserver) if: matrix.artifact == 'nanoserver' run: | - echo f | xcopy /Y /Q /R "${{ github.workspace }}\.tests\ci-init-nanoserver.bat.example" "${{ github.workspace }}\.tests\ci-init.bat" - echo f | xcopy /Y /Q /R C:\Windows\System32\certutil.exe ${{ github.workspace }}\certutil.exe - docker container run --rm -e PATH="C:\Python;C:\git\mingw64\bin;C:\Windows;C:\Windows\System32" -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run.bat + docker container run --rm -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run-nanoserver.bat test-create: needs: test diff --git a/.tests/ci-init-nanoserver.bat.example b/.tests/ci-test-run-nanoserver.bat similarity index 76% rename from .tests/ci-init-nanoserver.bat.example rename to .tests/ci-test-run-nanoserver.bat index ebb0ee43..298dbbcd 100644 --- a/.tests/ci-init-nanoserver.bat.example +++ b/.tests/ci-test-run-nanoserver.bat @@ -1,3 +1,5 @@ +@echo off + mkdir -p C:\Python && cd C:\Python curl --location "https://github.com/hemnstill/StandaloneTools/releases/download/python-3.12.1/build-msvc.tar.gz" --output "python.tar.gz" tar -xf "python.tar.gz" --strip-components 2 @@ -7,6 +9,10 @@ mkdir -p C:\git && cd C:\git curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" tar -xf "git.zip" -echo f | xcopy /Y /Q /R C:\app\certutil.exe C:\Python\certutil.exe +set PATH="%PATH%;C:\Python;C:\git\mingw64\bin" C:\git\mingw64\bin\git config --global --add safe.directory "*" + +"%~dp0..\.tools\busybox.exe" bash "%~dp0ci-test-run.sh" %* + +exit /b %errorlevel% diff --git a/_AutoinstallCreator/test_update.py b/_AutoinstallCreator/test_update.py index 43c2c8a6..c4ad3d52 100644 --- a/_AutoinstallCreator/test_update.py +++ b/_AutoinstallCreator/test_update.py @@ -86,6 +86,7 @@ def test_version_up_to_date(self): check=True) self.assertTrue(version_is_up_to_date(self.update_log_filepath, self.version_str)) + @unittest.skipIf(sys.platform.startswith('win') and not os.path.exists(r'C:\Windows\notepad.exe'), 'disable in nanoserver') def test_update_to_new_version(self): subprocess.run(busybox_exe_path_arg + [self.package_filepath, '--target', self.test_old_version], cwd=_self_tmp_path, @@ -115,5 +116,5 @@ def tearDown(self): {io_tools.read_text(self.old_update_log_filepath)}''') if os.path.isfile(self.update_log_filepath): - print(f'''old_update_log_filepath: + print(f'''update_log_filepath: {io_tools.read_text(self.update_log_filepath)}''') From 40e2ffd44afddaa74502bde3d588ea2f523ba8e0 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 09:46:34 +0400 Subject: [PATCH 74/75] set PATH --- .github/workflows/ci-test-run.yml | 2 +- .tests/ci-test-run-nanoserver.bat | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index 2c3853b9..bd265706 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -64,7 +64,7 @@ jobs: - name: ci test-run (nanoserver) if: matrix.artifact == 'nanoserver' run: | - docker container run --rm -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run-nanoserver.bat + docker container run --rm -e PATH="C:\Windows;C:\Windows\System32;C:\Python;C:\git\mingw64\bin" -v ${{ github.workspace }}:C:\app -w C:\app ${{ env.IMAGE_NAME }} C:\app\.tests\ci-test-run-nanoserver.bat test-create: needs: test diff --git a/.tests/ci-test-run-nanoserver.bat b/.tests/ci-test-run-nanoserver.bat index 298dbbcd..0419b769 100644 --- a/.tests/ci-test-run-nanoserver.bat +++ b/.tests/ci-test-run-nanoserver.bat @@ -9,8 +9,6 @@ mkdir -p C:\git && cd C:\git curl --location https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/MinGit-2.44.0-busybox-64-bit.zip --output "git.zip" tar -xf "git.zip" -set PATH="%PATH%;C:\Python;C:\git\mingw64\bin" - C:\git\mingw64\bin\git config --global --add safe.directory "*" "%~dp0..\.tools\busybox.exe" bash "%~dp0ci-test-run.sh" %* From 438bc337af0618373714f48ac9bac3b119a6d172 Mon Sep 17 00:00:00 2001 From: Reshetnikov_AS Date: Sat, 2 Mar 2024 09:54:56 +0400 Subject: [PATCH 75/75] enable linux, enable on push to master --- .github/workflows/ci-release.yml | 6 +++++- .github/workflows/ci-test-run.yml | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index a8217f2d..feb1a26a 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -1,6 +1,10 @@ name: ci release -on: [workflow_dispatch] +on: + push: + branches: + - master + workflow_dispatch: jobs: self-release: diff --git a/.github/workflows/ci-test-run.yml b/.github/workflows/ci-test-run.yml index bd265706..bf227359 100644 --- a/.github/workflows/ci-test-run.yml +++ b/.github/workflows/ci-test-run.yml @@ -1,6 +1,8 @@ name: ci build -on: [pull_request, workflow_dispatch] +on: + pull_request: + workflow_dispatch: jobs: test: @@ -11,13 +13,13 @@ jobs: strategy: matrix: include: -# - os: ubuntu-latest -# container: 'ubuntu:22.04' -# artifact: 'ubuntu' -# -# - os: ubuntu-latest -# container: 'alpine:3.15.0' -# artifact: 'alpine' + - os: ubuntu-latest + container: 'ubuntu:22.04' + artifact: 'ubuntu' + + - os: ubuntu-latest + container: 'alpine:3.15.0' + artifact: 'alpine' - os: windows-latest artifact: 'windows'