From b45cc0a13a20e88546cd7a536f09979edf8353a1 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sun, 15 Jan 2012 23:20:17 +0100 Subject: Support reading OF files from zip. Several devices require the original firmware to be able installing the bootloader. Most vendors distribute the firmware file in zip format. Extend reading the original firmware file to support reading the file from the zip directly instead of requiring the user to separately extract it. Change-Id: Ic4e89053456d8f7d6adc294f6657aceddbc354ba --- rbutil/rbutilqt/base/bootloaderinstallbase.cpp | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'rbutil/rbutilqt/base/bootloaderinstallbase.cpp') diff --git a/rbutil/rbutilqt/base/bootloaderinstallbase.cpp b/rbutil/rbutilqt/base/bootloaderinstallbase.cpp index 750e33bef8..7941f24309 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallbase.cpp +++ b/rbutil/rbutilqt/base/bootloaderinstallbase.cpp @@ -31,6 +31,7 @@ #include "bootloaderinstallmpio.h" #include "bootloaderinstallimx.h" #include "utils.h" +#include "ziputil.h" #if defined(Q_OS_MACX) #include @@ -320,3 +321,43 @@ void BootloaderInstallBase::setBlFile(QStringList sl) } } +bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile) +{ + bool found = false; + ZipUtil z(this); + // check if the file set is in zip format + if(z.open(of)) { + emit logItem(tr("Zip file format detected"), LOGINFO); + QStringList contents = z.files(); + qDebug() << "[BootloaderInstallBase] archive contains:" << contents; + for(int i = 0; i < blfile.size(); ++i) { + // strip any path, we don't know the structure in the zip + QString f = QFileInfo(blfile.at(i)).fileName(); + qDebug() << "[BootloaderInstallBase] searching archive for" << f; + int index = contents.indexOf(f); // FIXME: support files in folders + if(index >= 0) { + found = true; + emit logItem(tr("Extracting firmware %1 from archive") + .arg(f), LOGINFO); + // store in class temporary file + m_tempof.open(); + m_offile = m_tempof.fileName(); + m_tempof.close(); + if(!z.extractArchive(m_offile, contents.at(index))) { + emit logItem(tr("Error extracting firmware from archive"), LOGERROR); + found = false; + break; + } + } + } + if(!found) { + emit logItem(tr("Could not find firmware in archive"), LOGERROR); + } + + } + else { + m_offile = of; + found = true; + } + return found; +} -- cgit v1.2.3