Skip to content

Commit 3a56f23

Browse files
chore(dumpyara.sh) run 'shellcheck'
Change-Id: I6df551d4a217cb24a0a708bde8e1d1a775148b7a
1 parent 78996f2 commit 3a56f23

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

dumpyara.sh

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[[ $# = 0 ]] && echo "No Input" && exit 1
44

5-
OS=`uname`
5+
OS=$(uname)
66
if [ "$OS" = 'Darwin' ]; then
77
export LC_CTYPE=C
88
fi
@@ -37,13 +37,13 @@ fi
3737
if echo "$1" | grep -e '^\(https\?\|ftp\)://.*$' > /dev/null; then
3838
# 1DRV URL DIRECT LINK IMPLEMENTATION
3939
if echo "$1" | grep -e '1drv.ms' > /dev/null; then
40-
URL=`curl -I "$1" -s | grep location | sed -e "s/redir/download/g" | sed -e "s/location: //g"`
40+
URL=$(curl -I "$1" -s | grep location | sed -e "s/redir/download/g" | sed -e "s/location: //g")
4141
else
4242
URL=$1
4343
fi
4444
cd "$PROJECT_DIR"/input || exit
4545
{ type -p aria2c > /dev/null 2>&1 && printf "Downloading File...\n" && aria2c -x16 -j"$(nproc)" "${URL}"; } || { printf "Downloading File...\n" && wget -q --content-disposition --show-progress --progress=bar:force "${URL}" || exit 1; }
46-
if [[ ! -f "$(echo ${URL##*/} | inline-detox)" ]]; then
46+
if [[ ! -f "$(echo "${URL##*/}" | inline-detox)" ]]; then
4747
URL=$(wget --server-response --spider "${URL}" 2>&1 | awk -F"filename=" '{print $2}')
4848
fi
4949
detox "${URL##*/}"
@@ -53,8 +53,8 @@ else
5353
fi
5454

5555
ORG=AndroidDumps #your GitHub org name
56-
FILE=$(echo ${URL##*/} | inline-detox)
57-
EXTENSION=$(echo ${URL##*.} | inline-detox)
56+
FILE=$(echo "${URL##*/}" | inline-detox)
57+
EXTENSION=$(echo "${URL##*.}" | inline-detox)
5858
UNZIP_DIR=${FILE/.$EXTENSION/}
5959
PARTITIONS="system systemex system_ext system_other vendor cust odm odm_ext oem factory product modem xrom oppo_product opproduct reserve india my_preload my_odm my_stock my_operator my_country my_product my_company my_engineering my_heytap my_custom my_manifest my_carrier my_region my_bigball my_version special_preload vendor_dlkm odm_dlkm system_dlkm mi_ext"
6060

@@ -68,7 +68,7 @@ fi
6868

6969
# clone other repo's
7070
if [[ -d "$PROJECT_DIR/Firmware_extractor" ]]; then
71-
git -C "$PROJECT_DIR"/Firmware_extractor pull --recurse-submodules
71+
git -C "$PROJECT_DIR"/Firmware_extractor pull --recurse-submodules --rebase
7272
else
7373
git clone -q --recurse-submodules https://github.com/AndroidDumps/Firmware_extractor "$PROJECT_DIR"/Firmware_extractor
7474
fi
@@ -108,7 +108,7 @@ if [[ -f "$PROJECT_DIR"/working/"${UNZIP_DIR}"/boot.img ]]; then
108108
rm -rf "${OUTPUT}/dtb/00_kernel"
109109

110110
## Check whether device-tree blobs were extracted or not
111-
if [ "$(find ${OUTPUT_DTB} -name "*.dtb")" ]; then
111+
if [ "$(find "${OUTPUT_DTB}" -name "*.dtb")" ]; then
112112
for dtb in $(find "${OUTPUT_DTB}" -type f); do
113113
dtc -q -I dtb -O dts "${dtb}" >> "${OUTPUT}/dts/$(basename "${dtb}" | sed 's/\.dtb/.dts/')"
114114
done
@@ -236,7 +236,7 @@ fi
236236
cd "$PROJECT_DIR"/working/"${UNZIP_DIR}" || exit
237237
for p in $PARTITIONS; do
238238
# Try to extract images via fsck.erofs
239-
if [ -f $p.img ] && [ $p != "modem" ]; then
239+
if [ -f "$p".img ] && [ "$p" != "modem" ]; then
240240
echo "Trying to extract $p partition via fsck.erofs."
241241
"$PROJECT_DIR"/Firmware_extractor/tools/fsck.erofs --extract="$p" "$p".img
242242
# Deletes images if they were correctly extracted via fsck.erofs
@@ -247,8 +247,7 @@ for p in $PARTITIONS; do
247247
if [[ -e "$p.img" ]]; then
248248
mkdir "$p" 2> /dev/null || rm -rf "${p:?}"/*
249249
echo "Extraction via fsck.erofs failed, extracting $p partition via 7z"
250-
7z x "$p".img -y -o"$p"/ > /dev/null 2>&1
251-
if [ $? -eq 0 ]; then
250+
if 7z x "$p".img -y -o"$p"/ > /dev/null 2>&1; then
252251
rm "$p".img > /dev/null 2>&1
253252
else
254253
echo "Couldn't extract $p partition via 7z. Using mount loop"
@@ -257,8 +256,7 @@ for p in $PARTITIONS; do
257256
$sudo_cmd cp -rf "${p}/"* "${p}_"
258257
$sudo_cmd umount "${p}"
259258
$sudo_cmd cp -rf "${p}_/"* "${p}"
260-
$sudo_cmd rm -rf "${p}_"
261-
if [ $? -eq 0 ]; then
259+
if $sudo_cmd rm -rf "${p}_"; then
262260
rm -fv "$p".img > /dev/null 2>&1
263261
else
264262
echo "Couldn't extract $p partition. It might use an unsupported filesystem."
@@ -283,9 +281,6 @@ if [ -e "$PROJECT_DIR"/working/"${UNZIP_DIR}"/vendor/build.prop ]; then
283281
fi
284282
sort -u -o "$PROJECT_DIR"/working/"${UNZIP_DIR}"/board-info.txt "$PROJECT_DIR"/working/"${UNZIP_DIR}"/board-info.txt
285283

286-
# set variables
287-
ls system/build*.prop 2> /dev/null || ls system/system/build*.prop 2> /dev/null || { echo "No system build*.prop found, pushing cancelled!" && exit; }
288-
289284
# 'flavor' property (e.g. caiman-user)
290285
flavor=$(rg -m1 -INoP --no-messages "(?<=^ro.build.flavor=).*" {vendor,system,system/system}/build.prop)
291286
[[ -z ${flavor} ]] && flavor=$(rg -m1 -INoP --no-messages "(?<=^ro.vendor.build.flavor=).*" vendor/build*.prop)
@@ -468,7 +463,7 @@ chmod -R u+rwX ./* #ensure final permissions
468463
find "$PROJECT_DIR"/working/"${UNZIP_DIR}" -type f -printf '%P\n' | sort | grep -v ".git/" > "$PROJECT_DIR"/working/"${UNZIP_DIR}"/all_files.txt
469464

470465
if [[ -n $GIT_OAUTH_TOKEN ]]; then
471-
GITPUSH=(git push https://"$GIT_OAUTH_TOKEN"@github.com/$ORG/"${repo,,}".git "$branch")
466+
GITPUSH=(git push https://"$GIT_OAUTH_TOKEN"@github.com/"$ORG"/"${repo,,}".git "$branch")
472467
curl --silent --fail "https://raw.githubusercontent.com/$ORG/$repo/$branch/all_files.txt" 2> /dev/null && echo "Firmware already dumped!" && exit 1
473468
git init
474469
if [[ -z "$(git config --get user.email)" ]]; then

0 commit comments

Comments
 (0)