mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-28 16:01:20 +02:00
- update: cleanup and unify debug output
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -113,7 +113,7 @@ CFlashUpdate::CFlashUpdate()
|
|||||||
sysfs = CMTDInfo::getInstance()->findMTDsystem();
|
sysfs = CMTDInfo::getInstance()->findMTDsystem();
|
||||||
if (sysfs.empty())
|
if (sysfs.empty())
|
||||||
sysfs = MTD_DEVICE_OF_UPDATE_PART;
|
sysfs = MTD_DEVICE_OF_UPDATE_PART;
|
||||||
printf("Mtd partition to update: %s\n", sysfs.c_str());
|
dprintf(DEBUG_NORMAL, "[update] mtd partition to update: %s\n", sysfs.c_str());
|
||||||
notify = true;
|
notify = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,12 +153,10 @@ bool CFlashUpdate::checkOnlineVersion()
|
|||||||
|
|
||||||
CConfigFile _configfile('\t');
|
CConfigFile _configfile('\t');
|
||||||
const char * versionString = (_configfile.loadConfig( "/.version")) ? (_configfile.getString( "version", "????????????????").c_str()) : "????????????????";
|
const char * versionString = (_configfile.loadConfig( "/.version")) ? (_configfile.getString( "version", "????????????????").c_str()) : "????????????????";
|
||||||
#ifdef DEBUG
|
dprintf(DEBUG_NORMAL, "[update] file %s\n", g_settings.softupdate_url_file.c_str());
|
||||||
printf("[update] file %s\n", g_settings.softupdate_url_file.c_str());
|
|
||||||
#endif
|
|
||||||
CFlashVersionInfo curInfo(versionString);
|
CFlashVersionInfo curInfo(versionString);
|
||||||
curVer = curInfo.getVersion();
|
curVer = curInfo.getVersion();
|
||||||
printf("current flash-version: %s (%d) date %s (%ld)\n", versionString, curInfo.getVersion(), curInfo.getDate(), curInfo.getDateTime());
|
dprintf(DEBUG_NORMAL, "[update] current flash-version: %s (%d) date %s (%ld)\n", versionString, curInfo.getVersion(), curInfo.getDate(), curInfo.getDateTime());
|
||||||
|
|
||||||
std::ifstream urlFile(g_settings.softupdate_url_file.c_str());
|
std::ifstream urlFile(g_settings.softupdate_url_file.c_str());
|
||||||
if (urlFile >> url) {
|
if (urlFile >> url) {
|
||||||
@@ -171,7 +169,7 @@ bool CFlashUpdate::checkOnlineVersion()
|
|||||||
endpos = url.find('/', startpos);
|
endpos = url.find('/', startpos);
|
||||||
host = url.substr(startpos, endpos - startpos);
|
host = url.substr(startpos, endpos - startpos);
|
||||||
}
|
}
|
||||||
printf("[update] host %s\n", host.c_str());
|
dprintf(DEBUG_NORMAL, "[update] host %s\n", host.c_str());
|
||||||
if (host.empty() || (pinghost(host) != 1))
|
if (host.empty() || (pinghost(host) != 1))
|
||||||
return false;
|
return false;
|
||||||
if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20)) {
|
if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20)) {
|
||||||
@@ -180,12 +178,10 @@ bool CFlashUpdate::checkOnlineVersion()
|
|||||||
std::getline(in, name);
|
std::getline(in, name);
|
||||||
CFlashVersionInfo versionInfo(version);
|
CFlashVersionInfo versionInfo(version);
|
||||||
newVer = versionInfo.getVersion();
|
newVer = versionInfo.getVersion();
|
||||||
#ifdef DEBUG
|
dprintf(DEBUG_NORMAL, "[update] url %s version %s (%d) timestamp %s (%ld) md5 %s name %s\n", url.c_str(), version.c_str(), newVer, versionInfo.getDate(), versionInfo.getDateTime(), md5.c_str(), name.c_str());
|
||||||
printf("[update] url %s version %s (%d) timestamp %s (%ld) md5 %s name %s\n", url.c_str(), version.c_str(), newVer, versionInfo.getDate(), versionInfo.getDateTime(), md5.c_str(), name.c_str());
|
|
||||||
#endif
|
|
||||||
if(versionInfo.snapshot <= '2' && (newVer > curVer || versionInfo.getDateTime() > curInfo.getDateTime())) {
|
if(versionInfo.snapshot <= '2' && (newVer > curVer || versionInfo.getDateTime() > curInfo.getDateTime())) {
|
||||||
newfound = true;
|
newfound = true;
|
||||||
printf("[update] found new image\n");
|
dprintf(DEBUG_NORMAL, "[update] found new image\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,7 +190,6 @@ bool CFlashUpdate::checkOnlineVersion()
|
|||||||
return newfound;
|
return newfound;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define DEBUG
|
|
||||||
bool CFlashUpdate::selectHttpImage(void)
|
bool CFlashUpdate::selectHttpImage(void)
|
||||||
{
|
{
|
||||||
CHTTPTool httpTool;
|
CHTTPTool httpTool;
|
||||||
@@ -213,7 +208,7 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
versionString = _configfile.getString("version", "????????????????");
|
versionString = _configfile.getString("version", "????????????????");
|
||||||
|
|
||||||
CFlashVersionInfo curInfo(versionString.c_str());
|
CFlashVersionInfo curInfo(versionString.c_str());
|
||||||
printf("current flash-version: %s (%d) date %s (%ld)\n", versionString.c_str(), curInfo.getVersion(), curInfo.getDate(), curInfo.getDateTime());
|
dprintf(DEBUG_NORMAL, "[update] current flash-version: %s (%d) date %s (%ld)\n", versionString.c_str(), curInfo.getVersion(), curInfo.getDate(), curInfo.getDateTime());
|
||||||
curVer = curInfo.getVersion();
|
curVer = curInfo.getVersion();
|
||||||
|
|
||||||
httpTool.setStatusViewer(this);
|
httpTool.setStatusViewer(this);
|
||||||
@@ -232,17 +227,13 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
|
|
||||||
SelectionWidget.addItem(new CMenuForwarder(current, false));
|
SelectionWidget.addItem(new CMenuForwarder(current, false));
|
||||||
std::ifstream urlFile(g_settings.softupdate_url_file.c_str());
|
std::ifstream urlFile(g_settings.softupdate_url_file.c_str());
|
||||||
#ifdef DEBUG
|
dprintf(DEBUG_NORMAL, "[update] file %s\n", g_settings.softupdate_url_file.c_str());
|
||||||
printf("[update] file %s\n", g_settings.softupdate_url_file.c_str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
while (urlFile >> url)
|
while (urlFile >> url)
|
||||||
{
|
{
|
||||||
std::string::size_type startpos, endpos;
|
std::string::size_type startpos, endpos;
|
||||||
#ifdef DEBUG
|
dprintf(DEBUG_NORMAL, "[update] url %s\n", url.c_str());
|
||||||
printf("[update] url %s\n", url.c_str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* extract domain name */
|
/* extract domain name */
|
||||||
startpos = url.find("//");
|
startpos = url.find("//");
|
||||||
@@ -275,9 +266,7 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
|
|
||||||
CFlashVersionInfo versionInfo(versions[i]);
|
CFlashVersionInfo versionInfo(versions[i]);
|
||||||
newVer = versionInfo.getVersion();
|
newVer = versionInfo.getVersion();
|
||||||
#ifdef DEBUG
|
dprintf(DEBUG_NORMAL, "[update] url %s version %s (%d) timestamp %s (%ld) md5 %s name %s\n", url.c_str(), version.c_str(), newVer, versionInfo.getDate(), versionInfo.getDateTime(), md5.c_str(), name.c_str());
|
||||||
printf("[update] url %s version %s (%d) timestamp %s (%ld) md5 %s name %s\n", url.c_str(), version.c_str(), newVer, versionInfo.getDate(), versionInfo.getDateTime(), md5.c_str(), name.c_str());
|
|
||||||
#endif
|
|
||||||
if(versionInfo.snapshot <= '2' && (newVer > curVer || versionInfo.getDateTime() > curInfo.getDateTime()))
|
if(versionInfo.snapshot <= '2' && (newVer > curVer || versionInfo.getDateTime() > curInfo.getDateTime()))
|
||||||
newfound = 1;
|
newfound = 1;
|
||||||
if(!allow_flash && (versionInfo.snapshot <= '2'))
|
if(!allow_flash && (versionInfo.snapshot <= '2'))
|
||||||
@@ -330,7 +319,7 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
#ifdef BOXMODEL_CS_HD2
|
#ifdef BOXMODEL_CS_HD2
|
||||||
if(fileType <= '2') {
|
if(fileType <= '2') {
|
||||||
int esize = CMTDInfo::getInstance()->getMTDEraseSize(sysfs);
|
int esize = CMTDInfo::getInstance()->getMTDEraseSize(sysfs);
|
||||||
printf("[update] erase size is %x\n", esize);
|
dprintf(DEBUG_NORMAL, "[update] erase size is %x\n", esize);
|
||||||
if (esize == 0x40000) {
|
if (esize == 0x40000) {
|
||||||
filename += ".256k";
|
filename += ".256k";
|
||||||
}
|
}
|
||||||
@@ -343,9 +332,7 @@ bool CFlashUpdate::selectHttpImage(void)
|
|||||||
fileType = 'Z';
|
fileType = 'Z';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef DEBUG
|
dprintf(DEBUG_NORMAL, "[update] filename %s type %c newVersion %s md5 %s\n", filename.c_str(), fileType, newVersion.c_str(), file_md5.c_str());
|
||||||
printf("[update] filename %s type %c newVersion %s md5 %s\n", filename.c_str(), fileType, newVersion.c_str(), file_md5.c_str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -364,7 +351,7 @@ bool CFlashUpdate::getUpdateImage(const std::string & version)
|
|||||||
sprintf(dest_name, "%s/%s", g_settings.update_dir.c_str(), fname);
|
sprintf(dest_name, "%s/%s", g_settings.update_dir.c_str(), fname);
|
||||||
showStatusMessageUTF(std::string(g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILE)) + ' ' + version);
|
showStatusMessageUTF(std::string(g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILE)) + ' ' + version);
|
||||||
|
|
||||||
printf("get update (url): %s - %s\n", filename.c_str(), dest_name);
|
dprintf(DEBUG_NORMAL, "[update] get update (url): %s - %s\n", filename.c_str(), dest_name);
|
||||||
return httpTool.downloadFile(filename, dest_name, 40 );
|
return httpTool.downloadFile(filename, dest_name, 40 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,9 +360,7 @@ bool CFlashUpdate::checkVersion4Update()
|
|||||||
char msg[400];
|
char msg[400];
|
||||||
CFlashVersionInfo * versionInfo;
|
CFlashVersionInfo * versionInfo;
|
||||||
neutrino_locale_t msg_body;
|
neutrino_locale_t msg_body;
|
||||||
#ifdef DEBUG
|
dprintf(DEBUG_NORMAL, "[update] mode is %d\n", softupdate_mode);
|
||||||
printf("[update] mode is %d\n", softupdate_mode);
|
|
||||||
#endif
|
|
||||||
if(softupdate_mode==1) //internet-update
|
if(softupdate_mode==1) //internet-update
|
||||||
{
|
{
|
||||||
if(!selectHttpImage())
|
if(!selectHttpImage())
|
||||||
@@ -385,7 +370,7 @@ bool CFlashUpdate::checkVersion4Update()
|
|||||||
showGlobalStatus(20);
|
showGlobalStatus(20);
|
||||||
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_VERSIONCHECK));
|
showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_VERSIONCHECK));
|
||||||
|
|
||||||
printf("internet version: %s\n", newVersion.c_str());
|
dprintf(DEBUG_NORMAL, "[update] internet version: %s\n", newVersion.c_str());
|
||||||
|
|
||||||
showLocalStatus(100);
|
showLocalStatus(100);
|
||||||
showGlobalStatus(20);
|
showGlobalStatus(20);
|
||||||
@@ -450,7 +435,7 @@ bool CFlashUpdate::checkVersion4Update()
|
|||||||
fclose(fd);
|
fclose(fd);
|
||||||
else {
|
else {
|
||||||
hide();
|
hide();
|
||||||
printf("flash/package-file not found: %s\n", filename.c_str());
|
dprintf(DEBUG_NORMAL, "[update] flash/package-file not found: %s\n", filename.c_str());
|
||||||
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE));
|
DisplayErrorMessage(g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -491,9 +476,7 @@ bool CFlashUpdate::checkVersion4Update()
|
|||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
fileType = 0;
|
fileType = 0;
|
||||||
#ifdef DEBUG
|
dprintf(DEBUG_NORMAL, "[update] manual file type: %s %c\n", ptr, fileType);
|
||||||
printf("[update] manual file type: %s %c\n", ptr, fileType);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(msg, g_Locale->getText(LOCALE_FLASHUPDATE_NOVERSION));
|
strcpy(msg, g_Locale->getText(LOCALE_FLASHUPDATE_NOVERSION));
|
||||||
@@ -503,7 +486,7 @@ bool CFlashUpdate::checkVersion4Update()
|
|||||||
|
|
||||||
int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
||||||
{
|
{
|
||||||
printf("CFlashUpdate::exec: [%s]\n", actionKey.c_str());
|
dprintf(DEBUG_NORMAL, "CFlashUpdate::exec: [%s]\n", actionKey.c_str());
|
||||||
if (actionKey == "local")
|
if (actionKey == "local")
|
||||||
softupdate_mode = 0;
|
softupdate_mode = 0;
|
||||||
else
|
else
|
||||||
@@ -570,9 +553,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
|
|
||||||
showGlobalStatus(60);
|
showGlobalStatus(60);
|
||||||
|
|
||||||
#ifdef DEBUG
|
dprintf(DEBUG_NORMAL, "[update] flash/install filename %s type %c\n", filename.c_str(), fileType);
|
||||||
printf("[update] flash/install filename %s type %c\n", filename.c_str(), fileType);
|
|
||||||
#endif
|
|
||||||
if(fileType <= '2') {
|
if(fileType <= '2') {
|
||||||
//flash it...
|
//flash it...
|
||||||
#if ENABLE_EXTUPDATE
|
#if ENABLE_EXTUPDATE
|
||||||
@@ -588,10 +569,11 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DRYRUN
|
#ifdef DRYRUN
|
||||||
if(1) {
|
if (1)
|
||||||
#else
|
#else
|
||||||
if(!ft.program(filename, 80, 100)) {
|
if (!ft.program(filename, 80, 100))
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
hide();
|
hide();
|
||||||
ShowHint(LOCALE_MESSAGEBOX_ERROR, ft.getErrorMessage().c_str());
|
ShowHint(LOCALE_MESSAGEBOX_ERROR, ft.getErrorMessage().c_str());
|
||||||
return menu_return::RETURN_REPAINT;
|
return menu_return::RETURN_REPAINT;
|
||||||
@@ -649,7 +631,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
if (fseek(f, -2, SEEK_END) == 0)
|
if (fseek(f, -2, SEEK_END) == 0)
|
||||||
{
|
{
|
||||||
c[0] = fgetc(f);
|
c[0] = fgetc(f);
|
||||||
printf("[update] Current partition: %s\n", c);
|
dprintf(DEBUG_NORMAL, "[update] Current partition: %s\n", c);
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
@@ -676,7 +658,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
|
|
||||||
delete selector;
|
delete selector;
|
||||||
|
|
||||||
printf("[update] Flash into partition %d\n", selected);
|
dprintf(DEBUG_NORMAL, "[update] Flash into partition %d\n", selected);
|
||||||
|
|
||||||
int restart = CMsgBox::mbNo;
|
int restart = CMsgBox::mbNo;
|
||||||
|
|
||||||
@@ -685,14 +667,14 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
{
|
{
|
||||||
// align ofgwrite options
|
// align ofgwrite options
|
||||||
ofgwrite_options = "-m" + to_string(selected);
|
ofgwrite_options = "-m" + to_string(selected);
|
||||||
printf("[update] ofgwrite_options: %s\n", ofgwrite_options.c_str());
|
dprintf(DEBUG_NORMAL, "[update] ofgwrite_options: %s\n", ofgwrite_options.c_str());
|
||||||
|
|
||||||
// start selected partition?
|
// start selected partition?
|
||||||
restart = ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_SELECTED_PARTITION, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE);
|
restart = ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_START_SELECTED_PARTITION, CMsgBox::mbrYes, CMsgBox::mbYes | CMsgBox::mbNo, NEUTRINO_ICON_UPDATE);
|
||||||
if (restart == CMsgBox::mbrYes)
|
if (restart == CMsgBox::mbrYes)
|
||||||
{
|
{
|
||||||
std::string startup_new = "/boot/STARTUP_" + to_string(selected);
|
std::string startup_new = "/boot/STARTUP_" + to_string(selected);
|
||||||
printf("[update] Start selected partition %d (%s)\n", selected, startup_new.c_str());
|
dprintf(DEBUG_NORMAL, "[update] Start selected partition %d (%s)\n", selected, startup_new.c_str());
|
||||||
#ifndef DRYRUN
|
#ifndef DRYRUN
|
||||||
CFileHelpers fh;
|
CFileHelpers fh;
|
||||||
fh.copyFile(startup_new.c_str(), "/boot/STARTUP");
|
fh.copyFile(startup_new.c_str(), "/boot/STARTUP");
|
||||||
@@ -704,7 +686,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
hide();
|
hide();
|
||||||
|
|
||||||
const char ofgwrite_tgz[] = "/bin/ofgwrite_tgz";
|
const char ofgwrite_tgz[] = "/bin/ofgwrite_tgz";
|
||||||
printf("[update] calling %s %s %s %s\n", ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
|
dprintf(DEBUG_NORMAL, "[update] calling %s %s %s %s\n", ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
|
||||||
#ifndef DRYRUN
|
#ifndef DRYRUN
|
||||||
my_system(4, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
|
my_system(4, ofgwrite_tgz, g_settings.update_dir.c_str(), filename.c_str(), ofgwrite_options.c_str());
|
||||||
|
|
||||||
@@ -722,7 +704,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey)
|
|||||||
else // not image, install
|
else // not image, install
|
||||||
{
|
{
|
||||||
const char install_sh[] = "/bin/install.sh";
|
const char install_sh[] = "/bin/install.sh";
|
||||||
printf("[update] calling %s %s %s\n",install_sh, g_settings.update_dir.c_str(), filename.c_str() );
|
dprintf(DEBUG_NORMAL, "[update] calling %s %s %s\n",install_sh, g_settings.update_dir.c_str(), filename.c_str() );
|
||||||
#ifndef DRYRUN
|
#ifndef DRYRUN
|
||||||
my_system(3, install_sh, g_settings.update_dir.c_str(), filename.c_str());
|
my_system(3, install_sh, g_settings.update_dir.c_str(), filename.c_str());
|
||||||
#endif
|
#endif
|
||||||
@@ -1117,7 +1099,7 @@ int CFlashExpert::exec(CMenuTarget* parent, const std::string & actionKey)
|
|||||||
readmtd(iReadmtd);
|
readmtd(iReadmtd);
|
||||||
}
|
}
|
||||||
else if(iWritemtd!=-1) {
|
else if(iWritemtd!=-1) {
|
||||||
printf("mtd-write\n\n");
|
dprintf(DEBUG_NORMAL, "[update] mtd-write\n\n");
|
||||||
selectedMTD = iWritemtd;
|
selectedMTD = iWritemtd;
|
||||||
showFileSelector("");
|
showFileSelector("");
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user