Commit 946b39b0 authored by claes's avatar claes

New distributor window

parent 60ddd53d
......@@ -10,7 +10,7 @@
#include "co_time.h"
#include "rt_load.h"
wb_pkg::wb_pkg( char *nodelist)
wb_pkg::wb_pkg( char *nodelist, bool distribute)
{
if ( nodelist) {
char node_str[32][20];
......@@ -32,7 +32,7 @@ wb_pkg::wb_pkg( char *nodelist)
readConfig();
fetchFiles();
fetchFiles( distribute);
}
void wb_pkg::readConfig()
......@@ -250,7 +250,7 @@ pkg_node& wb_pkg::getNode( char *name)
throw wb_error_str("No such node");
}
void pkg_node::fetchFiles()
void pkg_node::fetchFiles( bool distribute)
{
char dev[80];
char dir[80];
......@@ -327,16 +327,19 @@ void pkg_node::fetchFiles()
of <<
"#mv $pwrp_tmp/pkg_unpack.sh $pwrp_tmp/pkg_build" << endl <<
"cd $pwrp_tmp" << endl <<
"tar -czf $pwrp_load/" << pkg_name << " pwr_pkg.dat pkg_unpack.sh pkg_build" << endl <<
"cd $pwrp_load" << endl <<
"ftp -vin " << m_name << " << EOF &>$pwrp_tmp/ftp_" << m_name << ".log" << endl <<
"user pwrp pwrp" << endl <<
"binary" << endl <<
"put " << pkg_name << endl <<
"quit" << endl <<
"EOF" << endl <<
"rsh -l pwrp " << m_name << " \\$pwr_exe/pwr_pkg.sh -i " << pkg_name << endl;
"tar -czf $pwrp_load/" << pkg_name << " pwr_pkg.dat pkg_unpack.sh pkg_build" << endl;
if ( distribute)
of <<
"cd $pwrp_load" << endl <<
"ftp -vin " << m_name << " << EOF &>$pwrp_tmp/ftp_" << m_name << ".log" << endl <<
"user pwrp pwrp" << endl <<
"binary" << endl <<
"put " << pkg_name << endl <<
"quit" << endl <<
"EOF" << endl <<
"rsh -l pwrp " << m_name << " \\$pwr_exe/pwr_pkg.sh -i " << pkg_name << endl;
of.close();
// Create a script that unpackes the archive and moves files to the target directories
......@@ -403,6 +406,37 @@ void pkg_node::fetchFiles()
}
void wb_pkg::copyPackage( char *pkg_name)
{
char pack_fname[200];
char node_name[80];
char *s;
// Extract node name from package name
strcpy( node_name, &pkg_name[9]);
if ( (s = strrchr( node_name, '_')))
*s = 0;
dcli_translate_filename( pack_fname, "$pwrp_tmp/pkg_pack.sh");
ofstream of( pack_fname);
of <<
"cd $pwrp_load" << endl <<
"ftp -vin " << node_name << " << EOF &>$pwrp_tmp/ftp_" << node_name << ".log" << endl <<
"user pwrp pwrp" << endl <<
"binary" << endl <<
"put " << pkg_name << endl <<
"quit" << endl <<
"EOF" << endl <<
"rsh -l pwrp " << node_name << " \\$pwr_exe/pwr_pkg.sh -i " << pkg_name << endl;
of.close();
// Execute the pack file
char cmd[200];
sprintf( cmd, "source %s", pack_fname);
system( cmd);
}
void pkg_pattern::fetchFiles()
{
char found_file[200];
......
......@@ -25,6 +25,7 @@ class pkg_file {
char *source() { return m_source;}
char *target() { return m_target;}
pwr_tTime date() { return m_date;}
};
class pkg_pattern {
......@@ -82,7 +83,7 @@ class pkg_node {
void push_back( pkg_pattern& pattern) {
m_pattern.push_back( pattern);
}
void fetchFiles();
void fetchFiles( bool distribute);
};
class wb_pkg {
......@@ -93,11 +94,13 @@ class wb_pkg {
void readConfig();
public:
wb_pkg( char *nodelist);
wb_pkg( char *nodelist, bool distribute = true);
pkg_node& getNode( char *name);
void fetchFiles() {
for ( int i = 0; i < (int)m_nodelist.size(); i++) m_nodelist[i].fetchFiles();
void fetchFiles( bool distribute) {
for ( int i = 0; i < (int)m_nodelist.size(); i++) m_nodelist[i].fetchFiles( distribute);
}
static void copyPackage( char *pkg_name);
};
#endif
......
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