Commit eab989b1 authored by claes's avatar claes

Set owner root of plc, and improved error handling

parent fe1b0cb4
...@@ -318,27 +318,32 @@ void pkg_node::fetchFiles( bool distribute) ...@@ -318,27 +318,32 @@ void pkg_node::fetchFiles( bool distribute)
// Put all files in a single list // Put all files in a single list
for ( int i = 0; i < (int)m_pattern.size(); i++) { for ( int i = 0; i < (int)m_pattern.size(); i++) {
for ( int j = 0; j < (int)m_pattern[i].m_filelist.size(); j++) { for ( int j = 0; j < (int)m_pattern[i].m_filelist.size(); j++) {
pkg_file f = m_pattern[i].m_filelist[j]; try {
pkg_file f = m_pattern[i].m_filelist[j];
dcli_parse_filename( f.m_source, dev, dir, file, type, &version);
strcpy( f.m_arname, file); dcli_parse_filename( f.m_source, dev, dir, file, type, &version);
strcat( f.m_arname, type); strcpy( f.m_arname, file);
strcat( f.m_arname, type);
// Check that this name is unic
for (;;) { // Check that this name is unic
bool new_name = false; for (;;) {
for ( int k = 0; k < (int)m_filelist.size(); k++) { bool new_name = false;
if ( strcmp( m_filelist[k].m_arname, f.m_arname) == 0) { for ( int k = 0; k < (int)m_filelist.size(); k++) {
strcat( f.m_arname, "x"); if ( strcmp( m_filelist[k].m_arname, f.m_arname) == 0) {
new_name = true; strcat( f.m_arname, "x");
break; new_name = true;
break;
}
} }
if ( !new_name)
break;
} }
if ( !new_name)
break;
}
m_filelist.push_back( f); m_filelist.push_back( f);
} catch ( wb_error &e) {
MsgWindow::message( 'W', e.what().c_str(), msgw_ePop_No);
m_warnings++;
}
} }
} }
...@@ -426,6 +431,16 @@ void pkg_node::fetchFiles( bool distribute) ...@@ -426,6 +431,16 @@ void pkg_node::fetchFiles( bool distribute)
"mv pwr_pkg.dat $pwrp_load" << endl << "mv pwr_pkg.dat $pwrp_load" << endl <<
"rm -r /tmp/pkg_build" << endl; "rm -r /tmp/pkg_build" << endl;
// Change owner to root of plc, to make modification of thread prio possible
ofu <<
"nname=`eval uname -n`" << endl <<
"tst=`eval sudo -l | grep \" ALL\"`" << endl <<
"if [ \"$tst\" != \"\" ]; then" << endl <<
" sudo chown root $pwrp_exe/plc_$nname_*" << endl <<
" sudo chmod g+w $pwrp_exe/plc_$nname_*" << endl <<
" sudo chmod u+s $pwrp_exe/plc_$nname_*" << endl <<
"fi" << endl;
ofu.close(); ofu.close();
// Create a data file with description and all installed files // Create a data file with description and all installed files
...@@ -546,8 +561,12 @@ void pkg_pattern::fetchFiles() ...@@ -546,8 +561,12 @@ void pkg_pattern::fetchFiles()
strcat( file_target, file); strcat( file_target, file);
strcat( file_target, type); strcat( file_target, type);
} }
pkg_file file( found_file, file_target); try {
m_filelist.push_back( file); pkg_file file( found_file, file_target);
m_filelist.push_back( file);
} catch ( wb_error &e) {
MsgWindow::message( 'W', e.what().c_str(), msgw_ePop_Yes);
}
break; break;
} }
} }
...@@ -572,8 +591,12 @@ void pkg_pattern::fetchFiles() ...@@ -572,8 +591,12 @@ void pkg_pattern::fetchFiles()
strcat( file_target, file); strcat( file_target, file);
strcat( file_target, type); strcat( file_target, type);
} }
pkg_file file( found_file, file_target); try {
m_filelist.push_back( file); pkg_file file( found_file, file_target);
m_filelist.push_back( file);
} catch ( wb_error &e) {
MsgWindow::message( 'W', e.what().c_str(), msgw_ePop_Yes);
}
sts = dcli_search_file( m_source, found_file, DCLI_DIR_SEARCH_NEXT); sts = dcli_search_file( m_source, found_file, DCLI_DIR_SEARCH_NEXT);
} }
...@@ -598,8 +621,11 @@ pkg_file::pkg_file( char *source, char *target) ...@@ -598,8 +621,11 @@ pkg_file::pkg_file( char *source, char *target)
struct stat info; struct stat info;
int sts = stat( source, &info); int sts = stat( source, &info);
if ( sts == -1) if ( sts == -1) {
throw wb_error_str("Source file doesn't exist"); char msg[256];
sprintf( msg, "Source file doesn't exist: %s", source);
throw wb_error_str(msg);
}
m_date.tv_sec = info.st_ctime; m_date.tv_sec = info.st_ctime;
m_date.tv_nsec = 0; m_date.tv_nsec = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment