-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapply_patches.sh
More file actions
executable file
·42 lines (32 loc) · 1008 Bytes
/
apply_patches.sh
File metadata and controls
executable file
·42 lines (32 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
# Enable error handling and unset variable checking
set -eu
set -o pipefail
# Check if $1 (patch directory) is provided
if [ -z "${1-}" ]; then
echo "Please provide a value for patch directory as the first argument."
exit 1
fi
PATCH_DIR="$1"
# Check if version-specific patches directory exists
if [ ! -d "$PATCH_DIR" ]; then
echo "Patches directory '$PATCH_DIR' does not exist."
exit 1
fi
# Create an array to hold the patches in sorted order
declare -a patch_files
echo "Applying patches from ${PATCH_DIR}" now
# Read the patch files into the array
while IFS= read -r -d $'\0' file; do
patch_files+=("$file")
done < <(find "$PATCH_DIR" -name "*.patch" -print0 | sort -zV)
echo "Found ${#patch_files[@]} patches, applying now"
# Iterate through sorted patch files
for patch_file in "${patch_files[@]}"; do
echo "Applying $patch_file"
git apply "$patch_file" || {
echo "Failed to apply $patch_file"
exit 1
}
done
echo "All patches applied successfully."