How to build third-party sources into deb packages using armbian tools?


Recommended Posts

I don't want to torture my SD card with full OS image rewrites or compilation on the device itself, so I would like to cross-compile.


I just set up a ubuntu/bionic64 VirtualBox through Vagrant using


Currently, I don't want to build entire image or kernel from scratch but I noticed that and related scripts contain many convenience functions and tools. I already started once to let it prepare the virtual machine for cross-compile tasks and it successfully installed all the dependencies.


I got especially interested in extras-buildpkgs folder. As I understand, I can put my own package descriptions there and Armbian tools will find it and offer to create packages for it?


Is there any simple way to leverage Armbian tools to create a deb package of a single third party program (ZynAddSubFx, to be more exact - I already have it compiled once directly on an ARM device, so I know it's doable) without compiling the kernel or OS? 


Ideally, I would like to get the "make install" results of the software to be collected into a deb package, so I can just install it on the target machine (NanoPi Neo2, to be specific).

Link to post
Share on other sites
Donate and support the project!

9 hours ago, midix said:

I got especially interested in extras-buildpkgs folder. As I understand, I can put my own package descriptions there and Armbian tools will find it and offer to create packages for it?

This part was not designed for end-user based packages. Absolutely agree that it's nice to have but would require some RFC, while our resources are ATM too low for such changes.


Currently, you need to make use of chroot compilation with your own script, this way:

Link to post
Share on other sites

It would be nice if the SDK could easily build deb packages, similar to openwrt's SDK.  I checked into but didn't mess with distcc setup.  Larger projects will need distcc or much patience.


This is sort of what I do to "cross-compile" deb packages.  You still need to build an image but you don't have to use it.  You can just copy your deb packages over to target os.


To get make install results into deb package, you need to use some sort of debian package builder.  Many options, guides, and tutorials are available online.  The example below uses dpkg-deb.


After you build initial image, you can speed up image building by setting clean level: ./compile CLEAN_LEVEL=""


Needs a small patch to SDK, as we need a way to get out the debs (or use another method, like network).

diff --git a/lib/ b/lib/
index a99163e..bea81fc 100644
--- a/lib/
+++ b/lib/
@@ -110,7 +110,7 @@ customize_image()
        chmod +x $SDCARD/tmp/
        mkdir -p $SDCARD/tmp/overlay
        # util-linux >= 2.27 required
-       mount -o bind,ro $SRC/userpatches/overlay $SDCARD/tmp/overlay
+       mount -o bind $SRC/userpatches/overlay $SDCARD/tmp/overlay
        display_alert "Calling image customization script" "" "info"
        chroot $SDCARD /bin/bash -c "/tmp/ $RELEASE $LINUXFAMILY $BOARD $BUILD_DESKTOP"
        umount $SDCARD/tmp/overlay

In userpatches/, drop your compile code.  Or for multiple packages, do something like:

for FN in /tmp/overlay/packages/*; do
        source $FN

Add your compile script.  Here is a hello world example, copy to userpatches/overlay/packages/helloworld:

#!/bin/sh -e
# example based on

MAINTAINER="lrrr <>"

cat <<-EOF > /tmp/hw.c
#include <stdio.h>
int main(void){
        printf("Hello world!\n");
        return 0;

mkdir -p ${BDIR}/usr/local/bin
gcc -Wall /tmp/hw.c -o ${BDIR}/usr/local/bin/$PACKAGE

mkdir -p ${BDIR}/DEBIAN
cat <<-EOF > ${BDIR}/DEBIAN/control
Package: $PACKAGE
Version: $VERSION
Section: base
Priority: optional
Architecture: $ARCH
Maintainer: $MAINTAINER
Description: Hello World
 When you need some sunshine, just run this
 small program!

dpkg-deb --build $BDIR

# requires armbian SDK mod for /tmp/overlay (rw)
mv -v ${BDIR}.deb /tmp/overlay

rm -fr ${BDIR} hw.c


Link to post
Share on other sites

Thanks for the helpful hints.


For now, I managed to create something hacky using the following approach:

In I commented out the line
# rm -rf $SDCARD


So now I had left valid rootfs and I could do


mount -t proc chproc $armccrootpath/proc
mount -t sysfs chsys $armccrootpath/sys
mount -t devtmpfs chdev $armccrootpath/dev || mount --bind /dev $armccrootpath/dev
mount -t devpts chpts $armccrootpath/dev/pts

cp /usr/bin/qemu-aarch64-static $armccrootpath/usr/bin/
chroot $armccrootpath


From there, I continued as usual and was able to compile ZynAddSubFx. I tried to create a deb using checkinstall tool, but unfortunately it failed during tar process and complained about many missing Voice files. So I gave up, zipped entire zynaddsubfx folder with build results and just copied it over to nanopineo2 and ran `make install` there. It worked just fine at the end.

Link to post
Share on other sites

I usually use the cached rootfs in cache/rootfs.  Extract, then mount pseudo-filesystems and copy over static qemu like you posted.


Quick hacks are good if they get the job done.  :)


Another easy way to get chroot with and do things manually:

echo "Entering chroot for $1 $2 $3"

Before you exit chroot, copy your debs/files with another shell, network, etc.

Link to post
Share on other sites
On 9/26/2018 at 7:50 PM, midix said:

chroot $armccrootpath


From there, I continued as usual ...


When I try to do the same, chrooting fails with:

chroot: failed to run command ‘/bin/bash’: No such file or directory


So I wonder, how that chroot should work anyhow, as in /bin and /usr/bin are now ARM-binaries, while the compiling host needs amd64 binaries.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.