From 7491e3df91223e79f46bd432033daccb6aa67f6d Mon Sep 17 00:00:00 2001 From: Chris Boesch Date: Thu, 5 Oct 2023 20:18:04 +0200 Subject: changed the patch files that we can also use them with busybox for testing in Woodpecker --- patches/frodo.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 patches/frodo.sh (limited to 'patches/frodo.sh') diff --git a/patches/frodo.sh b/patches/frodo.sh new file mode 100755 index 0000000..a92642a --- /dev/null +++ b/patches/frodo.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# "How do you pick up the threads of an old life? +# How do you go on, when in your heart you begin +# to understand... there is no going back? +# There are some things that time cannot mend. +# Some hurts that go too deep, that have taken hold." +# Frodo, The Return of the King +# +# +# This script shall repair the patches for the little +# broken programs using the old patches in this directory +# first, to heal them and then create new and better +# patches, with Gollum's help. +# +set -e + +# We check ourselves before we wreck ourselves. +if [ ! -f patches/frodo.sh ] +then + echo "But I must be run from the project root directory." + exit 1 +fi + +# Create directory of answers if it doesn't already exist. +mkdir -p answers + +# Cycle through all the little broken Zig applications. +i=0 +for broken in exercises/*.zig +do + ((i=i+1)) + + # Remove the dir and extension, rendering the True Name. + true_name=$(basename "$broken" .zig) + patch_name="patches/patches/$true_name.patch" + healed_name="answers/$true_name.zig" + cp "$broken" "$healed_name" + # echo "$patch_name" + + if [ -f "$patch_name" ] + then + # Apply the bandages to the wounds, grow new limbs, let + # new life spring into the broken bodies of the fallen. + echo Healing "$true_name"... + patch -i "$patch_name" "$healed_name" + + # Create new prescriptions... + echo Repairing "$patch_name"... + if [ "$true_name.patch" = "999_the_end.patch" ] + then + i=999 + fi + # with gollum's help! + ./patches/gollum.sh $i + else + echo Cannot repair "$true_name". No patch found. + fi +done + -- cgit v1.2.3-70-g09d2