#!/bin/bash

set -e

if [[ -f ./patch_flag ]];then
    echo "runtime patched!"
    exit 0
fi

tar -zxvf runtime-1.11.1.tar.gz
cp -fr ./runtime-1.11.1/* ./
rm -rf ./runtime-1.11.1
cat ./series.conf | while read line
do
    if [[ $line == '' || $line =~ ^\s*# ]]; then
        continue
    fi
    echo "====patch $line======"
    patch -p1 -F1 -s < ./patches/$line
done

touch ./patch_flag
