| ... |
... |
@@ -88,6 +88,15 @@ sub create_tar { |
|
88
|
88
|
system('tar', '--exclude=./dev', '-C', $rootfsdir, '-caf', $tarfile, '.');
|
|
89
|
89
|
}
|
|
90
|
90
|
|
|
|
91
|
+sub get_chroot_bin {
|
|
|
92
|
+ my @dirs = qw|/usr/sbin /usr/bin /sbin /bin|;
|
|
|
93
|
+ push @dirs, split(':', $ENV{PATH});
|
|
|
94
|
+ foreach my $dir (@dirs) {
|
|
|
95
|
+ my $cpath = "$dir/chroot";
|
|
|
96
|
+ return $cpath if -e $cpath;
|
|
|
97
|
+ }
|
|
|
98
|
+}
|
|
|
99
|
+
|
|
91
|
100
|
sub run_chroot {
|
|
92
|
101
|
my ($rootfsdir, $cmd) = @_;
|
|
93
|
102
|
create_devfiles($rootfsdir);
|
| ... |
... |
@@ -101,7 +110,7 @@ sub run_chroot { |
|
101
|
110
|
path("$rootfsdir/etc/hosts")->append("\n127.0.1.1 rbm\n")
|
|
102
|
111
|
unless grep { m/^127.0.1.1 rbm$/ } path("$rootfsdir/etc/hosts")->lines;
|
|
103
|
112
|
system('hostname', 'rbm');
|
|
104
|
|
- my $res = system('/usr/sbin/chroot', $rootfsdir, @$cmd);
|
|
|
113
|
+ my $res = system(get_chroot_bin(), $rootfsdir, @$cmd);
|
|
105
|
114
|
do_unmounts($rootfsdir);
|
|
106
|
115
|
return $res;
|
|
107
|
116
|
}
|
| ... |
... |
@@ -115,7 +124,7 @@ sub copy_file_to { |
|
115
|
124
|
local %ENV = (
|
|
116
|
125
|
PATH => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
|
|
117
|
126
|
);
|
|
118
|
|
- return system('/usr/sbin/chroot', $rootfsdir, 'chown', '-R', $owner, $dst);
|
|
|
127
|
+ return system(get_chroot_bin(), $rootfsdir, 'chown', '-R', $owner, $dst);
|
|
119
|
128
|
}
|
|
120
|
129
|
|
|
121
|
130
|
sub copy_file_from {
|