mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
* Software Update with apply the settings (Part11)
- Deletelist added to delete files or directories from image - Files/Directories are marked by a prefixed '~' in the settingsupdate.conf - Rework readBackupList()
This commit is contained in:
@@ -486,6 +486,7 @@ flashupdate.settings Update-Einstellungen
|
|||||||
flashupdate.squashfs.noversion Bei Updates werden Versionsüberprüfungen derzeit nur über Web-Updates unterstützt.\nWollen Sie das ausgewählte Image wirklich installieren?
|
flashupdate.squashfs.noversion Bei Updates werden Versionsüberprüfungen derzeit nur über Web-Updates unterstützt.\nWollen Sie das ausgewählte Image wirklich installieren?
|
||||||
flashupdate.titlereadflash Flash auslesen
|
flashupdate.titlereadflash Flash auslesen
|
||||||
flashupdate.titlewriteflash Flash schreiben
|
flashupdate.titlewriteflash Flash schreiben
|
||||||
|
flashupdate.update_with_settings_del_skipped Ordner [%s] kann nicht gelöscht werden. Eintrag wird übersprungen.
|
||||||
flashupdate.update_with_settings_processed Image wird bearbeitet...
|
flashupdate.update_with_settings_processed Image wird bearbeitet...
|
||||||
flashupdate.update_with_settings_skipped Ordner [%s] kann nicht gesichert werden. Eintrag wird übersprungen.
|
flashupdate.update_with_settings_skipped Ordner [%s] kann nicht gesichert werden. Eintrag wird übersprungen.
|
||||||
flashupdate.update_with_settings_successfully Settingsübernahme erfolgreich.\nDas Image kann jetzt geflasht werden.
|
flashupdate.update_with_settings_successfully Settingsübernahme erfolgreich.\nDas Image kann jetzt geflasht werden.
|
||||||
|
@@ -486,6 +486,7 @@ flashupdate.settings Update settings
|
|||||||
flashupdate.squashfs.noversion SquashFS version checks are currently only supported when updating over the web.\nAre you sure that you wish to install this image?
|
flashupdate.squashfs.noversion SquashFS version checks are currently only supported when updating over the web.\nAre you sure that you wish to install this image?
|
||||||
flashupdate.titlereadflash Reading Flash
|
flashupdate.titlereadflash Reading Flash
|
||||||
flashupdate.titlewriteflash Writing Flash
|
flashupdate.titlewriteflash Writing Flash
|
||||||
|
flashupdate.update_with_settings_del_skipped Folder [%s] can not be deleted. Entry is skipped.
|
||||||
flashupdate.update_with_settings_processed Image is being processed...
|
flashupdate.update_with_settings_processed Image is being processed...
|
||||||
flashupdate.update_with_settings_skipped Folder [%s] can not be saved. Entry is skipped.
|
flashupdate.update_with_settings_skipped Folder [%s] can not be saved. Entry is skipped.
|
||||||
flashupdate.update_with_settings_successfully Setting takeover successfully.\nThe image can now be flashed.
|
flashupdate.update_with_settings_successfully Setting takeover successfully.\nThe image can now be flashed.
|
||||||
|
@@ -37,3 +37,10 @@
|
|||||||
-/var/tuxbox/config/satellites.xml
|
-/var/tuxbox/config/satellites.xml
|
||||||
-/var/tuxbox/config/settingsupdate.conf
|
-/var/tuxbox/config/settingsupdate.conf
|
||||||
-/var/tuxbox/config/tobackup.conf
|
-/var/tuxbox/config/tobackup.conf
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
## nach der Sicherung aus dem neuen Image zu l<>schende Dateien/Verzeichnisse,
|
||||||
|
## gekennzeichnet durch ein vorangestelltes ~
|
||||||
|
# z.B.
|
||||||
|
# ~/share/tuxbox/neutrino/themes/Classic.theme
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
@@ -73,7 +73,9 @@ CExtUpdate::CExtUpdate()
|
|||||||
fLogfile = "/tmp/update.log";
|
fLogfile = "/tmp/update.log";
|
||||||
mountPkt = "/tmp/image_mount";
|
mountPkt = "/tmp/image_mount";
|
||||||
FileHelpers = NULL;
|
FileHelpers = NULL;
|
||||||
BlackList.clear();
|
copyList.clear();
|
||||||
|
blackList.clear();
|
||||||
|
deleteList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CExtUpdate::~CExtUpdate()
|
CExtUpdate::~CExtUpdate()
|
||||||
@@ -82,7 +84,9 @@ CExtUpdate::~CExtUpdate()
|
|||||||
delete[] MTDBuf;
|
delete[] MTDBuf;
|
||||||
if(FileHelpers)
|
if(FileHelpers)
|
||||||
delete[] FileHelpers;
|
delete[] FileHelpers;
|
||||||
BlackList.clear();
|
copyList.clear();
|
||||||
|
blackList.clear();
|
||||||
|
deleteList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CExtUpdate* CExtUpdate::getInstance()
|
CExtUpdate* CExtUpdate::getInstance()
|
||||||
@@ -120,6 +124,7 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str
|
|||||||
}
|
}
|
||||||
if(hintBox)
|
if(hintBox)
|
||||||
hintBox->hide();
|
hintBox->hide();
|
||||||
|
sync();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -339,6 +344,7 @@ bool CExtUpdate::applySettings()
|
|||||||
if(hintBox)
|
if(hintBox)
|
||||||
hintBox->hide();
|
hintBox->hide();
|
||||||
|
|
||||||
|
sync();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,6 +405,40 @@ bool CExtUpdate::copyFileList(const std::string & fileList, const std::string &
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CExtUpdate::deleteFileList(const std::string & fileList)
|
||||||
|
{
|
||||||
|
Wildcard = "";
|
||||||
|
struct dirent **namelist;
|
||||||
|
std::string fList = fileList;
|
||||||
|
static struct stat FileInfo;
|
||||||
|
|
||||||
|
size_t pos = fileList.find_last_of("/");
|
||||||
|
fList = fileList.substr(0, pos);
|
||||||
|
Wildcard = fileList.substr(pos+1);
|
||||||
|
|
||||||
|
int n = scandir(fList.c_str(), &namelist, fileSelect, 0);
|
||||||
|
if (n > 0) {
|
||||||
|
while (n--) {
|
||||||
|
std::string dName = namelist[n]->d_name;
|
||||||
|
if (lstat((fList+"/"+dName).c_str(), &FileInfo) != -1) {
|
||||||
|
if (S_ISDIR(FileInfo.st_mode)) {
|
||||||
|
// Directory
|
||||||
|
WRITE_UPDATE_LOG("delete directory: %s\n", (fList+"/"+dName).c_str());
|
||||||
|
FileHelpers->removeDir((fList+"/"+dName).c_str());
|
||||||
|
}
|
||||||
|
else if (S_ISREG(FileInfo.st_mode)) {
|
||||||
|
// File
|
||||||
|
WRITE_UPDATE_LOG("delete file: %s\n", (fList+"/"+dName).c_str());
|
||||||
|
unlink((fList+"/"+dName).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(namelist[n]);
|
||||||
|
}
|
||||||
|
free(namelist);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool CExtUpdate::findConfigEntry(std::string & line, std::string find)
|
bool CExtUpdate::findConfigEntry(std::string & line, std::string find)
|
||||||
{
|
{
|
||||||
if (line.find("#:" + find + "=") == 0) {
|
if (line.find("#:" + find + "=") == 0) {
|
||||||
@@ -430,7 +470,7 @@ bool CExtUpdate::readConfig(const std::string & line)
|
|||||||
|
|
||||||
bool CExtUpdate::isBlacklistEntry(const std::string & file)
|
bool CExtUpdate::isBlacklistEntry(const std::string & file)
|
||||||
{
|
{
|
||||||
for(vector<std::string>::iterator it = BlackList.begin(); it != BlackList.end(); ++it) {
|
for(vector<std::string>::iterator it = blackList.begin(); it != blackList.end(); ++it) {
|
||||||
if (*it == file) {
|
if (*it == file) {
|
||||||
DBG_MSG("BlacklistEntry %s\n", (*it).c_str());
|
DBG_MSG("BlacklistEntry %s\n", (*it).c_str());
|
||||||
WRITE_UPDATE_LOG("BlacklistEntry: %s\n", (*it).c_str());
|
WRITE_UPDATE_LOG("BlacklistEntry: %s\n", (*it).c_str());
|
||||||
@@ -440,6 +480,20 @@ bool CExtUpdate::isBlacklistEntry(const std::string & file)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CExtUpdate::checkSpecialFolders(std::string line, bool copy)
|
||||||
|
{
|
||||||
|
if ((line == "/") || (line == "/*") || (line == "/*.*") || (line.find("/dev") == 0) || (line.find("/proc") == 0) ||
|
||||||
|
(line.find("/sys") == 0) || (line.find("/mnt") == 0) || (line.find("/tmp") == 0)) {
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
neutrino_locale_t msg = (copy) ? LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED : LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_DEL_SKIPPED;
|
||||||
|
snprintf(buf, sizeof(buf), g_Locale->getText(msg), line.c_str());
|
||||||
|
WRITE_UPDATE_LOG("%s%s", buf, "\n");
|
||||||
|
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool CExtUpdate::readBackupList(const std::string & dstPath)
|
bool CExtUpdate::readBackupList(const std::string & dstPath)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
@@ -470,37 +524,18 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
size_t pos;
|
size_t pos;
|
||||||
std::string line;
|
std::string line;
|
||||||
|
|
||||||
// read blacklist
|
// read blacklist and config vars
|
||||||
BlackList.clear();
|
copyList.clear();
|
||||||
while(fgets(buf, sizeof(buf), f1) != NULL) {
|
blackList.clear();
|
||||||
line = buf;
|
deleteList.clear();
|
||||||
line = trim(line);
|
|
||||||
// ignore comments
|
|
||||||
if (line.find_first_of("#") == 0)
|
|
||||||
continue;
|
|
||||||
pos = line.find_first_of("#");
|
|
||||||
if (pos != std::string::npos) {
|
|
||||||
line = line.substr(0, pos);
|
|
||||||
line = trim(line);
|
|
||||||
}
|
|
||||||
// find blacklist entry
|
|
||||||
if (line.find_first_of("-") == 0) {
|
|
||||||
line = line.substr(1);
|
|
||||||
if ((line.length() > 1) && (lstat(line.c_str(), &FileInfo) != -1)) {
|
|
||||||
if (S_ISREG(FileInfo.st_mode))
|
|
||||||
BlackList.push_back(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// read backuplist
|
|
||||||
fseek(f1, 0, SEEK_SET);
|
|
||||||
while(fgets(buf, sizeof(buf), f1) != NULL) {
|
while(fgets(buf, sizeof(buf), f1) != NULL) {
|
||||||
|
std::string tmpLine;
|
||||||
line = buf;
|
line = buf;
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
// ignore comments
|
// ignore comments
|
||||||
if (line.find_first_of("#") == 0) {
|
if (line.find_first_of("#") == 0) {
|
||||||
if (line.find_first_of(":") == 1) { // config vars
|
// config vars
|
||||||
|
if (line.find_first_of(":") == 1) {
|
||||||
if (line.length() > 1)
|
if (line.length() > 1)
|
||||||
readConfig(line);
|
readConfig(line);
|
||||||
}
|
}
|
||||||
@@ -511,27 +546,39 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
line = line.substr(0, pos);
|
line = line.substr(0, pos);
|
||||||
line = trim(line);
|
line = trim(line);
|
||||||
}
|
}
|
||||||
|
// find blackList entry
|
||||||
// '+' add entry = default
|
if (line.find_first_of("-") == 0) {
|
||||||
if (line.find_first_of("+") == 0)
|
tmpLine = line.substr(1);
|
||||||
line = line.substr(1);
|
if ((tmpLine.length() > 1) && (lstat(tmpLine.c_str(), &FileInfo) != -1)) {
|
||||||
|
if (S_ISREG(FileInfo.st_mode))
|
||||||
// '-' blacklist entry
|
blackList.push_back(tmpLine);
|
||||||
if (line.find_first_of("-") == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Entry '~' (delete) ignore currently still
|
|
||||||
if (line.find_first_of("~") == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// special folders
|
|
||||||
else if ((line == "/") || (line == "/*") || (line == "/*.*") || (line.find("/dev") == 0) || (line.find("/proc") == 0) ||
|
|
||||||
(line.find("/sys") == 0) || (line.find("/mnt") == 0) || (line.find("/tmp") == 0)) {
|
|
||||||
snprintf(buf, sizeof(buf), g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED), line.c_str());
|
|
||||||
WRITE_UPDATE_LOG("%s%s", buf, "\n");
|
|
||||||
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// find deleteList entry
|
||||||
|
else if (line.find_first_of("~") == 0) {
|
||||||
|
tmpLine = line.substr(1);
|
||||||
|
if (checkSpecialFolders(tmpLine, false))
|
||||||
|
continue;
|
||||||
|
tmpLine = dstPath + tmpLine;
|
||||||
|
if (line.length() > 2)
|
||||||
|
deleteList.push_back(tmpLine);
|
||||||
|
}
|
||||||
|
// find copyList entry
|
||||||
|
else {
|
||||||
|
tmpLine = (line.find_first_of("+") == 0) ? line.substr(1) : line; // '+' add entry = default
|
||||||
|
if (checkSpecialFolders(tmpLine, true))
|
||||||
|
continue;
|
||||||
|
if (tmpLine.length() > 1)
|
||||||
|
copyList.push_back(tmpLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f1);
|
||||||
|
|
||||||
|
// read copyList
|
||||||
|
vector<std::string>::iterator it;
|
||||||
|
for(it = copyList.begin(); it != copyList.end(); ++it) {
|
||||||
|
line = *it;
|
||||||
|
line = trim(line);
|
||||||
// remove '/' from line end
|
// remove '/' from line end
|
||||||
size_t len = line.length();
|
size_t len = line.length();
|
||||||
pos = line.find_last_of("/");
|
pos = line.find_last_of("/");
|
||||||
@@ -573,8 +620,29 @@ bool CExtUpdate::readBackupList(const std::string & dstPath)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(f1);
|
|
||||||
|
|
||||||
|
// read DeleteList
|
||||||
|
for(it = deleteList.begin(); it != deleteList.end(); ++it) {
|
||||||
|
line = *it;
|
||||||
|
if (lstat(line.c_str(), &FileInfo) != -1) {
|
||||||
|
if ((line.find("*") != std::string::npos) || (line.find("?") != std::string::npos)) {
|
||||||
|
// Wildcards
|
||||||
|
WRITE_UPDATE_LOG("delete file list: %s\n", line.c_str());
|
||||||
|
deleteFileList(line.c_str());
|
||||||
|
}
|
||||||
|
else if (S_ISREG(FileInfo.st_mode)) {
|
||||||
|
// File
|
||||||
|
WRITE_UPDATE_LOG("delete file: %s\n", line.c_str());
|
||||||
|
unlink(line.c_str());
|
||||||
|
}
|
||||||
|
else if (S_ISDIR(FileInfo.st_mode)){
|
||||||
|
// Directory
|
||||||
|
WRITE_UPDATE_LOG("delete directory: %s\n", line.c_str());
|
||||||
|
FileHelpers->removeDir(line.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sync();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,14 +54,16 @@ class CExtUpdate
|
|||||||
std::string backupList, defaultBackup;
|
std::string backupList, defaultBackup;
|
||||||
std::string mountPkt;
|
std::string mountPkt;
|
||||||
CFileHelpers* FileHelpers;
|
CFileHelpers* FileHelpers;
|
||||||
std::vector<std::string> BlackList;
|
std::vector<std::string> copyList, blackList, deleteList;
|
||||||
|
|
||||||
bool applySettings(void);
|
bool applySettings(void);
|
||||||
bool readBackupList(const std::string & dstPath);
|
bool readBackupList(const std::string & dstPath);
|
||||||
bool copyFileList(const std::string & fileList, const std::string & dstPath);
|
bool copyFileList(const std::string & fileList, const std::string & dstPath);
|
||||||
|
bool deleteFileList(const std::string & fileList);
|
||||||
bool readConfig(const std::string & Config);
|
bool readConfig(const std::string & Config);
|
||||||
bool findConfigEntry(std::string & line, std::string find);
|
bool findConfigEntry(std::string & line, std::string find);
|
||||||
bool isMtdramLoad();
|
bool isMtdramLoad();
|
||||||
|
bool checkSpecialFolders(std::string line, bool copy);
|
||||||
|
|
||||||
FILE * fUpdate;
|
FILE * fUpdate;
|
||||||
char updateLogBuf[1024];
|
char updateLogBuf[1024];
|
||||||
|
@@ -513,6 +513,7 @@ typedef enum
|
|||||||
LOCALE_FLASHUPDATE_SQUASHFS_NOVERSION,
|
LOCALE_FLASHUPDATE_SQUASHFS_NOVERSION,
|
||||||
LOCALE_FLASHUPDATE_TITLEREADFLASH,
|
LOCALE_FLASHUPDATE_TITLEREADFLASH,
|
||||||
LOCALE_FLASHUPDATE_TITLEWRITEFLASH,
|
LOCALE_FLASHUPDATE_TITLEWRITEFLASH,
|
||||||
|
LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_DEL_SKIPPED,
|
||||||
LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_PROCESSED,
|
LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_PROCESSED,
|
||||||
LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED,
|
LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED,
|
||||||
LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SUCCESSFULLY,
|
LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SUCCESSFULLY,
|
||||||
|
@@ -513,6 +513,7 @@ const char * locale_real_names[] =
|
|||||||
"flashupdate.squashfs.noversion",
|
"flashupdate.squashfs.noversion",
|
||||||
"flashupdate.titlereadflash",
|
"flashupdate.titlereadflash",
|
||||||
"flashupdate.titlewriteflash",
|
"flashupdate.titlewriteflash",
|
||||||
|
"flashupdate.update_with_settings_del_skipped",
|
||||||
"flashupdate.update_with_settings_processed",
|
"flashupdate.update_with_settings_processed",
|
||||||
"flashupdate.update_with_settings_skipped",
|
"flashupdate.update_with_settings_skipped",
|
||||||
"flashupdate.update_with_settings_successfully",
|
"flashupdate.update_with_settings_successfully",
|
||||||
|
Reference in New Issue
Block a user