d1man/05-building-packages.md

151 lines
4.1 KiB
Markdown

Building deb packages
=====================
Using jenkins-debian-glue, we can set up a build pipeline for any
version controlled software by creating a `debian` directory in the
repository. Its structure looks like:
```
debian
+-- changelog
+-- compat
+-- control
+-- gbp.conf
+-- postinst
+-- preinst
+-- rules
+-- source
+-- format
```
These files are equivalend to any standard Debian/Devuan package.
Once the repository is set up, and contains a `debian` directory, we are
able to construct the _deb_ package build pipeline. It is first
necessary to create a Jenkins `-source` job, followed by a `-binaries`
job, and finishing with a `-repos` job. Further on, for easier reading,
we will consider that we are building a package called `linux-sunxi`,
which is a Linux kernel package dedicated to LIME2 Arm boards.
-source
-------
The -source job is responsible to fetch the software (package) sources
and distribute them to any build executor nodes that are needed to build
the package.
These jobs need the following configuration:
* String parameters:
* `release` (The codename of the suite): `ascii-proposed`
* `distribution` (The upstream Devuan suite codename): `ascii`
* Git repository URL:
* `https://git.devuan.org/devuan-packages/linux-sunxi`
* + branch(es) to be built: `suites/ascii`
* Execution shell script:
/usr/bin/generate-git-snapshot
* Post-build triggers:
* Projects to build: `linux-sunxi-binaries`
* Predefined parameters:
```
release=${release}
distribution=${distribution}
```
-binaries
---------
The -binaries job is responsible for compiling the source code and
creating _deb_ packages out of the compiled code. The packages are
compiled on each preconfigured build executor node, for each necessary
CPU architecture.
These jobs need the following configuration:
* String parameters (these are passed through by the `-source` job):
* `release` (The codename of the suite): `ascii-proposed`
* `distribution` (The upstream Devuan suite codename): `ascii`
* Configuration matrix (for the CPU architectures)
* `architecture`: `amd64 armhf arm64`
* `label`: `amd64 armf arm64`
* + Generic combination filter:
```
(architecture=="amd64").implies(label=="amd64") && (architecture=="armhf").implies(label=="armhf") && (architecture=="all").implies(label=="all") && (architecture=="armel").implies(label=="armel") && (architecture=="arm64").implies(label=="arm64")
```
* Copy artifacts from another project:
* Name: `linux-sunxi-source`
* Artifacts to copy: `*`
* Execution shell script:
export BUILD_ONLY=true
/usr/bin/build-and-provide-package
* Post-build triggers:
* Projects to build: `linux-sunxi-repos`
* Predefined parameters:
```
release=${release}
distribution=${distribution}
architecture=${architecture}
label=${label}
```
* Archive artifacts:
* `*.gz,*.bz2,*.xz,*.deb,*.udeb,*.dsc,*.changes,*.buildinfo`
-repos
------
The -repos job is responsible to take the built _deb_ packages and ship
them off to dak to create or append to an APT repository.
These jobs need the following configuration:
* String parameters (these are passed through by the `-binaries` job):
* `release`
* `distribution`
* `architecture`
* `label`
* Copy artifacts from another project:
* Name: `linux-sunxi-binaries/architecture=$architecture,label=$label`
* Artifacts to copy: `*`
* Execution shell script:
if [ -n "$gitlabBranch" ] ; then
export codename=$gitlabBranch
fi
. /etc/jenkins/debian_glue
export KEY_ID
for i in architecture* ; do
#cp $i/* .
cd $i
debsign --no-re-sign -k$KEY_ID *.changes || true
debsign --no-re-sign -k$KEY_ID *.dsc || true
cd ..
done
#find . -type d -name 'architecture*' | xargs rm -r
#debsign --no-re-sign -k$KEY_ID *.changes
#debsign --no-re-sign -k$KEY_ID *.dsc
ssh dak@repo.devuan.org mkdir /home/dak/jenkins/$BUILD_TAG
scp -r * dak@repo.devuan.org:/home/dak/jenkins/$BUILD_TAG
ssh dak@repo.devuan.org dak_add_pkgs -s $codename -c main $BUILD_TAG
Once this pipeline completes, the repository is ready to be used, but it
is also possible to utilize **amprolla** for additional customization.