3 # Common setup functions for building release packages
7 # - Initial framework for migrating setup/release building to perl
10 # Gef - Cleaner handling of cons builds, currently doesn't catch cons errors
23 # Replace in file parm-1; parm-2 with parm-3
28 my $search = shift(@_);
29 my $replace_with = shift(@_);
31 # need to use | instead of / with sed since the variables will contain /'s which confuse it
32 system("cat '$file' | sed -e 's|$search|$replace_with|g' > '$file.tmp'");
33 system("cp '$file.tmp' '$file'; rm '$file.tmp'");
36 # Not exactly common (between win32/linux), but useful here all the same
40 my $BUILD_DIR = shift(@_);
41 my $BUILD_CMD = shift(@_);
42 # use a direct system() call since syscmd doesnt catch cons errors
43 system("cd $BUILD_DIR; $BUILD_CMD");
46 # Maintain a list of errors that have occured
50 my $err_type = shift(@_); # unused
51 my $err_command = shift(@_);
53 @errors[$err_count++] = "$err_command";
56 # Output the list of errors stored
65 print("$err_count Errors!! Ouch, looks like something screwed up.\n");
69 print("$err_count Error(s) encountered\n");
72 for($count; $count lt $err_count; $count++)
74 if(@errors[$count] ne "")
76 print("-> @errors[$count]\n");
82 # print("No errors encountered.\n");
86 # A wrapper for system() calls that catches errors
90 my $command_string = shift(@_);
92 # todo: identify multiple commands (commands split with ;'s)
93 # todo: catch cons errors (cons doesn't return a value)
94 system("$command_string");
97 if(($sysretval gt 0) && ($sysretval lt 257))
99 @cmdlist = split(" ", $command_string);
100 if(@cmdlist[0] eq "cp")
102 collate_error("copy", $command_string);
104 elsif(@cmdlist[0] eq "mv")
106 collate_error("move", $command_string);
108 elsif(@cmdlist[0] eq "cons")
110 collate_error("cons", $command_string);
112 elsif(@cmdlist[0] eq "cd")
114 collate_error("changed dir", $command_string);
116 elsif(@cmdlist[0] eq "mkdir")
118 collate_error("make dir", $command_string);
120 elsif(@cmdlist[0] eq "cat")
122 collate_error("cat", $command_string);
124 elsif(@cmdlist[0] eq "rm")
126 collate_error("remove", $command_string);
130 collate_error("unhandled", $command_string);