Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions dumpyara.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,23 +169,33 @@ PARTITIONS=(system systemex system_ext system_other vendor cust odm odm_ext oem
# Extract the images
LOGI "Extracting partitions..."
for partition in "${PARTITIONS[@]}"; do
# Proceed only if the image from 'PARTITIONS' array exists
if [[ -f "${partition}".img ]]; then
if [[ -f "${partition}.img" ]]; then
LOGI "Processing '${partition}.img'..."
# Try to extract file through '7z'
${FSCK_EROFS} --extract="${partition}" "${partition}".img >> /dev/null 2>&1 || {
# Try to extract file through '7z'
7z -snld x "${partition}".img -y -o"${partition}"/ > /dev/null || {
LOGE "'${partition}' extraction via '7z' failed."

# Only abort if we're at the first occourence
if [[ "${partition}" == "${PARTITIONS[0]}" ]]; then
LOGF "Aborting dumping considering it's a crucial partition."
if ! ${FSCK_EROFS} --extract="${partition}" "${partition}.img" >/dev/null 2>&1; then
# Try to extract file through '7z'
if ! 7z -snld x "${partition}.img" -y -o"${partition}/" >/dev/null 2>&1; then
LOGW "'${partition}' extraction via 7z failed, trying F2FS..."

sudo mkdir -p "/mnt/${partition}" "./${partition}"

if sudo mount -t f2fs -o loop,ro "${partition}.img" "/mnt/${partition}" >/dev/null 2>&1; then
sudo cp -a "/mnt/${partition}/." "./${partition}/" >/dev/null 2>&1 && LOGI "Copied '${partition}' successfully."
sudo chown -R "$(id -u):$(id -g)" "./${partition}"
sudo umount "/mnt/${partition}" >/dev/null 2>&1
sudo rm -rf "/mnt/${partition}"
else
LOGE "'${partition}' extraction via F2FS mount failed."
if [[ "${partition}" == "${PARTITIONS[0]}" ]]; then
LOGF "Aborting dumping considering it's a crucial partition."
fi
continue
fi
}
}
fi
fi

# Clean-up
rm -f "${partition}".img
# Clean up
rm -f "${partition}.img"
fi
done

Expand Down