@@ -229,21 +229,40 @@ if [[ "${romzip}" == *.@(img|bin) ]] && [ "$(head -c6 "${romzip}")" == "RKFWf" ]
229229 exit 0
230230fi
231231
232- if [[ $( 7z l -ba " ${romzip} " | grep -i aml) ]]; then
233- echo " aml detected"
234- cp " ${romzip} " " $tmpdir "
235- romzip=" $tmpdir /$( basename " ${romzip} " ) "
236- 7z e -y " ${romzip} " >> " $tmpdir " /zip.log
237- $aml_extract $( find . -type f -name " *aml*.img" )
232+ if 7z l -ba " ${romzip} " | grep -q aml; then
233+ echo " [INFO] Amlogic package detected"
234+ cp " ${romzip} " " ${tmpdir} "
235+
236+ romzip=" ${tmpdir} /$( basename ${romzip} ) "
237+ if [[ " $( basename ${romzip} ) " == * " .tar.bz2" ]]; then
238+ tar -xvjf " ${romzip} " > /dev/null
239+ else
240+ 7z e -y " ${romzip} " >> " $tmpdir " /zip.log
241+ fi
242+
243+ # Extract through 'aml_extract'
244+ echo " [IFNO] Extracting through 'aml-upgrade-package-extract'..."
245+ $aml_extract $( find . -type f -name " *aml*.img" ) || {
246+ echo " [INFO] Extraction failed!"
247+ exit 1
248+ }
249+
250+ # Replace partitions' extension to '.img'
238251 rename ' s/.PARTITION$/.img/' * .PARTITION
239252 rename ' s/_aml_dtb.img$/dtb.img/' * .img
240253 rename ' s/_a.img/.img/' * .img
241- if [[ -f super.img ]]; then
254+
255+ # Generate a 'super.img'
256+ [[ -f super.img ]] && \
242257 superimage
243- fi
244- for partition in $PARTITIONS ; do
245- [[ -e " $tmpdir /$partition .img" ]] && mv " $tmpdir /$partition .img" " ${outdir} /$partition .img"
258+
259+ # Move to output directory
260+ for p in $PARTITIONS ; do
261+ [[ -e " $tmpdir /$p .img" ]] && \
262+ mv " $tmpdir /$p .img" " ${outdir} /$p .img"
246263 done
264+
265+ # Clean-up
247266 rm -rf " $tmpdir "
248267 exit 0
249268fi
0 commit comments