@@ -90,6 +90,7 @@ star="$toolsdir/$HOST/bin/star"
9090
9191romzip=" $( realpath $1 ) "
9292romzipext=" ${romzip##* .} "
93+ filename=" $( basename ${romzip%% .* } ) "
9394PARTITIONS=" super system vendor cust odm oem factory product xrom modem dtbo dtb boot recovery tz systemex oppo_product preload_common system_ext system_other 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 init_boot vendor_kernel_boot vendor_boot mi_ext boot-debug vendor_boot-debug hw_product product_h preas preavs"
9495EXT4PARTITIONS=" system vendor cust odm oem factory product xrom systemex oppo_product preload_common hw_product product_h preas preavs"
9596OTHERPARTITIONS=" tz.mbn:tz tz.img:tz modem.img:modem NON-HLOS:modem boot-verified.img:boot dtbo-verified.img:dtbo"
@@ -105,14 +106,52 @@ mkdir -p "$outdir"
105106cd $tmpdir
106107
107108MAGIC=$( head -c12 " $romzip " | tr -d ' \0' )
108- if [[ $MAGIC == " OPPOENCRYPT!" ]] || [[ " $romzipext " == " ozip" ]]; then
109- echo " ozip detected"
110- cp " $romzip " " $tmpdir /temp.ozip"
111- python3 $ozipdecrypt " $tmpdir /temp.ozip"
112- if [[ -d " $tmpdir /out" ]]; then
113- 7z a -r " $tmpdir /temp.zip" " $tmpdir /out/*"
109+
110+ # File is '.ozip'
111+ if [[ " ${MAGIC} " == " OPPOENCRYPT!" ]] || [[ " ${romzipext} " == " ozip" ]]; then
112+
113+ # Function to archive directories to a fake image.
114+ directory_archive () {
115+ # We probably have 'vendor/' extracted to a directory.
116+ 7z x " ${tmpdir} /$( basename ${romzip%% .* } ) .zip" -o" ${tmpdir} /ozip/" > /dev/null
117+
118+ # Set a variable for working directory
119+ WORKING_OZIP=${tmpdir} /ozip
120+
121+ # Convert all directories to 'images' (even though it's an archive)
122+ for image in recovery system vendor; do
123+ # Archive to a '.zip', first
124+ 7z a -r ${outdir} /${image} .zip ${WORKING_OZIP} /${image} /* > /dev/null
125+
126+ # Move '.zip' to .'img' to get recognized by dumper
127+ mv ${outdir} /${image} .zip ${outdir} /${image} .img
128+
129+ # Remove remaining directory
130+ rm -rf ${outdir} /${image} /
131+ done
132+
133+ # Move every image from 'ozip/' to '${outdir}'
134+ find " ${tmpdir} /ozip/." -name " *.img" -exec mv {} " ${outdir} " \;
135+
136+ # Delete extracted directory
137+ rm -rf " ${tmpdir} /ozip"
138+ }
139+
140+ # Copy over encrypted archive to our directory
141+ cp ${romzip} " ${tmpdir} "
142+
143+ # Start decrypting the archive
144+ echo " [INFO] Decrypting '.ozip' through 'oppo_ozip_decrypt'..."
145+ python3 $ozipdecrypt " ${tmpdir} /${filename} .ozip" > /dev/null
146+ rm -rf " ${tmpdir} /${filename} .ozip" ${tmpdir} /out ${tmpdir} /tmp
147+
148+ # Run extractor over decrypted archive
149+ if $( 7z l " ${tmpdir} /${filename} .zip" | grep -q system.img) ; then
150+ " $LOCALDIR /extractor.sh" " ${tmpdir} /${filename} .zip" " $outdir "
151+ else
152+ directory_archive
114153 fi
115- " $LOCALDIR /extractor.sh " " $ tmpdir/temp .zip" " $outdir "
154+ rm -rf " ${ tmpdir} / ${filename} .zip" > /dev/null
116155 exit
117156fi
118157
0 commit comments