Cross-Building for WD Cloud and Node.js

  1. Summary of Cross-Building with Wheezy for WD Cloud Firmware Version 4 or Above
  2. Building Node.js Manually
  3. Package List

WD Cloud runs Debian Linux on ARM. When you build applications for other architectures, you need to use cross-building. I have successfully built a package on Ubuntu 14 by following this post with a few notes.

If you see an error message like:

Err http://ftp.debian.org wheezy-updates Release.gpg Could not resolve 'ftp.debian.org'

Then, copy /etc/resolv.conf into build/etc, e.g.,

sudo cp /etc/resolv.conf build/etc

Please check here for a list of WD Cloud firmware images.

Summary of Cross-Building with Wheezy for WD Cloud Firmware Version 4 or Above

# required for cross-building
apt-get install qemu-user-static
apt-get install binfmt-support

# folder for building
mkdir wdmc-build
cd wdmc-build

# download location can be found in http://support.wdc.com/product/download.asp?groupid=904&lang=en
wget http://download.wdc.com/gpl/gpl-source-wd_my_cloud-04.01.03-421.zip

unzip gpl-source-wd_my_cloud-04.01.03-421.zip packages/build_tools/debian/*
mkdir 64k-wheezy
cp -R packages/build_tools/debian/* ./64k-wheezy
echo '#!/bin/bash' > 64k-wheezy/build.sh
echo './build-armhf-package.sh --pagesize=64k $1 wheezy' >> 64k-wheezy/build.sh
chmod a+x 64k-wheezy/build.sh

cd 64k-wheezy
# the setup script will prompt for root password during chroot
./setup.sh bootstrap/wheezy-bootstrap_1.24.14_armhf.tar.gz build

sudo mv build/usr/bin/qemu-arm-static build/usr/bin/qemu-arm-static_orig
sudo cp /usr/bin/qemu-arm-static build/usr/bin/qemu-arm-static

# override build/etc/apt/sources.list
sudo echo "deb http://security.debian.org/ wheezy/updates main contrib non-free" > build/etc/apt/sources.list
sudo echo "deb-src http://security.debian.org/ wheezy/updates main contrib non-free" >> build/etc/apt/sources.list
sudo echo "deb http://ftp.debian.org/debian wheezy-updates main contrib non-free" >> build/etc/apt/sources.list
sudo echo "deb-src http://ftp.debian.org/debian wheezy-updates main contrib non-free" >> build/etc/apt/sources.list
sudo echo "deb http://ftp.debian.org/debian wheezy main contrib non-free" >> build/etc/apt/sources.list
sudo echo "deb-src http://ftp.debian.org/debian wheezy main contrib non-free" >> build/etc/apt/sources.list
# optional until you need to use backports packages
sudo echo "deb http://ftp.debian.org/debian wheezy-backports main contrib non-free" >> build/etc/apt/sources.list
sudo echo "deb http://ftp.debian.org/debian wheezy-backports main contrib non-free" >> build/etc/apt/sources.list

sudo cp /etc/resolv.conf build/etc

Then you can build by running build.sh with the package name, e.g.,

lang=bash
./build.sh joe

It will download the source package from the repository, cross-compile it, and build a deb file. The process could take over 10 minutes. Once it is successful, you can scp the .deb file to your router and install it with dpkg -i.

Building Node.js Manually

It is a little tricky to build Node.js because the source is not in the repository. I have tried to use a binary from http://nodejs.org/dist/v0.12.0/node-v0.12.0-linux-x86.tar.gz, but it failed with:
cannot execute binary file
You can follow the scripts to build it manually:

# setup utils
./setup.sh bootstrap/wheezy-bootstrap_1.24.14_armhf.tar.gz build
sudo mkdir -p build/root/binutils
sudo tar vfx binutils/binutils-armhf-64k.tar.gz -C build/root/binutils
sudo chroot build /bin/bash
cd /root/binutils
dpkg -i binutils_*.deb
dpkg -i binutils-multiarch_*.deb
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true
export LC_ALL=C
export LANGUAGE=C
export LANG=C
export DEB_CFLAGS_APPEND='-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE'
export DEB_BUILD_OPTIONS=nocheck
cd /root

# now the build environment is ready
wget http://nodejs.org/dist/v0.12.0/node-v0.12.0.tar.gz
tar vfxz node-v0.12.0.tar.gz
cd node-v0.12.0
./configure
make

# go back to original environment
exit

The binary is ready in build/root/node-v0.12.0/node for you to upload to the WD Cloud. You can upload to /usr/local/bin in your WD Cloud.

You also need to download npm and other components from http://nodejs.org/dist/v0.12.0/node-v0.12.0-linux-x86.tar.gz. Extract the files and put them in either /usr/local or /usr.

wget http://nodejs.org/dist/v0.12.0/node-v0.12.0-linux-x86.tar.gz
tar vfxz node-v0.12.0-linux-x86.tar.gz
cd node-v0.12.0-linux-x86
rm bin/node
cp -R include /usr/local
cp -R share /usr/local
cp -R lib /usr/local
cp -R bin /usr/local

Remember not to override the binary you have uploaded.

Package List

Below is a list of packages I have successfully built:

  • htop
  • joe
  • unrar
  • transmission
    • libcurl3-gnutls
    • libminiupnpc5
    • libnatpmp1
    • transmission-common
    • transmission-daemon
  • Node.js prerequisites
    • libc-ares2
    • libv8
  • python3-pip
    • libcurl3-gnutls
    • python2.6
    • python3
    • python3-pkg-resources
    • python3-setuptools
    • python-pkg-resources
    • python-setuptools
  • liberror-perl (required for git)
  • git
  • rrdtool (required for cacti)
  • virtual-mysql-client (required for cacti)
  • php5-mysql (required for cacti)
  • dbconfig-common (required for cacti)
  • libphp-adodb (required for cacti)
  • snmp (required for cacti)
  • php5-snmp (required for cacti)
  • cacti

Packages are uploaded to [https://app.box.com/wdcloud](https://app.box.com/wdcloud target=_blank).

Script to build:

Share