Cross-building from amd64

Build nss (3.25-1)

  1. Download source
  2. Apply the following patches from rebootstrap:
       1 --- a/debian/rules
       2 +++ b/debian/rules
       3 @@ -33,10 +34,9 @@
       4  endif
       5  ifeq ($(origin CXX),default)
       6  TOOLCHAIN += CXX=$(DEB_HOST_GNU_TYPE)-g++
       7 +CXX := $(DEB_HOST_GNU_TYPE)-g++
       8  endif
       9 -ifeq ($(origin CCC),default)
      10 -TOOLCHAIN += CCC=$(DEB_HOST_GNU_TYPE)-g++
      11 +TOOLCHAIN += CCC=$(CXX)
      12 -endif
      13  ifeq ($(origin RANLIB),default)
      14  TOOLCHAIN += RANLIB=$(DEB_HOST_GNU_TYPE)-ranlib
      15  endif
    
       1 --- a/debian/rules
       2 +++ b/debian/rules
       3 @@ -108,6 +108,7 @@
       4                 NSPR_LIB_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
       5                 BUILD_OPT=1 \
       6                 NS_USE_GCC=1 \
       7 +               NSS_ENABLE_WERROR=0 \
       8                 OPTIMIZER="$(CFLAGS) $(CPPFLAGS)" \
       9                 LDFLAGS='$(LDFLAGS) $$(ARCHFLAG) $$(ZDEFS_FLAG)' \
      10                 DSO_LDOPTS='-shared $$(LDFLAGS)' \
    
  3. Build with
    DEB_BUILD_OPTIONS=nocheck \
    DEB_BUILD_PROFILES="cross nocheck" \
    sbuild -c unstable-amd64-sbuild --host=m68k \
    --extra-repository='deb http://snapshot.debian.org/archive/debian-ports/20160803T183328Z unstable main' \
    --extra-package=/home/james/src/build-essential/crossbuild-essential-m68k_12.2_all.deb

Build libidn (1.33-1)

  1. Download source
  2. Change the Build-Depends to
    Build-Depends: debhelper (>= 9), gcj-jdk [!arm !hppa !hurd-i386 !mips64el] <!stage1>, fastjar [!arm !hppa !hurd-i386 !mips64el] <!stage1>, dh-autoreconf, autopoint (>= 0.19.3), chrpath <cross>
    The differences should be adding the stage1 exclusions to gcj-jdk and fastjar, and adding chrpath for cross
  3. Apply the following patch (some of this is probably redundant, but it seems to work)

    In fact, I suspect that adding --add-depends=libc6:m68k to the build would make this not needed, and as far as I can tell is the only significant difference between a clean chroot and the one used by rebootstrap.

       1 --- a/debian/rules
       2 +++ b/debian/rules
       3 @@ -26,6 +26,7 @@
       4                 --with-packager-version=$(CFG_VERS) \
       5                 --with-packager-bug-reports=https://bugs.debian.org/ \
       6                 --disable-silent-rules \
       7 +               --disable-rpath \
       8                  $(ENABLE_JAVA)
       9  
      10  override_dh_auto_install:
      11 @@ -36,6 +37,17 @@
      12         mv debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libidn.so.* debian/tmp/lib/$(DEB_HOST_MULTIARCH)/
      13         rm -f debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libidn.so
      14         ln -s /lib/$(DEB_HOST_MULTIARCH)/libidn.so.11 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/libidn.so
      15 +# Somehow idn is linked with -rpath, which breaks dpkg-shlibdeps
      16 +ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
      17 +       chrpath -d debian/tmp/usr/bin/idn
      18 +endif
      19 +
      20 +ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
      21 +override_dh_shlibdeps:
      22 +# Horrible horrible cross-build hack
      23 +# Not sure why rebootstrap succeeds...
      24 +       dh_shlibdeps -- -l/usr/$(DEB_HOST_MULTIARCH)/lib
      25 +endif
      26  
      27  override_dh_install:
      28         dh_install
    
  4. Build with
    DEB_BUILD_OPTIONS=nocheck \
    DEB_BUILD_PROFILES="cross nocheck" \
    sbuild -c unstable-amd64-sbuild --host=m68k \
    --extra-repository='deb http://snapshot.debian.org/archive/debian-ports/20160803T183328Z unstable main' \
    --extra-package=/home/james/src/build-essential/crossbuild-essential-m68k_12.2_all.deb

Build openjdk-8

  1. Get the latest source
  2. Apply the following patch (not all of the :native additions may be needed, but this worked for me)
       1 --- a/debian/control
       2 +++ b/debian/control
       3 @@ -3,17 +3,18 @@
       4  Priority: optional
       5  Maintainer: OpenJDK Team <openjdk@lists.launchpad.net>
       6  Uploaders: Matthias Klose <doko@ubuntu.com>
       7 -Build-Depends: debhelper (>= 9), quilt, m4, lsb-release, zip, unzip,
       8 -  sharutils, gawk, cpio, pkg-config, procps, wdiff, fastjar (>= 2:0.96-0ubuntu2),
       9 -  autoconf (>= 2.69), automake, autotools-dev, ant, ant-optional,  libtool,
      10 -  g++-5,
      11 -  openjdk-8-jdk | openjdk-7-jdk,
      12 +Build-Depends: debhelper:native (>= 9), quilt:native, m4:native, lsb-release:native, zip:native, unzip:native,
      13 +  sharutils:native, gawk:native, cpio:native, pkg-config, procps:native, wdiff:native, fastjar:native (>= 2:0.96-0ubuntu2),
      14 +  autoconf (>= 2.69), automake, autotools-dev, ant:native, ant-optional:native,  libtool,
      15 +  g++-5 <!cross>,
      16 +  g++-5-m68k-linux-gnu [m68k] <cross>,
      17 +  openjdk-8-jdk <!cross> | openjdk-7-jdk <!cross>,
      18    libxtst-dev, libxi-dev, libxt-dev, libxaw7-dev, libxrender-dev, libcups2-dev, libasound2-dev, liblcms2-dev, libfreetype6-dev (>= 2.2.1), libgtk2.0-dev, libxinerama-dev, libkrb5-dev, xsltproc, libpcsclite-dev,
      19    libffi-dev, 
      20    zlib1g-dev, libattr1-dev, libpng-dev, libjpeg-dev, libgif-dev, libpulse-dev (>= 0.9.12) [!alpha], systemtap-sdt-dev [!sh4],
      21    libnss3-dev (>= 2:3.17.1), tzdata,
      22 -  mauve, jtreg, xvfb, xauth, xfonts-base, libgl1-mesa-dri [!x32], twm | metacity, twm | dbus-x11, x11-xkb-utils,
      23 -  time, openjdk-8-jdk-headless <cross>, dpkg-dev (>= 1.17.14),
      24 +  mauve <!nocheck>, jtreg <!nocheck>, xvfb <!nocheck>, xauth <!nocheck>, xfonts-base <!nocheck>, libgl1-mesa-dri [!x32] <!nocheck>, twm <!nocheck> | metacity <!nocheck>, twm <!nocheck> | dbus-x11 <!nocheck>, x11-xkb-utils <!nocheck>,
      25 +  time:native, openjdk-8-jdk-headless:native <cross>, dpkg-dev:native (>= 1.17.14),
      26  Standards-Version: 3.9.8
      27  Homepage: http://openjdk.java.net/
      28  Vcs-Bzr: http://bazaar.launchpad.net/~openjdk/openjdk/openjdk8
      29 --- a/debian/rules
      30 +++ b/debian/rules
      31 @@ -42,8 +42,10 @@
      32  hotspot_archs  = amd64 i386 arm64 ppc64 ppc64el kfreebsd-amd64 kfreebsd-i386
      33  # FIXME: use bootcycle builds for zero archs?
      34  bootcycle_build  = $(if $(filter $(DEB_HOST_ARCH), $(hotspot_archs)),yes)
      35 +BINUTILS_ARCH =
      36  ifneq ($(DEB_HOST_ARCH),$(DEB_BUILD_ARCH))
      37    bootcycle_build  =
      38 +  BINUTILS_ARCH = $(DEB_HOST_MULTIARCH)-
      39  endif
      40  
      41  shark_archs    = amd64 i386 kfreebsd-amd64 kfreebsd-i386
      42 @@ -2292,20 +2287,20 @@
      43             id=$$(echo $$i | sed -r 's,debian/[^/]+,$(d_dbg)/usr/lib/debug,'); \
      44             echo strip $$i; \
      45             mkdir -p $$(dirname $$id); \
      46 -           objcopy --only-keep-debug $$i $$id; \
      47 +           $(BINUTILS_ARCH)objcopy --only-keep-debug $$i $$id; \
      48             chmod 644 $$id; \
      49 -           strip --remove-section=.comment --remove-section=.note \
      50 +           $(BINUTILS_ARCH)strip --remove-section=.comment --remove-section=.note \
      51               --strip-debug $$i; \
      52 -           objcopy --add-gnu-debuglink $$id $$i; \
      53 +           $(BINUTILS_ARCH)objcopy --add-gnu-debuglink $$id $$i; \
      54           else \
      55             d=usr/lib/debug/.build-id/$${b_id:0:2}; \
      56             f=$${b_id:2}.debug; \
      57             mkdir -p $(d_dbg)/$$d; \
      58 -           objcopy --only-keep-debug --compress-debug-sections $$i $(d_dbg)/$$d/$$f; \
      59 +           $(BINUTILS_ARCH)objcopy --only-keep-debug --compress-debug-sections $$i $(d_dbg)/$$d/$$f; \
      60             chmod 644 $(d_dbg)/$$d/$$f; \
      61 -           strip --remove-section=.comment --remove-section=.note $$i; \
      62 +           $(BINUTILS_ARCH)strip --remove-section=.comment --remove-section=.note $$i; \
      63             pushd $(d_dbg)/$$d >/dev/null; \
      64 -           objcopy --add-gnu-debuglink $$f $(CURDIR)/$$i; \
      65 +           $(BINUTILS_ARCH)objcopy --add-gnu-debuglink $$f $(CURDIR)/$$i; \
      66             popd >/dev/null; \
      67           fi; \
      68         done
    
  3. Build with
    DEB_BUILD_OPTIONS=nocheck \
    DEB_BUILD_PROFILES="cross nocheck" \
    sbuild -c unstable-amd64-sbuild --host=m68k \
    --extra-repository='deb http://snapshot.debian.org/archive/debian-ports/20160803T183328Z unstable main' \
    --extra-package=/home/james/src/build-essential/crossbuild-essential-m68k_12.2_all.deb \
    --extra-package=/home/james/src/nss/libnss3_3.25-1_m68k.deb \
    --extra-package=/home/james/src/nss/libnss3-dev_3.25-1_m68k.deb \
    --extra-package=/home/james/src/libidn/libidn11_1.33-1_m68k.deb \
    --debbuildopt=-d
    It seems the -d is needed for dpkg-buildpackage, as dpkg-checkbuilddeps thinks B-Ds are missing, despite sbuild's apt resolver succeeding.