Cross-build Debian Packages for mips64el Architecture
In this post, I will show how to cross-build an example Debian package, sl
, for mips64el
architecture on a amd64
host machine.
1 Install Prerequisites
On the host machine, install essential build tools for both amd64
host and mips64el
target.
1 | $ sudo apt install crossbuild-essential-mips64el build-essential |
2 Configure Signing Key
TBD
3 Configure deb-src
By default, Debian may not include working deb-src
sources in sources.list
. In order to download the source code for a package, you need to first manually add (or uncomment) deb-src
s.
1 | $ sudo apt edit-sources # edit sources |
You will see a text editor. If there are commented deb-src
s, uncomment them. If there are no deb-src
s at all, copy the deb
lines, duplicate them, and change deb
s to deb-src
s in the duplicated lines. The following configuration is a valid example sources.list
with deb-src
s.
1 | deb http://mirrors.tuna.tsinghua.edu.cn/debian buster main |
You then need to update list of packages on the host.
1 | $ sudo apt update |
4 Prepare the Source Code and Build Dependencies for the Target Package
1 | $ sudo dpkg --add-architecture mips64el # add mips64el architecture for build deps |
To build other packages, just replace
sl
with any other package name.
5 Build!
1 | $ cd sl-5.02 |
If you don’t want to sign the package, add
-us -uc
flags afterdpkg-buildpackage
.
Then we get a nice sl_5.02-1_mips64el.deb
package.
6 Upload the Package to the Target Machine and Run
1 | $ scp sl_5.02-1_mips64el.deb 192.168.1.149: # copy the package to the target machine 192.168.1.149 |
Voilà! You have a working sl
running on mips64el
target.