[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#920868: please add (some) support to cross-compile debian-installer



Package: debian-installer
Version: 20190118
Severity: wishlist
Tags: patch

Dear Maintainer,

It would be handy to cross-compile the
debian-installer on amd64 for other architectures.

The patch below aims to suppress some errors
related to build-dependency check and to
packages of a foreign architecture.

I added a new variable 'NO_CHECK_BUILD_DEPS' 
in the makefile to inhibit the build-dependency 
check if needed (dpkg-buildpackage checks build 
dependencies and the makefile calls check-builddeps
as well)

The support of cross-compilation is still partial :
- it doesn't address mklibs (but mklibs-copy is in use
nowadays)
- not all use cases are tested

Thanks in advance for your comments !

Regards,
JH Chatenet

diff -Naur a/build/Makefile b/build/Makefile
--- a/build/Makefile
+++ b/build/Makefile
@@ -309,7 +309,10 @@
 $(STAMPS)tree-unpack-$(targetstring)-stamp: $(STAMPS)get_udebs-$(targetstring)-stamp
 	dh_testroot
 	@[ -d ../debian ] || { echo "directory '../debian' not found; complete source of 'debian-installer' package is required"; false; }
-	cd .. && dpkg-checkbuilddeps
+
+ifeq ($(NO_CHECK_BUILD_DEPS),)
+	cd .. && dpkg-checkbuilddeps -a $(DEB_HOST_ARCH)
+endif
 	@rm -f $@
 
 	# This build cannot be restarted, because dpkg gets confused.
@@ -322,6 +325,9 @@
 	# Only dpkg needs this stuff, so it can be removed later.
 	mkdir -p $(DPKGDIR)/updates/
 	touch $(DPKGDIR)/available
+ifneq ($(CROSS),)
+	echo $(ARCH) > $(DPKGDIR)/arch
+endif
 
 ifdef TRANSSTATUS
 	# Include translation status file; warn if older than 2 weeks.
@@ -499,6 +505,9 @@
 	mkdir -p $(EXTRAUDEBSDIR)
 	mkdir -p $(EXTRAUDEBSDPKGDIR)/info $(EXTRAUDEBSDPKGDIR)/updates
 	touch $(EXTRAUDEBSDPKGDIR)/status $(EXTRAUDEBSDPKGDIR)/available
+ifneq ($(CROSS),)
+	echo $(ARCH) > $(EXTRAUDEBSDPKGDIR)/arch
+endif
 
 ifdef EXTRADRIVERS
 	# Unpack the udebs of additional driver disks, so mklibs runs on them too.
diff -Naur a/build/README b/build/README
--- a/build/README
+++ b/build/README
@@ -477,6 +477,9 @@
 PRESEED
   An initrd preseed file to put in the initrd.
 
+NO_CHECK_BUILD_DEPS
+  If set to a non empty value, this variable inhibits build dependency
+  checks.
 
 Rules invoked from the various targets:
 
diff -Naur a/build/util/gen-sources.list.udeb b/build/util/gen-sources.list.udeb
--- a/build/util/gen-sources.list.udeb	
+++ b/build/util/gen-sources.list.udeb
@@ -34,14 +34,33 @@
 	local file
 	for file in $@; do
 		[ -s $file ] || continue
-		grep '^deb[[:space:]]' $file | \
-		   grep -v '^deb[[:space:]]\+cdrom:' | \
-		   sed 's,^deb \[[^]]*\] ,deb ,' | \
-		   grep -v '\(security.debian.org\|volatile.debian.\(net\|org\)\)' | \
-		   grep '[[:space:]]main' | \
-		   awk '{print $1 " " $2}' | \
-		   sed 's,^deb file,deb copy,' | \
-		   sed 's,/* *$,,'
+		if [ -n "$CROSS" ] && [ -n "$DEB_HOST_ARCH" ]; then
+			grep '^deb[[:space:]]' $file | \
+			   sed -n -e "
+			     # Do not consider mirrors which don't carry the requested architecture
+			     # They might cause errors if they are signed with another keyring
+			     # No arch=... option : all architectures should be there
+			     /^deb[[:space:]]\+\[[^]]*arch[[:space:]]*=/! p
+			     # There is an arch=... option : is the requested architecture present ?
+			     /^deb[[:space:]]\+\[[^]]*arch[[:space:]]*=[[:space:]]*\([^] ]\+,\)*${DEB_HOST_ARCH}\(,[^] ]\+\)*\([[:space:]]\+\|\]\)/p
+			   "  | \
+			   grep -v '^deb[[:space:]]\+cdrom:' | \
+			   sed 's,^deb \[[^]]*\] ,deb ,' | \
+			   grep -v '\(security.debian.org\|volatile.debian.\(net\|org\)\)' | \
+			   grep '[[:space:]]main' | \
+			   awk '{print $1 " " $2}' | \
+			   sed 's,^deb file,deb copy,' | \
+			   sed 's,/* *$,,'
+		else
+			grep '^deb[[:space:]]' $file | \
+			   grep -v '^deb[[:space:]]\+cdrom:' | \
+			   sed 's,^deb \[[^]]*\] ,deb ,' | \
+			   grep -v '\(security.debian.org\|volatile.debian.\(net\|org\)\)' | \
+			   grep '[[:space:]]main' | \
+			   awk '{print $1 " " $2}' | \
+			   sed 's,^deb file,deb copy,' | \
+			   sed 's,/* *$,,'
+		fi
 	done
 }
 
diff -Naur a/build/util/pkg-list b/build/util/pkg-list
--- a/build/util/pkg-list
+++ b/build/util/pkg-list
@@ -66,6 +66,8 @@
 		-o Dir::Etc::Preferences=./preferences.udeb.local \\
 		-o Dir::State=./apt.udeb/state \\
 		-o Dir::State::Status=./apt.udeb/state/status \\
+		-o Apt::Architecture=$deb_host_arch \\
+		-o Apt::Architectures::=$deb_host_arch \\
 		-o Dir::Cache=./apt.udeb/cache $params 2>/dev/null`;
 }
 
@@ -284,6 +286,7 @@
 	debug -1;
 }
 foreach my $p (sort keys %$collect) {
+	$p =~ s/:.*//;
 	print "$p\n" unless $exclude->{$p} || $parentcollect->{$p};
 
 	# Warn about missing deps.
diff -Naur a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -10,9 +10,9 @@
 # Base build dependencies:
 	debhelper (>= 7.0.0),
 #		Of course.
-	apt (>= 0.8.16),
+	apt:native (>= 0.8.16),
 # 		Used for downloading udebs.
-	apt-utils,
+	apt-utils:native,
 # 		apt-ftparchive is used for including localudebs.
 	gnupg,
 #		New versions of apt need gnupg for security checks.
@@ -30,7 +30,7 @@
 	docbook-xml,
 	docbook-xsl,
 #		The d-i internals manual is in DocBook XML.
-	libbogl-dev,
+	libbogl-dev:native,
 #		For bdftobogl used in font reduction.
 #	
 # Library build dependencies:
@@ -40,7 +40,7 @@
 #		calls in directfb. For now, this is done by setting EXTRAFILES.
 # 
 # Filesystem tools:
-	genext2fs (>= 1.3-7.1),
+	genext2fs:native (>= 1.3-7.1),
 #		For creating ext2 filesystems without being root.
 #		1.3-7.1 fixes issues on several arches.
 	e2fsprogs,
@@ -48,9 +48,9 @@
 #		them.
 #		Lintian: Yes, we know it's essential. We prefer not to
 #		count on it remaining so.
-	mklibs (>= 0.1.40), mklibs-copy (>= 0.1.40),
+	mklibs (>= 0.1.40), mklibs-copy:native (>= 0.1.40),
 #		We use mklibs for library reduction.
-	genisoimage [!s390 !s390x],
+	genisoimage:native [!s390 !s390x],
 #		For making mini isos.
 	genromfs [sparc sparc64],
 #		Used for creating sparc floppies (which are not built by
@@ -113,7 +113,7 @@
 	grub-efi-arm64-bin [arm64],
 	grub-efi-ia32-bin [i386],
 	grub-efi-arm-bin [armhf],
-	grub-common [amd64 arm64 i386], xorriso,
+	grub-common [amd64 arm64 i386], xorriso:native,
 #		Used to make EFI bootable images
 	grub-ieee1275-bin [ppc64el],
 #		IEEE1275 bootloader support.
diff -Naur a/debian/rules b/debian/rules
--- a/debian/rules
+++ b/debian/rules
@@ -1,6 +1,26 @@
 #! /usr/bin/make -f
 
-ARCH=$(shell dpkg-architecture -qDEB_BUILD_ARCH)
+# Minimal support for cross-building
+
+DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+
+ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+CROSS ?= yes
+endif
+
+export CROSS
+
+DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
+DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
+DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM)
+DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
+
+export DEB_HOST_ARCH DEB_HOST_ARCH_OS DEB_HOST_GNU_CPU DEB_HOST_GNU_SYSTEM DEB_HOST_MULTIARCH
+
+
+ARCH=$(shell dpkg-architecture -qDEB_HOST_ARCH)
 VERSION=$(shell LC_ALL=C dpkg-parsechangelog | grep ^Version: | cut -d ' ' -f 2)
 DATE=$(shell echo $(VERSION) | cut -d '.' -f 1)
 SOURCE_DATE_EPOCH = $(shell date -d "$$(dpkg-parsechangelog -SDate)" +%s)


Reply to: