1
0
mirror of https://github.com/lineageos4microg/docker-lineage-cicd synced 2024-11-09 10:09:56 +01:00
docker-lineage-cicd/README.md

330 lines
14 KiB
Markdown
Raw Normal View History

2017-01-06 15:02:14 +01:00
# docker-lineage-cicd
2017-01-08 17:37:37 +01:00
2021-01-19 12:38:20 +01:00
Docker microservice for LineageOS Continuous Integration and Continuous Deployment
2017-01-08 17:37:37 +01:00
2018-03-08 08:00:01 +01:00
## Why Docker?
2017-01-08 17:37:37 +01:00
2018-03-08 08:00:01 +01:00
A fair number of dependencies is needed to build LineageOS, plus a Linux system
(and a discrete knowledge of it). With Docker we give you a minimal Linux build
system with all the tools and scripts already integrated, easing considerably
the creation of your own LineageOS build.
2017-01-08 17:50:24 +01:00
2018-03-08 08:00:01 +01:00
Moreover Docker runs also on Microsoft Windows and Mac OS, which means that
LineageOS can be built on such platforms without requiring a dual boot system
or a manual set up of a Virtual Machine.
2017-01-08 17:50:24 +01:00
2018-03-08 08:00:01 +01:00
## How do I install Docker?
2018-03-08 08:00:01 +01:00
The official Docker guides are well-written:
2018-06-22 16:59:57 +02:00
* Linux ([Ubuntu][docker-ubuntu], [Debian][docker-debian],
[CentOS][docker-centos] and [Fedora][docker-fedora] are officially
supported)
* [Windows 10/Windows Server 2016 64bit][docker-win]
* [Mac OS El Capitan 10.11 or newer][docker-mac]
2018-03-08 08:00:01 +01:00
If your Windows or Mac system doesn't satisfy the requirements (or if you have
2018-06-22 16:59:57 +02:00
Oracle VirtualBox installed, you can use [Docker Toolbox][docker-toolbox].
2018-03-08 08:00:01 +01:00
Docker Toolbox is not described in this guide, but it should be very similar to
the standard Docker installation.
2017-01-08 17:37:37 +01:00
2018-06-22 16:59:57 +02:00
Once you can run the [`hello-world` image][docker-helloworld] you're ready to
start!
2017-01-08 17:37:37 +01:00
2018-03-08 08:00:01 +01:00
## How can I build LineageOS?
2017-01-08 17:50:24 +01:00
2018-03-08 08:00:01 +01:00
This Docker image contains a great number of settings, to allow you to fully
2018-06-22 16:59:57 +02:00
customize your LineageOS build. Here you can find all of them, with the default
values between the brackets.
2017-06-06 14:37:18 +02:00
2018-03-08 08:00:01 +01:00
TL;DR - go to the [Examples](#examples)
2017-01-08 17:50:24 +01:00
2018-03-08 08:00:01 +01:00
### Fundamental settings
2017-01-08 17:50:24 +01:00
2018-06-22 16:59:57 +02:00
The two fundamental settings are:
2017-01-08 17:37:37 +01:00
* `BRANCH_NAME (lineage-16.0)`: LineageOS branch, see the branch list
2018-06-22 16:59:57 +02:00
[here][los-branches] (multiple comma-separated branches can be specified)
2018-03-08 08:00:01 +01:00
* `DEVICE_LIST`: comma-separated list of devices to build
Running a build with only these two set will create a ZIP file almost identical
to the LineageOS official builds, just signed with the test keys.
2018-06-22 16:59:57 +02:00
When multiple branches are selected, use `DEVICE_LIST_<BRANCH_NAME>` to specify
the list of devices for each specific branch (see [the examples](#examples)).
2018-03-08 08:00:01 +01:00
### Signature spoofing
2018-06-22 16:59:57 +02:00
There are two options for the [signature spoofing patch][signature-spoofing]
required for [microG][microg]:
* "Original" [patches][signature-spoofing-patches]
2018-03-08 08:00:01 +01:00
* Restricted patches
With the "original" patch the FAKE_SIGNATURE permission can be granted to any
user app: while it may seem handy, this is considered dangerous by a great
number of people, as the user could accidentally give this permission to rogue
apps.
A more strict option is the restricted patch, where the FAKE_SIGNATURE
permission can be obtained only by privileged system apps, embedded in the ROM
during the build process.
The signature spoofing patch can be optionally included with:
2018-06-22 16:59:57 +02:00
* `SIGNATURE_SPOOFING (no)`: `yes` to use the original patch, `restricted` for
the restricted one, `no` for none of them
2018-03-08 08:00:01 +01:00
If in doubt, use `restricted`: note that packages that requires the
FAKE_SIGNATURE permission must be embedded in the build by adding them in
* `CUSTOM_PACKAGES`
Extra packages can be included in the tree by adding the corresponding manifest
XML to the local_manifests volume.
### Proprietary files
Some proprietary files are needed to create a LineageOS build, but they're not
included in the LineageOS repo for legal reasons. You can obtain these blobs in
three ways:
2018-06-22 16:59:57 +02:00
* by [pulling them from a running LineageOS][blobs-pull]
* by [extracting them from a LineageOS ZIP][blobs-extract]
* by downloading them from TheMuppets [GitHub][blobs-themuppets] and
[GitLab][blobs-the-muppets] repositories (unofficial)
2018-03-08 08:00:01 +01:00
The third way is the easiest one and is enabled by default; if you're OK with
that just move on, otherwise set `INCLUDE_PROPRIETARY (true)` to `false` and
manually provide the blobs (not explained in this guide).
2021-01-29 17:58:03 +01:00
### Over the Air updates
2018-03-08 08:00:01 +01:00
2021-01-29 17:58:03 +01:00
To enable OTA for you builds, you need to run a server that speaks the protocol
understood by the [LineageOS updater app][updater] and provide the URL to this
server as `OTA_URL` variable for the build.
2018-03-08 08:00:01 +01:00
2021-01-29 17:58:03 +01:00
One implementation is [LineageOTA][lineageota], which is also available as Docker
image. Follow these steps to prepare your builds for OTA:
* Run the Docker image `julianxhokaxhiu/lineageota`
* Port 80 exposed to the internet (might want to add an HTTPS reverse proxy)
* The `/srv/zips` directory/volume of the CICD image mounted at
`/var/www/html/builds/full` (can be read-only)
* Set environment variables when building
* `ZIP_SUBDIR` to `false`
* `OTA_URL` to the address of the OTA server, with `/api` appended
2018-03-08 08:00:01 +01:00
If you don't setup a OTA server you won't be able to update the device from the
updater app (but you can still update it manually with the recovery of course).
### Signing
By default, builds are signed with the Android test keys. If you want to sign
2018-06-22 16:59:57 +02:00
your builds with your own keys (**highly recommended**):
2018-03-08 08:00:01 +01:00
2018-06-22 16:59:57 +02:00
* `SIGN_BUILDS (false)`: set to `true` to sign the builds with the keys
contained in `/srv/keys`; if no keys are present, a new set will be generated
2018-03-08 08:00:01 +01:00
### Other settings
Other useful settings are:
2018-06-22 16:59:57 +02:00
* `CCACHE_SIZE (50G)`: change this if you want to give more (or less) space to
ccache
* `WITH_SU (false)`: set to `true` to embed `su` in the build (note that, even
when set to `false`, you can still enable root by flashing the
[su installable ZIP][los-extras])
2018-03-08 08:00:01 +01:00
* `RELEASE_TYPE (UNOFFICIAL)`: change the release type of your builds
2018-06-22 16:59:57 +02:00
* `BUILD_OVERLAY (false)`: normally each build is done on the source tree, then
the tree is cleaned with `mka clean`. If you want to be sure that each build
is isolated from the others, set `BUILD_OVERLAY` to `true` (longer build
time). Requires `--cap-add=SYS_ADMIN`.
* `LOCAL_MIRROR (false)`: change this to `true` if you want to create a local
mirror of the LineageOS source (> 200 GB)
* `CRONTAB_TIME (now)`: instead of building immediately and exit, build at the
specified time (uses standard cron format)
2021-01-29 17:57:48 +01:00
* `ZIP_SUBDIR (true)`: Move the resulting zips to $ZIP_DIR/$codename instead of $ZIP_DIR/
2018-06-22 16:59:57 +02:00
The full list of settings, including the less interesting ones not mentioned in
this guide, can be found in the [Dockerfile][dockerfile].
2018-03-08 08:00:01 +01:00
## Volumes
You also have to provide Docker some volumes, where it'll store the source, the
resulting builds, the cache and so on. The volumes are:
* `/srv/src`, for the LineageOS sources
* `/srv/zips`, for the output builds
* `/srv/logs`, for the output logs
* `/srv/ccache`, for the ccache
* `/srv/local_manifests`, for custom manifests (optional)
* `/srv/userscripts`, for the user scripts (optional)
When `SIGN_BUILDS` is `true`
* `/srv/keys`, for the signing keys
When `BUILD_OVERLAY` is `true`
* `/srv/tmp`, for temporary files
When `LOCAL_MIRROR` is `true`:
* `/srv/mirror`, for the LineageOS mirror
## Examples
### Build for river (lineage-18.1, officially supported), test keys, no patches
```
docker run \
-e "BRANCH_NAME=lineage-18.1" \
-e "DEVICE_LIST=river" \
2018-03-08 08:00:01 +01:00
-v "/home/user/lineage:/srv/src" \
-v "/home/user/zips:/srv/zips" \
-v "/home/user/logs:/srv/logs" \
-v "/home/user/cache:/srv/ccache" \
lineageos4microg/docker-lineage-cicd
```
### Build for bacon (lineage-17.1, officially supported), custom keys, restricted signature spoofing with integrated microG and FDroid
2018-03-08 08:00:01 +01:00
```
docker run \
-e "BRANCH_NAME=lineage-17.1" \
-e "DEVICE_LIST=bacon" \
-e "SIGN_BUILDS=true" \
2018-03-08 08:00:01 +01:00
-e "SIGNATURE_SPOOFING=restricted" \
-e "CUSTOM_PACKAGES=GmsCore GsfProxy FakeStore MozillaNlpBackend NominatimNlpBackend com.google.android.maps.jar FDroid FDroidPrivilegedExtension " \
-v "/home/user/lineage:/srv/src" \
-v "/home/user/zips:/srv/zips" \
-v "/home/user/logs:/srv/logs" \
-v "/home/user/cache:/srv/ccache" \
2018-03-08 08:00:01 +01:00
-v "/home/user/keys:/srv/keys" \
-v "/home/user/manifests:/srv/local_manifests" \
lineageos4microg/docker-lineage-cicd
```
If there are already keys in `/home/user/keys` they will be used, otherwise a
2018-06-22 16:59:57 +02:00
new set will be generated before starting the build (and will be used for every
subsequent build).
2018-03-08 08:00:01 +01:00
The microG and FDroid packages are not present in the LineageOS repositories,
2018-06-22 16:59:57 +02:00
and must be provided through an XML in the `/home/user/manifests`.
[This][prebuiltapks] repo contains some of the most common packages for these
kind of builds: to include it create an XML (the name is irrelevant, as long as
it ends with `.xml`) in the `/home/user/manifests` folder with this content:
2018-03-08 08:00:01 +01:00
```
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="lineageos4microg/android_prebuilts_prebuiltapks" path="prebuilts/prebuiltapks" remote="github" revision="master" />
</manifest>
```
### Build for four devices on lineage-17.1 and lineage-18.1 (officially supported), custom keys, restricted signature spoofing with integrated microG and FDroid, custom OTA server
2018-03-08 08:00:01 +01:00
```
docker run \
-e "BRANCH_NAME=lineage-17.1,lineage-18.1" \
-e "DEVICE_LIST_LINEAGE_17_1=bacon,oneplus2" \
-e "DEVICE_LIST_LINEAGE_18_1=river,lake" \
2018-03-08 08:00:01 +01:00
-e "SIGN_BUILDS=true" \
-e "SIGNATURE_SPOOFING=restricted" \
-e "CUSTOM_PACKAGES=GmsCore GsfProxy FakeStore MozillaNlpBackend NominatimNlpBackend com.google.android.maps.jar FDroid FDroidPrivilegedExtension " \
-e "OTA_URL=https://api.myserver.com/" \
-v "/home/user/lineage:/srv/src" \
-v "/home/user/zips:/srv/zips" \
-v "/home/user/logs:/srv/logs" \
2018-03-08 08:00:01 +01:00
-v "/home/user/cache:/srv/ccache" \
-v "/home/user/keys:/srv/keys" \
-v "/home/user/manifests:/srv/local_manifests" \
lineageos4microg/docker-lineage-cicd
```
2018-03-08 08:00:01 +01:00
### Build for a6000 (not officially supported), custom keys, restricted signature spoofing with integrated microG and FDroid
As there is no official support for this device, we first have to include the
sources in the source tree through an XML in the `/home/user/manifests` folder;
2018-06-22 16:59:57 +02:00
from [this][a6000-xda] thread we get the links of:
2018-03-08 08:00:01 +01:00
2018-06-22 16:59:57 +02:00
* Device tree: https://github.com/dev-harsh1998/android_device_lenovo_a6000
* Common Tree: https://github.com/dev-harsh1998/android_device_lenovo_msm8916-common
* Kernel: https://github.com/dev-harsh1998/kernel_lenovo_msm8916
* Vendor blobs: https://github.com/dev-harsh1998/proprietary-vendor_lenovo
2018-03-08 08:00:01 +01:00
2018-06-22 16:59:57 +02:00
Then, with the help of lineage.dependencies from the
[device tree][a6000-device-tree-deps] and the
[common tree][a6000-common-tree-deps] we create an XML
`/home/user/manifests/a6000.xml` with this content:
2018-03-08 08:00:01 +01:00
2017-06-06 14:37:18 +02:00
```
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
2018-03-08 08:00:01 +01:00
<project name="dev-harsh1998/android_device_lenovo_a6000" path="device/lenovo/a6000" remote="github" />
<project name="dev-harsh1998/android_device_lenovo_msm8916-common" path="device/lenovo/msm8916-common" remote="github" />
<project name="dev-harsh1998/kernel_lenovo_msm8916" path="kernel/lenovo/a6000" remote="github" />
<project name="dev-harsh1998/proprietary-vendor_lenovo" path="vendor/lenovo" remote="github" />
<project name="LineageOS/android_device_qcom_common" path="device/qcom/common" remote="github" />
2017-06-06 14:37:18 +02:00
</manifest>
```
2018-03-08 08:00:01 +01:00
We also want to include our custom packages so, like before, create an XML (for
example `/home/user/manifests/custom_packages.xml`) with this content:
2017-06-06 14:37:18 +02:00
```
2018-03-08 08:00:01 +01:00
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project name="lineageos4microg/android_prebuilts_prebuiltapks" path="prebuilts/prebuiltapks" remote="github" revision="master" />
</manifest>
```
2018-03-08 08:00:01 +01:00
We also set `INCLUDE_PROPRIETARY=false`, as the proprietary blobs are already
2018-06-22 16:59:57 +02:00
provided by the repo
https://github.com/dev-harsh1998/prorietary_vendor_lenovo (so we
don't have to include the TheMuppets repo).
2018-03-08 08:00:01 +01:00
Now we can just run the build like it was officially supported:
```
docker run \
-e "BRANCH_NAME=lineage-15.1" \
-e "DEVICE_LIST=a6000" \
-e "SIGN_BUILDS=true" \
-e "SIGNATURE_SPOOFING=restricted" \
-e "CUSTOM_PACKAGES=GmsCore GsfProxy FakeStore MozillaNlpBackend NominatimNlpBackend com.google.android.maps.jar FDroid FDroidPrivilegedExtension " \
-e "INCLUDE_PROPRIETARY=false" \
-v "/home/user/lineage:/srv/src" \
-v "/home/user/zips:/srv/zips" \
-v "/home/user/logs:/srv/logs" \
-v "/home/user/cache:/srv/ccache" \
-v "/home/user/keys:/srv/keys" \
-v "/home/user/manifests:/srv/local_manifests" \
lineageos4microg/docker-lineage-cicd
```
2018-06-22 16:59:57 +02:00
[docker-ubuntu]: https://docs.docker.com/install/linux/docker-ce/ubuntu/
[docker-debian]: https://docs.docker.com/install/linux/docker-ce/debian/
[docker-centos]: https://docs.docker.com/install/linux/docker-ce/centos/
[docker-fedora]: https://docs.docker.com/install/linux/docker-ce/fedora/
[docker-win]: https://docs.docker.com/docker-for-windows/install/
[docker-mac]: https://docs.docker.com/docker-for-mac/install/
[docker-toolbox]: https://docs.docker.com/toolbox/overview/
[docker-helloworld]: https://docs.docker.com/get-started/#test-docker-installation
[los-branches]: https://github.com/LineageOS/android/branches
[signature-spoofing]: https://github.com/microg/android_packages_apps_GmsCore/wiki/Signature-Spoofing
[microg]: https://microg.org/
[signature-spoofing-patches]: src/signature_spoofing_patches/
[blobs-pull]: https://wiki.lineageos.org/devices/bacon/build#extract-proprietary-blobs
[blobs-extract]: https://wiki.lineageos.org/extracting_blobs_from_zips.html
[blobs-themuppets]: https://github.com/TheMuppets/manifests
[blobs-the-muppets]: https://gitlab.com/the-muppets/manifest
2018-06-22 16:59:57 +02:00
[lineageota]: https://github.com/julianxhokaxhiu/LineageOTA
2021-01-29 17:58:03 +01:00
[updater]: https://github.com/LineageOS/android_packages_apps_Updater
2018-06-22 16:59:57 +02:00
[los-extras]: https://download.lineageos.org/extras
[dockerfile]: Dockerfile
[prebuiltapks]: https://github.com/lineageos4microg/android_prebuilts_prebuiltapks
[a6000-xda]: https://forum.xda-developers.com/lenovo-a6000/development/rom-lineageos-15-1-t3733747
[a6000-device-tree-deps]: https://github.com/dev-harsh1998/android_device_lenovo_a6000/blob/lineage-15.1/lineage.dependencies
[a6000-common-tree-deps]: https://github.com/dev-harsh1998/android_device_lenovo_msm8916-common/blob/lineage-15.1/lineage.dependencies