Skip to content

Commit 40fb999

Browse files
authored
Merge pull request #44 from JedMeister/dev-docs
Update Dev docs
2 parents be7a77a + 750abd2 commit 40fb999

24 files changed

Lines changed: 925 additions & 540 deletions

docs/README.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ lines of "code"::
6868
root@tkldev fab/products$ git-clone https://github.com/turnkeylinux-apps/lamp
6969
Cloning into lamp...
7070

71-
root@tkldev fab/products$ wc -l $(find lamp -type f|grep -v '\.git\|png\|jpg\|changelog\|README.rst\|txt$')
71+
root@tkldev fab/products$ wc -l $(find lamp -type f | grep -v '\.git\|png\|jpg\|changelog\|README.rst\|txt$')
7272
11 lamp/plan/main
7373
1 lamp/overlay/etc/skel/.bashrc.d/php-xdebug
7474
17 lamp/overlay/etc/apache2/mods-available/status.conf
@@ -100,7 +100,7 @@ There are no strings attached. If you don't want to, you don't have to
100100
include common TurnKey functionality or any of the custom TurnKey
101101
components.
102102

103-
Sadly, we've gotten into the nasty habit of prepending TKL - the TurnKey
103+
Sadly, we've gotten into the nasty habit of pre-pending TKL - the TurnKey
104104
Linux initials - to all things TurnKey but don't let that fool you.
105105
Under the hood TKLDev is 100% general purpose.
106106

@@ -130,6 +130,5 @@ enough so anyone that wants to can jump in and make cool stuff happen.
130130
.. _common: https://github.com/turnkeylinux/common
131131
.. _Setup: ./getting-started/setup.rst
132132
.. _Hello world: ./getting-started/helloworld.rst
133-
.. _Tips and tricks: ./getting-started/tips.rst
133+
.. _Tips and tricks: ./tips/
134134
.. _Development: ./development/README.rst
135-

docs/advanced/building-appliances-offline.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ Building your Appliance
7676
-----------------------
7777

7878
Now you can build Core offline. It's almost identical to building appliances
79-
normally; you just need to explictly tell TKLDev to do it. We do that by
80-
setting the FAB_POOL environment variable. It shouldn't also be neccessary to
79+
normally; you just need to explicitly tell TKLDev to do it. We do that by
80+
setting the FAB_POOL environment variable. It shouldn't also be necessary to
8181
set the RELEASE but I'm going to demonstrate that for interest:
8282

8383
.. code-block:: bash
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
Building Packages from Source
2+
=============================
3+
4+
TKLDev includes most of the components needed to build Debian packages from
5+
source code OOTB. This can be useful if you want to test changes you've made
6+
to an existing package or create a new package - of your code or someone
7+
else's.
8+
9+
Environment variables
10+
---------------------
11+
12+
```bash
13+
# assuming building for the current TurnKey/Debian version
14+
CODENAME=$(lsb_release -sc)
15+
```
16+
17+
Buildroot
18+
---------
19+
20+
A buildroot is a minimalist Debian [chroot][chroot] which provides an
21+
environment specifically for building packages. TurnKey uses our [bootstrap] as
22+
a base, then preinstalls some extra build related packages/tools.
23+
24+
It is highly recommended that you [generate a buildroot][gen-buildroot] using
25+
our tool. Do that like this:
26+
27+
```bash
28+
cd /turnkey
29+
git clone https://github.com/turnkeylinux/buildroot.git
30+
cd buildroot
31+
make install
32+
```
33+
34+
Always run `make clean` if/when you rebuild the buildroot.
35+
36+
Note that using a pre-built buildroot will speed up package building,
37+
although strictly speaking is not required. A vanilla bootstrap may
38+
be used, as the dependencies noted in the [Build-Depends][build-deps] section
39+
of the package control file will be installed into the buildroot prior
40+
to building the package.
41+
42+
Pool configuration
43+
------------------
44+
45+
[Pool][pool] is the custom TurnKey tool for building packages. With the
46+
exception of a buildroot, TKLDev should have (most of) pool configured out of
47+
the box.
48+
49+
All you need to do is build the buildroot as linked above and you are ready
50+
to go.
51+
52+
Build a package with pool
53+
-------------------------
54+
55+
I'll use Turnkey's "inithooks" package as an example:
56+
57+
First, clone or copy your source code to an appropriate location. We use
58+
/turnkey/public, but it can be any directory you like:
59+
60+
```bash
61+
mkdir -p /turnkey/public
62+
cd /turnkey/public
63+
git clone https://github.com/turnkeylinux/inithooks.git
64+
```
65+
66+
Then register the source code with Pool and build the package:
67+
68+
```bash
69+
cd pools/${CODENAME}
70+
pool-register /turnkey/public/inithooks
71+
pool-get . inithooks
72+
```
73+
74+
Assuming that the build process completes successfully, you will find the new
75+
Debian package in the pool directory:
76+
77+
```bash
78+
root@tkldev pools/bookworm# ls
79+
inithooks_2.2.1_all.deb
80+
```
81+
If you wish, the package can be installed on the local system using apt:
82+
83+
```bash
84+
apt install ./inithooks_2.2.1_all.deb
85+
```
86+
87+
Alternatively, the package can be used when building an appliance by adding the
88+
package name to the appliance plan (if required) and setting `FAB_POOL=y` prior
89+
to appliance build. E.g.:
90+
91+
```bash
92+
export FAB_POOL=y
93+
make
94+
```
95+
96+
Package versioning
97+
------------------
98+
99+
By default, a Debian package will generate it's version from the heading of
100+
the debian/changelog. That's fine when building "stable" packages. However,
101+
when hacking on a package it can be useful to preserve each package iteration
102+
as you make changes. By default, that requires manual update to the changelog
103+
version for each rebuild - and remembering to do it.
104+
105+
To help out, our default buildroot includes our custom
106+
[auto version][autoversion] tool. As the name suggests, it can generate a unique
107+
version for you; each time you rebuild a package.
108+
109+
The requirements for autoversion to generate a custom version are:
110+
- package source code must be in a git repo
111+
- changes must be committed
112+
- the must not be a changelog in the source debian directory
113+
114+
If your package does already have a changelog, then move/remove it until you
115+
are ready for a new "stable" release.
116+
117+
The generated versions are nicest if your code has at least one annotated tag.
118+
See the [tags][tags] section of the [Git Pro][git-pro]online book for details
119+
about annotated tags. For example if package "foo" has the git HEAD tagged
120+
'v0.1', autoversion will generate version '0.1'. I.e. 'foo_0.1_all.deb'.
121+
122+
Further commits generate versions noting how many commits since the tag and
123+
the commit ID of HEAD. The new version string will be
124+
'<version_tag>+<commits_since_tag>+g<commit_id>'. E.g. if foo has 2 commits
125+
since the 'v0.1' tag and the HEAD commit ID is "59286ad", the new version will
126+
be "0.1+1+g59286ad" - i.e. 'foo_0.1+1+g59286ad_all.deb'.
127+
128+
It still works if there are no tags, but the versions are a bit ugly. They are
129+
in the form of '0+<YYYY>.<MM>.<DD>+<HH>.<MM>.<SS>+<commit_id>'. E.g.:
130+
'foo_0+2025.2.19+06.45.45+a42fea97_all.deb'.
131+
132+
The versions will sort properly, so it's no issue to push them to an apt
133+
package repo as is, but ideally you want to have a "nice" version number for a
134+
stable package. So either give it a new version tag - add/replace the
135+
changelog.
136+
137+
[chroot]: https://en.wikipedia.org/wiki/Chroot
138+
[bootstrap]: https://github.com/turnkeylinux/bootstrap
139+
[gen-buildroot]: https://github.com/turnkeylinux/buildroot?tab=readme-ov-file#build
140+
[build-deps]: https://github.com/turnkeylinux/inithooks/blob/master/debian/control#L5-L8
141+
[pool]: https://github.com/turnkeylinux/pool
142+
[autoversion]: https://github.com/turnkeylinux/autoversion?tab=readme-ov-file#map-git-commits-to-auto-versions-and-vice-versa
143+
[tags]: https://git-scm.com/book/en/v2/Git-Basics-Tagging
144+
[git-pro]: https://git-scm.com/book/en/v2

docs/advanced/building-packages-from-source.rst

Lines changed: 0 additions & 184 deletions
This file was deleted.

docs/advanced/optimized-builds.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For example, let's build Core as an LXC container (aka Proxmox) build. Note
3737
that if there isn't already a Core ISO and matching hash file in /mnt/isos
3838
buildtasks will download it from the TurnKey mirror.
3939

40-
Note: As of v14.2, you need to explictly use the full appliance-version name.
40+
Note: As of v14.2, you need to explicitly use the full appliance-version name.
4141
That is in the form:
4242

4343
APPLIANCE_NAME-VERSION-DEBIAN_CODENAME-ARCH

0 commit comments

Comments
 (0)