diff --git a/main.py b/main.py index 650d845..fa3fbc1 100755 --- a/main.py +++ b/main.py @@ -2,21 +2,23 @@ import subprocess import os import argparse +import sys def run_script(script_path, extra_args): if not os.path.exists(script_path): print(f"[ERROR] Script not found at {script_path}") exit(1) - command = ["sudo","bash", script_path] + extra_args + command = ["sudo", "bash", script_path] + extra_args print(f"[INFO] Running command: {' '.join(command)}") - result = subprocess.run(command) + # Pass the parent's stdout and stderr so that progress output shows in real time. + result = subprocess.run(command, stdout=sys.stdout, stderr=sys.stderr) if result.returncode != 0: print(f"[ERROR] Script exited with code {result.returncode}") exit(result.returncode) print("[SUCCESS] Script executed successfully.") def main(): - # Use os.path.realpath to get the actual path of this file regardless of symlinks + # Use os.path.realpath to get the actual path of this file regardless of symlinks. repo_root = os.path.dirname(os.path.realpath(__file__)) # Define available scripts along with their descriptions. @@ -100,9 +102,17 @@ def main(): print("[INFO] No extra parameters provided.") if not args.auto_confirm: - input("Press Enter to execute the script or Ctrl+C to cancel...") + try: + input("Press Enter to execute the script or Ctrl+C to cancel...") + except KeyboardInterrupt: + print("\n[ERROR] Execution aborted by user.") + exit(1) run_script(script_info["path"], args.extra) if __name__ == "__main__": - main() + try: + main() + except KeyboardInterrupt: + print("\n[ERROR] Execution aborted by user.") + exit(1) diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..19db333 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,2 @@ +pacman: + - pv \ No newline at end of file diff --git a/scripts/image/setup.sh b/scripts/image/setup.sh index afd6167..ac4035b 100644 --- a/scripts/image/setup.sh +++ b/scripts/image/setup.sh @@ -245,18 +245,28 @@ if [ -z "$image_checksum" ]; then done fi -if [[ -v image_checksum ]] - then - (info "Checking md5 checksum..." && echo "$image_checksum $image_path"| md5sum -c -) || - (info "Checking sha1 checksum..." && echo "$image_checksum $image_path"| sha1sum -c -) || - (info "Checking sha256 checksum..." && echo "$image_checksum $image_path"| sha256sum -c -) || - error "Verification failed. HINT: Force the download of the image." - else - warning "Verification is not possible. No checksum is defined." +if [[ -v image_checksum ]]; then + info "A checksum is defined for the image." + info "Checksums verify file integrity to ensure that the file was not corrupted during download." + info "The script will try verifying the integrity using MD5, then SHA1, and finally SHA256 if needed." + + info "Trying MD5 checksum verification..." + (info "Checking md5 checksum..." && echo "$image_checksum $image_path" | md5sum -c -) || + (warning "MD5 verification failed. This may indicate data corruption." && + info "Trying SHA1 checksum verification for a secondary integrity check..." && + info "Checking sha1 checksum..." && echo "$image_checksum $image_path" | sha1sum -c -) || + (warning "SHA1 verification failed. Attempting SHA256 verification for thoroughness." && + info "SHA256 provides a more robust check and is used as a final integrity measure." && + info "Checking sha256 checksum..." && echo "$image_checksum $image_path" | sha256sum -c -) || + error "Verification failed. HINT: Force the download of the image." +else + warning "No checksum is defined. Skipping checksum verification." fi -info "Verifying signature..." +info "Note: Checksums verify integrity but do not confirm authenticity." +info "Proceeding to signature verification, which ensures the file comes from a trusted source." signature_download_url="$download_url.sig" +info "Attempting to download the image signature from: $signature_download_url" info "Try to download image signature from $signature_download_url." if wget -q --method=HEAD "$signature_download_url"; then @@ -388,7 +398,7 @@ if [ "$transfer_image" = "y" ] elif [ "${image_path: -4}" = ".iso" ] then info "Transfering .iso file..." && - sudo dd if="$image_path" of="$device_path" bs="$OPTIMAL_BLOCKSIZE" conv=fsync status=progress && + pv "$image_path" | sudo dd of="$device_path" bs="$OPTIMAL_BLOCKSIZE" conv=fsync && sync || error elif [ "${image_path: -3}" = ".xz" ]