forked from Pixel-Props/build.prop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_images.sh
84 lines (66 loc) · 2.52 KB
/
extract_images.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Using util_functions.sh
[ -f "util_functions.sh" ] && . ./util_functions.sh || { echo "util_functions.sh not found" && exit 1; }
# Extract the factory images
print_message "Extracting factory images..." info
for file in ./*; do # List directory ./*
if [ -f "$file" ]; then # Check if it is a file
if [ "${file: -4}" == ".zip" ]; then # Check if it is a zip file
print_message "Processing \"${file##*/}\"" debug
# Time the extraction
extraction_start=$(date +%s)
# Extract images
7z e $file -o"extracted_factoryimages" "*/*.zip" -r -y &>/dev/null
rm $file
# Time the extraction
extraction_end=$(date +%s)
extraction_runtime=$((extraction_end - extraction_start))
# Print the time
print_message "Extraction time: $extraction_runtime seconds" info
fi
fi
done
if [ -d "extracted_factoryimages" ]; then
print_message "\nExtracting images from \"extracted_factoryimages\"..." info
for file in ./extracted_factoryimages/*; do # List directory ./extracted_factoryimages/*
if [ -f "$file" ]; then # Check if it is a file
if [ "${file: -4}" == ".zip" ]; then # Check if it is a zip file
filename="${file##*/}" # Remove the path
basename="${filename%.*}" # Remove the extension
print_message "Processing \"$filename\"" debug
# Time the extraction
extraction_start=$(date +%s)
# Extract images
7z x "$file" -o"$basename" -y &>/dev/null
# Time the extraction
extraction_end=$(date +%s)
extraction_runtime=$((extraction_end - extraction_start))
# Print the time
print_message "Extraction time: $extraction_runtime seconds" info
fi
fi
done
rm -rf "extracted_factoryimages"
fi
# Extract the images directories
print_message "\nExtracting images directories..." info
for dir in ./*; do # List directory ./*
if [ -d "$dir" ]; then # Check if it is a directory
dir=${dir%*/} # Remove last /
print_message "Processing \"${dir##*/}\"" debug
# Time the extraction
extraction_start=$(date +%s)
# Extracting each image
extract_image "$dir" "product"
extract_image "$dir" "vendor"
extract_image "$dir" "system"
extract_image "$dir" "system_ext"
# Time the extraction
extraction_end=$(date +%s)
extraction_runtime=$((extraction_end - extraction_start))
# Print the extraction time
print_message "Extraction time: $extraction_runtime seconds" info
# Build system.prop
print_message "Building system.prop..." info
./build_system_prop.sh "$dir"
fi
done