summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChan Lee <chan45.lee@samsung.com>2016-12-01 10:23:45 +0900
committerChan Lee <chan45.lee@samsung.com>2016-12-01 11:41:45 +0900
commit83b041f0a40aff2e8b51fb858648ec58f1e9c3f7 (patch)
tree3829998e84dfd1e34d935d4f2c9258b7e1116acf
parent23bd45d0a4a885918f7830d0875ef4c6b1f96f86 (diff)
downloadbuild-sandbox/chanleebf/host_arch.tar.gz
build-sandbox/chanleebf/host_arch.tar.bz2
build-sandbox/chanleebf/host_arch.zip
Get original host archtecture not the one of KVM containersandbox/chanleebf/host_arch
‘uname -m’ inside KVM container returns target build architecture but not the build host one (it’s done by qemu-user). So we can prepare statically linked binary to get original host archtecture. This patch is writen by Pavel Kopyl(p.kopyl@samsung.com). Change-Id: I3f82e6782d02a9a7a80d333add3b50caa8f23774 Signed-off-by: Chan Lee <chan45.lee@samsung.com>
-rw-r--r--Build.pm4
-rw-r--r--Makefile10
-rwxr-xr-xdebian/rules3
-rw-r--r--host_arch.c20
-rw-r--r--packaging/build.spec12
5 files changed, 48 insertions, 1 deletions
diff --git a/Build.pm b/Build.pm
index 4277c46..9ad2ca0 100644
--- a/Build.pm
+++ b/Build.pm
@@ -24,6 +24,7 @@ use strict;
use Digest::MD5;
use Build::Rpm;
use Data::Dumper;
+use File::Basename;
our $expand_dbg;
@@ -174,7 +175,8 @@ sub read_config_dist {
}
sub get_hostarch {
- my $hostarch = `uname -m` || 'i586';
+ my $dirname = dirname(__FILE__);
+ my $hostarch = `$dirname/host_arch` || 'i586';
return $hostarch;
}
diff --git a/Makefile b/Makefile
index 346a908..44e5e9b 100644
--- a/Makefile
+++ b/Makefile
@@ -91,6 +91,16 @@ initvm-install: initvm
install -m755 -d $(DESTDIR)$(pkglibdir)
install -m755 initvm.$(INITVM_ARCH) $(DESTDIR)$(pkglibdir)/initvm.$(INITVM_ARCH)
+host_arch: host_arch.c
+ $(CC) -o $@ -static $(CFLAGS) host_arch.c
+
+host_arch-all: host_arch
+
+host_arch-build: host_arch
+
+host_arch-install: host_arch
+ install -m755 -d $(DESTDIR)$(pkglibdir)
+ install -m755 host_arch $(DESTDIR)$(pkglibdir)/host_arch
dist:
ifeq ($(SCM),svn)
diff --git a/debian/rules b/debian/rules
index bae8422..2145078 100755
--- a/debian/rules
+++ b/debian/rules
@@ -25,6 +25,7 @@ configure-stamp:
build: build-stamp
make initvm-all
+ make host_arch-all
build-stamp: configure-stamp
dh_testdir
touch build-stamp
@@ -43,6 +44,8 @@ install: build
dh_installdirs
make DESTDIR=$(CURDIR)/debian/build initvm-install
chmod 0644 $(CURDIR)/debian/build/usr/lib/build/initvm.*
+ make DESTDIR=$(CURDIR)/debian/build host_arch-install
+ chmod 0644 $(CURDIR)/debian/build/usr/lib/build/host_arch
make DESTDIR=$(CURDIR)/debian/build install
binary-arch: build install
diff --git a/host_arch.c b/host_arch.c
new file mode 100644
index 0000000..362c6bf
--- /dev/null
+++ b/host_arch.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/utsname.h>
+
+int main(void) {
+
+ struct utsname buffer;
+
+ errno = 0;
+ if (uname(&buffer) != 0) {
+ perror("uname");
+ exit(EXIT_FAILURE);
+ }
+
+ printf("%s\n", buffer.machine);
+
+ return EXIT_SUCCESS;
+}
+
diff --git a/packaging/build.spec b/packaging/build.spec
index 5659cb8..9434c58 100644
--- a/packaging/build.spec
+++ b/packaging/build.spec
@@ -36,6 +36,11 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
AutoReqProv: off
# Keep the following dependencies in sync with obs-worker package
BuildRequires: glibc-devel
+%if 0%{?suse_version}
+BuildRequires: glibc-devel-static
+%else
+BuildRequires: glibc-static
+%endif
Requires: bash
Requires: perl
Requires: binutils
@@ -134,6 +139,8 @@ chroot or a secure virtualized
%build
# initvm
make CFLAGS="$RPM_BUILD_FLAGS" initvm-all
+# host_arch
+make CFLAGS="$RPM_BUILD_FLAGS" host_arch-all
%if 0%{?fedora} == 23
%global debug_package %{nil}
@@ -145,6 +152,11 @@ make DESTDIR=$RPM_BUILD_ROOT initvm-install
strip $RPM_BUILD_ROOT/usr/lib/build/initvm.*
export NO_BRP_STRIP_DEBUG="true"
chmod 0644 $RPM_BUILD_ROOT/usr/lib/build/initvm.*
+# host_arch
+make DESTDIR=$RPM_BUILD_ROOT host_arch-install
+strip $RPM_BUILD_ROOT/usr/lib/build/host_arch
+export NO_BRP_STRIP_DEBUG="true"
+chmod 0644 $RPM_BUILD_ROOT/usr/lib/build/host_arch
# main
make DESTDIR=$RPM_BUILD_ROOT install