Merge "[patch] AArch64: reclass system arch tweaks"
[fuel.git] / mcp / patches / patch.sh
1 #!/bin/bash -e
2 ##############################################################################
3 # Copyright (c) 2017 Mirantis Inc., Enea AB and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 CI_DEBUG=${CI_DEBUG:-0}; [[ "${CI_DEBUG}" =~ (false|0) ]] || set -x
11
12 if [ -r "$1" ]; then
13   while IFS=': ' read -r p_dest p_file; do
14     if ! patch --dry-run -Rd "${p_dest}" -r - -s -p1 < \
15       "/root/fuel/mcp/patches/${p_file}" > /dev/null; then
16         patch -d "${p_dest}" -p1 < "/root/fuel/mcp/patches/${p_file}"
17     fi
18   done < <(grep -vE '^#' "${1}" | grep -E "^.*${2}.*: ")
19 fi