forked from Rhoban/workspace
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-code.speed
More file actions
executable file
·83 lines (69 loc) · 2.09 KB
/
deploy-code.speed
File metadata and controls
executable file
·83 lines (69 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/php
<?php
// Checking for chrpath
system('which chrpath > /dev/null', $ret);
if ($ret != 0) {
die("Error: you should have chrpath installed (apt-get install chrpath)\n");
}
// Remote host
$remote = isset($argv[1]) ? $argv[1] : '10.0.0.1';
// Killing server on host
echo "Killing KidSize on " . $remote;
`ssh rhoban@$remote ./env/stop.sh`;
// Parameters
$binary = 'devel_release/lib/kid_size/KidSize';
$targetHost = 'rhoban@'.$remote;
$targetDir = '/home/rhoban/catkin_rel/';
$libBlackList=array("libpthread.","libstdc","libm.","libgcc","libc.");
function smartCopyFile($filename){
global $libBlackList;
$name=basename($filename);
foreach($libBlackList as $l)
if (strpos($name,$l)===0)
return;
//echo "smartCopyFile of ".$filename."\n";
if (file_exists(".deploy/".$name))
return;
if (is_link($filename)){
$src=readlink($filename);
//echo $filename." is a link pointing to ".$src."\n";
if (substr($src,0,1)!='/'){
$src=dirname($filename)."/".$src;
//echo "rel to abs: ".$src."\n";
}
smartCopyFile($src);
$srcname=basename($src);
symlink($srcname,".deploy/".$name);
} else {
copy($filename,".deploy/".$name);
}
}
function smartCopy($filePattern){
foreach(glob($filePattern) as $filename){
smartCopyFile($filename);
}
}
// Libraries
echo "* Preparing system libraries...\n";
$out = `ldd $binary|grep -iv "Not found|grep -iv "`;
$lines = explode("\n", trim($out));
foreach ($lines as $line) {
$parts = explode(' ', trim($line));
if (count($parts) > 3) {
$lib = $parts[2];
if (trim($lib)) {
if (strstr($lib, 'deps') || strstr($lib, 'home')) {
`cp $lib .deploy/`;
}
else {
smartCopy($lib);
}
}
}
}
// Deploying
echo "* Sending files...\n";
`cp $binary .deploy/`;
$binaryName = basename($binary);
`chrpath --replace $targetDir .deploy/$binaryName`;
`rsync --delete -av --info=flist2,name,progress .deploy/ $targetHost:$targetDir`;