mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
- update: allow ofgwrite to flash another partition
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -620,20 +620,83 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||
else if (fileType == 'Z')
|
||||
{
|
||||
showGlobalStatus(100);
|
||||
ShowHint(LOCALE_MESSAGEBOX_INFO, "Start ofgwrite");
|
||||
|
||||
// get active partition
|
||||
char c[2] = {0};
|
||||
FILE *f;
|
||||
f = fopen("/sys/firmware/devicetree/base/chosen/kerneldev", "r");
|
||||
if (f)
|
||||
{
|
||||
if (fseek(f, -2, SEEK_END) == 0)
|
||||
{
|
||||
c[0] = fgetc(f);
|
||||
printf("[update] Current partition: %s\n", c);
|
||||
}
|
||||
}
|
||||
|
||||
// select partition
|
||||
int selected = 0;
|
||||
CMenuSelectorTarget *selector = new CMenuSelectorTarget(&selected);
|
||||
|
||||
CMenuWidget m(LOCALE_FLASHUPDATE_CHOOSE_PARTITION, NEUTRINO_ICON_SETTINGS);
|
||||
m.addItem(GenericMenuSeparator);
|
||||
CMenuForwarder *mf;
|
||||
|
||||
for (int i = 1; i < 4+1; i++)
|
||||
{
|
||||
bool active = !strcmp(c, to_string(i).c_str());
|
||||
std::string m_title = "Partition " + to_string(i);
|
||||
mf = new CMenuForwarder(m_title, true, NULL, selector, to_string(i).c_str(), CRCInput::convertDigitToKey(i));
|
||||
mf->iconName_Info_right = active ? NEUTRINO_ICON_CHECKMARK : NULL;
|
||||
m.addItem(mf, active);
|
||||
}
|
||||
|
||||
m.enableSaveScreen(true);
|
||||
m.exec(NULL, "");
|
||||
|
||||
delete selector;
|
||||
|
||||
printf("[update] Flash into partition %d\n", selected);
|
||||
|
||||
int restart = CMsgBox::mbNo;
|
||||
|
||||
std::string ofgwrite_options("");
|
||||
if (selected > 0 && strcmp(c, to_string(selected).c_str()))
|
||||
{
|
||||
// align ofgwrite options
|
||||
ofgwrite_options = "-m" + to_string(selected);
|
||||
printf("[update] ofgwrite_options: %s\n", ofgwrite_options.c_str());
|
||||
|
||||
// start selected partition?
|
||||
restart = ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_SELECTED_PARTITION, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE);
|
||||
if (restart == CMsgBox::mbrYes)
|
||||
{
|
||||
std::string startup_new = "/boot/STARTUP_" + to_string(selected);
|
||||
printf("[update] Start selected partition %d (%s)\n", selected, startup_new.c_str());
|
||||
#ifndef DRYRUN
|
||||
CFileHelpers fh;
|
||||
fh.copyFile(startup_new.c_str(), "/boot/STARTUP");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_OFGWRITE);
|
||||
hide();
|
||||
|
||||
const char ofgwrite_tgz[] = "/bin/ofgwrite_tgz";
|
||||
printf("[update] calling %s %s %s\n", ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str() );
|
||||
printf("[update] calling %s %s %s %s\n", ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
|
||||
#ifndef DRYRUN
|
||||
my_system(3, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str());
|
||||
#endif
|
||||
my_system(4, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
|
||||
|
||||
/*
|
||||
ofgwrite is killing Neutrino.
|
||||
So we stay here and wait for our end. This avoids osd flickering.
|
||||
TODO: fix osd-flickering
|
||||
Neutrino is clearing framebuffer, so ofgwrite's gui is cleared too.
|
||||
*/
|
||||
while (true)
|
||||
sleep(1);
|
||||
|
||||
if (restart == CMsgBox::mbrYes)
|
||||
CNeutrinoApp::getInstance()->exec(NULL, "reboot");
|
||||
#endif
|
||||
return menu_return::RETURN_EXIT_ALL;
|
||||
}
|
||||
#endif
|
||||
else // not image, install
|
||||
|
Reference in New Issue
Block a user