|
175 | 175 |
|
176 | 176 | echo "Extracting firmware on: $outdir" |
177 | 177 |
|
178 | | -for otherpartition in $OTHERPARTITIONS; do |
179 | | - filename=$(echo $otherpartition | cut -f 1 -d ":") |
180 | | - outname=$(echo $otherpartition | cut -f 2 -d ":") |
181 | | - if [[ $(7z l -ba "$romzip" | grep $filename) ]]; then |
182 | | - echo "$filename detected for $outname" |
183 | | - foundfiles=$(7z l -ba "$romzip" | gawk '{ print $NF }' | grep $filename) |
184 | | - 7z e -y "$romzip" $foundfiles 2>/dev/null >> $tmpdir/zip.log |
185 | | - outputs=$(ls *"$filename"*) |
186 | | - for output in $outputs; do |
187 | | - [[ ! -e "$outname".img ]] && mv $output "$outname".img |
188 | | - $simg2img "$outname".img "$outdir/$outname".img 2>/dev/null |
189 | | - if [[ ! -s "$outdir/$outname".img ]] && [ -f "$outname".img ]; then |
190 | | - mv "$outname".img "$outdir/$outname".img |
191 | | - fi |
192 | | - done |
| 178 | +# Extract firmware partitions |
| 179 | +for partition in ${OTHERPARTITIONS}; do |
| 180 | + # Set the names for the partition(s) |
| 181 | + IN=$(echo $partition | cut -f 1 -d ":") |
| 182 | + OUT=$(echo $partition | cut -f 2 -d ":") |
| 183 | + |
| 184 | + # Check if partition is present on archive |
| 185 | + if $(7z l -ba "$romzip" | grep -q $IN); then |
| 186 | + echo "[INFO] Extracting ${IN}..." |
| 187 | + |
| 188 | + # Extract to '${outdir}' |
| 189 | + 7zz x "${romzip}" "${IN}" -so > ${outdir}/${IN}.sparse |
| 190 | + |
| 191 | + # Convert from sparse to RAW image |
| 192 | + $simg2img "${outdir}/${IN}".sparse "${outdir}/${OUT}".img |
| 193 | + rm -rf "${outdir}/${IN}".sparse |
193 | 194 | fi |
194 | 195 | done |
195 | 196 |
|
|
0 commit comments