Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
185 lines (121 sloc) 5.09 KB

Building Packages from Source

As of v14.2, TKLDev includes all the components needed to build packages from souce code on the fly. This may be useful if you wish to test a piece of software which is unpackaged, but you want it packaged. It can also be useful if you wish to tweak an existing TurnKey package.

Please note that within these instructions, I make use of variables. If you follow this from start to finish in a single shell, then you won't have any issues. Please note though, that if you use multiple shells, or do it over multiple sessions, then you'll either need to redefine the variables, or substitue the real path/value.

Building packages - getting set up

Before you can build packages, you'll need a buildroot to build them in. A buildroot is essentially a minimalist Debian chroot. TurnKey may provide one for download at some point. But for now, you'll need to build it yourself.

Chanko - initial setup

Chanko is a tool to download and cache Debian packages and is a prerequisite for building our buildroot.

Initially, you will need to ensure that Chanko is fully configured and has been pre-loaded with the packages required for the buildroot. If you haven't already done it, please set up Chanko:


Note: this script may not yet be included in TKLDev, you may need to download and prepare the script first:

chmod +x /$SCRIPT

Loading Chanko

To load Chanko with the required packages, you'll need to create some plans which will note the required packages Chanko will need to download.

If you haven't already, please clone the buildroot source code:

cd /turnkey
git clone

Now to gather the plans for Chanko:

CODENAME=$(lsb_release -cs)

wget -O ${CHANKO}/plan/bootstrap-required \
wget -O ${CHANKO}/plan/bootstrap-base \
echo "/* buildroot */" >> ${CHANKO}/plan/buildroot
cat /turnkey/buildroot/plan/main >> ${CHANKO}/plan/buildroot
# extra TurnKey packages for buildroot:
cat >> ${CHANKO}/plan/buildroot <<EOF
# note the 'EOF' must be at the start of a line and the only thing on said line

Then download the packages like this:

cd ${CHANKO}
chanko refresh -a
echo y | chanko-get plan/bootstrap-base
echo y | chanko-get plan/bootstrap-required
echo y | chanko-get plan/buildroot

That will take a little while to do it's work, but hopefully not too long.

Build the buildroot

Once you've configured Chanko, it's really easy! You just need to do this:

CODENAME=$(lsb_release -cs)

cd /turnkey/buildroot
export FAB_POOL=y
export RELEASE=debian/$CODENAME

Put the buildroot in place

Once that has finished, you just need to move your buildroot to where Pool is expecting it to be:

CODENAME=$(lsb_release -cs)
mkdir -p ${BUILDROOT}

rsync --progress --delete -Hac build/root.patched/ ${BUILDROOT}

Once that's done, you can recover a bit of space by cleaning up:

make clean

Initialize Pool

The last step is to initialize Pool.

cd pools/
mkdir -p ${CODENAME}
pool-init ${FAB_PATH}/buildroots/${CODENAME}

# bugfix
mkdir -p /turnkey/fab/deckdebuilds/chroots/

Now we should be nearly ready to build!

Build a package from source

Now it's time to build a package! For this test I'm going to build TurnKey's inithooks package. So let's clone the source code first:

mkdir /turnkey/public
cd /turnkey/public
git clone

Now we'll register this source code with Pool and build the package:

cd pools/${CODENAME}

pool-register /turnkey/public/inithooks
pool-get . inithooks

And after a few moments, you should find the ccurl Debian package ready for use:

root@tkldev pools/stretch# ls

You can now move this .deb to where you wish to use it and install with dpkg. Alternatively, if you are building an appliance you can automatically include this package by adding the packagename to the plan and building with export FAB_POOL=y.

You can’t perform that action at this time.