Skip to content

Commit e29a124

Browse files
committed
Update
1 parent 3edd178 commit e29a124

2 files changed

Lines changed: 49 additions & 23 deletions

File tree

app/src/main/assets/home/bin/listsuper

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,31 @@ echo "listsuper path/super.img"
55
exit 1
66
fi
77

8-
if [[ "$(lpdump "$1" | grep -m1 'Header flags:' | awk '{print $3}')" == 'virtual_ab_device' ]];then
9-
slog typeheh 'VAB'
8+
# config
9+
config_super="$(lpdump "$1")"
10+
11+
(
12+
# data
13+
slog first_sector_super "$(awk '/First sector:/ { print ($3 * 512); exit }' <<< "$config_super")"
14+
15+
slog first_sector_size_super "$(awk '/First sector:/ { print ($3 * 1024); exit }' <<< "$config_super")"
16+
17+
slog typeheh "$(awk '/Header flags:/ && $3=="virtual_ab_device"{print "VAB"; exit} /Group:/ && $2~/_b$/{b=1} END{print b?"AB":"A"}' <<< "$config_super")"
18+
19+
slog super_sizedj "$(awk '/Size:/ { print $2/(1024*1024*1024) }' <<< "$config_super")"
20+
21+
super_size_a="$(awk '/Group table:/ {f=1; next} f && /Maximum size:/ {if (++c==2) {print $3*2; exit}}' <<< "$config_super")"
22+
23+
if [ "$super_size_a" -gt "$(glog super_sizedj)" ]; then
24+
slog check_super_type_ab 0
1025
else
11-
[[ "$(lpdump "$1" | grep 'Group:' | grep -c '_b$')" == 0 ]] && slog typeheh 'A' || slog typeheh 'AB'
26+
slog check_super_type_ab 1
1227
fi
1328

14-
slog super_sizedj `echo "scale=1; $(lpdump "$1" | grep -A 5 'Block device table:' | grep 'Size:' | awk '{print $2}') / (1024*1024*1024)" | bc -l`
15-
slog super_group "$(lpdump "$1" | grep -m1 'Group:' | awk '{print $2}' | sed -e 's|_a||' -e 's|_b||')"
29+
slog super_group "$(awk '/Group:/ {sub(/_[ab]$/,"",$2); print $2; exit}' <<< "$config_super")"
30+
) &
1631

17-
lpdump "$1" | awk '/super:/ {
32+
echo "$config_super" | awk '/super:/ {
1833
start = $2
1934
gsub(":", "", $4)
2035
end = $4

app/src/main/assets/home/bin/repack_super

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/data/data/com.tool.tree/files/home/bin/bash
22
#kakathic
33

4+
source language
5+
46
show_help() {
57
echo "Usage: repack_super -i <input> -m ''file1 file2'' -g <group> -s <size-gb> -f [raw, sparse] -t [A, AB, VAB]"
68
echo
@@ -18,7 +20,7 @@ show_help() {
1820
}
1921

2022
INPUT=""; MIMGPA=""; SUPGRUP=""; SAIZESUP="";
21-
DANGIMG=""; TYPEIMG="";
23+
DANGIMG=""; TYPEIMG=""; ml1=""; ml2="";
2224
if [[ $# -eq 0 || "$1" != -* ]]; then
2325
show_help
2426
fi
@@ -38,52 +40,61 @@ while getopts ":i:m:g:s:f:t:h" opt; do
3840
done
3941

4042
if [[ -z "$INPUT" || -z "$MIMGPA" ]]; then
41-
echo "Lack of value" >&2
42-
show_help
43+
echo "Lack of value:
44+
-i ${INPUT:-???}
45+
-m ${MIMGPA:-???}" >&2
4346
fi
4447

4548
[[ -z "$SUPGRUP" ]] && SUPGRUP='qti_dynamic_partitions'
4649
[[ -z "$SAIZESUP" ]] && SAIZESUP='8.5'
4750
[[ -z "$DANGIMG" ]] && DANGIMG='raw'
4851
[[ -z "$TYPEIMG" ]] && TYPEIMG='A'
4952

50-
source language
53+
first_sector_size="$(glog first_sector_size_super 2097152)"
54+
first_sector="$(glog first_sector_super 1048576)"
55+
5156
super_sizek="$(echo "$SAIZESUP * 1024 * 1024 * 1024" | bc -l | cut -d. -f1)"
5257
echo "${sizes_text}: ${SAIZESUP} GB ➠ ${super_sizek} bytes"
5358
echo
5459

5560
argvs="--super-name super --metadata-size 65536 "
5661
cd "$INPUT"
5762

58-
if [ $TYPEIMG = "A" ];then
59-
argvs+="--metadata-slots 2 --block-size 4096 --device super:${super_sizek} --group ${SUPGRUP}:${super_sizek} "
63+
if [ "$TYPEIMG" == "A" ]; then
64+
argvs+="--metadata-slots 2 --device super:${super_sizek}:$first_sector --group ${SUPGRUP}:${super_sizek} "
6065
fi
6166

6267
for i in $MIMGPA; do
63-
ml1=''; ml2='';
64-
i1=$(echo "$i" | sed 's/.img//g')
65-
i2=$(echo "$i" | sed -e 's/_a.img//g' -e 's/_b.img//g' -e 's/.img//g')
68+
echo "$i" | grep -q "-cow" && continue
69+
i1=$(echo "$i" | sed 's/.img$//')
70+
i2=$(echo "$i" | sed -e 's/_a.img$//' -e 's/_b.img$//' -e 's/.img$//')
6671
info=$(checktype "$INPUT/$i1.img")
6772
p_size=$(stat -c %s "$INPUT/$i1.img")
68-
[ $info == "sparse" ] && simg2img "$INPUT/$i1.img"
69-
[ $TYPEIMG = "A" ] && argvs+="--partition ${i2}:readonly:$p_size:${SUPGRUP} --image ${i2}=$i1.img "
70-
if [ $TYPEIMG == "AB" ] || [ $TYPEIMG == "VAB" ];then
73+
#p_size=$(( ($(stat -c %s "$INPUT/$i1.img") + 4095) / 4096 * 4096 ))
74+
[ "$info" == "sparse" ] && simg2img "$INPUT/$i1.img"
75+
[ "$TYPEIMG" == "A" ] && argvs+="--partition ${i2}:readonly:$p_size:${SUPGRUP} --image ${i2}=$i1.img "
76+
if [ "$TYPEIMG" == "AB" ] || [ "$TYPEIMG" == "VAB" ]; then
7177
ml1+="--partition ${i2}_a:none:$p_size:${SUPGRUP}_a --image ${i2}_a=$i1.img "
7278
ml2+="--partition ${i2}_b:none:0:${SUPGRUP}_b "
7379
fi
7480
done
7581

76-
if [ $TYPEIMG = "AB" ] || [ $TYPEIMG = "VAB" ];then
77-
argvs+="--metadata-slots 3 --device super:${super_sizek} --group ${SUPGRUP}_a:${super_sizek} ${ml1} --group ${SUPGRUP}_b:${super_sizek} ${ml2} "
82+
if [ "$TYPEIMG" == "AB" ] || [ "$TYPEIMG" == "VAB" ]; then
83+
if [ "$TYPEIMG" == "AB" ] && [ "$(glog check_super_type_ab)" == 1 ]; then
84+
half_size=$((super_sizek / 2 - first_sector_size * 2))
85+
else
86+
half_size=$((super_sizek - first_sector_size))
87+
fi
88+
argvs+="--metadata-slots 3 --device super:${super_sizek}:$first_sector --group ${SUPGRUP}_a:${half_size} ${ml1} --group ${SUPGRUP}_b:${half_size} ${ml2} "
7889
fi
79-
[ $TYPEIMG = "VAB" ] && argvs+="--virtual-ab "
80-
[ $DANGIMG = "sparse" ] && argvs+="--sparse "
90+
[ "$TYPEIMG" == "VAB" ] && argvs+="--virtual-ab "
91+
[ "$DANGIMG" == "sparse" ] && argvs+="--sparse "
8192

8293
mkdir -p out
8394
echo "lpmake ${argvs}-F --output $INPUT/out/super.img" | sed -z 's| --|\n--|g'
8495
lpmake ${argvs} -F --output out/super.img 2>$TMP/super_log.log
8596

86-
if [ $? == 1 ];then
97+
if [ $? == 1 ]; then
8798
killtree "\n$supers_text_1" "$INPUT/out/super.img"
8899
else
89100
echo -e "\n$supers_text_2"

0 commit comments

Comments
 (0)