summaryrefslogtreecommitdiffstats
path: root/lib/Sbuild
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Sbuild')
-rw-r--r--lib/Sbuild/ChrootUnshare.pm14
-rw-r--r--lib/Sbuild/Utility.pm12
2 files changed, 24 insertions, 2 deletions
diff --git a/lib/Sbuild/ChrootUnshare.pm b/lib/Sbuild/ChrootUnshare.pm
index c4a3064..8fb2350 100644
--- a/lib/Sbuild/ChrootUnshare.pm
+++ b/lib/Sbuild/ChrootUnshare.pm
@@ -288,6 +288,18 @@ sub _get_exec_argv {
$init = "/usr/bin/dumb-init";
}
+ # Detect whether linux32 personality might be needed
+ my %personalities = (
+ 'armel:arm64' => 1,
+ 'armhf:arm64' => 1,
+ 'i386:amd64' => 1,
+ 'mipsel:mips64el' => 1,
+ 'powerpc:ppc64' => 1,
+ 's390:s390x' => 1,
+ 'sparc:sparc64' => 1,
+ );
+ my $linux32 = exists $personalities{($self->get_conf('BUILD_ARCH') . ':' . $self->get_conf('ARCH'))};
+
my @bind_mounts = ();
for my $entry (@{$self->get_conf('UNSHARE_BIND_MOUNTS')}) {
push @bind_mounts, $entry->{directory}, $entry->{mountpoint};
@@ -295,7 +307,7 @@ sub _get_exec_argv {
return (
'env', 'PATH=' . $self->get_conf('PATH'),
- get_unshare_cmd({UNSHARE_FLAGS => $unshare, FORK => 1, IDMAP => $self->get('Uid Gid Map')}), 'sh', '-c', "
+ get_unshare_cmd({UNSHARE_FLAGS => $unshare, FORK => 1, IDMAP => $self->get('Uid Gid Map'), LINUX32 => $linux32}), 'sh', '-c', "
rootdir=\"\$1\"; shift;
user=\"\$1\"; shift;
dir=\"\$1\"; shift;
diff --git a/lib/Sbuild/Utility.pm b/lib/Sbuild/Utility.pm
index 5a59b28..9cdfff1 100644
--- a/lib/Sbuild/Utility.pm
+++ b/lib/Sbuild/Utility.pm
@@ -56,7 +56,7 @@ BEGIN {
@EXPORT = qw(setup cleanup shutdown check_url download get_unshare_cmd
read_subuid_subgid CLONE_NEWNS CLONE_NEWUTS CLONE_NEWIPC CLONE_NEWUSER
- CLONE_NEWPID CLONE_NEWNET test_unshare get_tar_compress_options);
+ CLONE_NEWPID CLONE_NEWNET PER_LINUX32 test_unshare get_tar_compress_options);
$SIG{'INT'} = \&shutdown;
$SIG{'TERM'} = \&shutdown;
@@ -379,6 +379,11 @@ use constant {
CLONE_NEWNET => 0x40000000,
};
+# from personality.h
+use constant {
+ PER_LINUX32 => 0x0008,
+};
+
sub get_unshare_cmd($) {
my $options = shift;
@@ -515,6 +520,11 @@ if (\$cpid != 0) {
EOF
}
+ if ($options->{'LINUX32'}) {
+ my $personality = PER_LINUX32;
+ $command .= "syscall &SYS_personality, $personality;";
+ }
+
$command .= 'exec { $ARGV[0] } @ARGV or die "exec() failed: $!";';
# remove code comments
$command =~ s/^\s*#.*$//gm;