Giter Club home page Giter Club logo

copperheados-build's Introduction

Build CopperheadOS in your Jenkins instance

This is a configuration for Jenkins that will build CopperheadOS (AOSP-based highly-secure Android-like distribution) images for the Pixel XL — and, with a bit of tweaking, the other Google Nexus and Pixel phones — based on the CopperheadOS release schedule, complete with fully compliant secure boot and anti-theft protection.

This build recipe is based on the official CopperheadOS build instructions. In addition to that, this executable recipe will automatically rekey F-Droid so F-Droid will have the ability to install applications as a trusted app store on your phone. Quite excellent!

This build recipe will also build periodically. If a successful build has taken place in the past, the pipeline will exit early with a successful status, so you do not need to worry about wasting CPU, memory or disk space on repeat builds of the same thing. The parameters used to determine whether a build should run to completion are evident from the pipeline script — check the script out if you want to know what decides whether a build continues or not.

How to use it

Install the Jenkins Pipeline plugin on your Jenkins instance.

Copy the directory containing this file, exactly as-is, into the Jenkins jobs folder. For example, if your Jenkins jobs folder path is /var/lib/jenkins/jobs, then you'd copy this folder so that the copy ends up at /var/lib/jenkins/jobs/copperheados-build. If you'd like, rename it afterwards, so it isn't named copperheados-build.

Configuration of the master

Inside the newly-created directory, make a copy of the the config.xml.j2 file and name it config.xml.

Open the config.xml file in your favorite text editor and make the following changes:

  1. Find the PRODUCT_NAME parameter under <parameterDefinitions>, then delete the line that says {{ android_devices[0] | je }} from the list of parameters. Now sort the list of parameters so that the device you plan to build for most often is at the top.
  2. Change the values of the GIT_USER_NAME and GIT_USER_EMAIL parameters to choices of your own.
  3. Change the values of RELEASE_UPLOAD_ADDRESS and RELEASE_DOWNLOAD_ADDRESS to suit your updates publishing needs. Note that you are responsible for making sure your Jenkins master node can SSH into the host named by RELEASE_UPLOAD_ADDRESS and can write to the folder named by that variable. See the documentation adjacent to the variables themselves for more information.
  4. Tune the rest of the parameters to your own liking, in particular the parameter for NUM_CORES to speed up the build if your build node has a lot of RAM and many cores.
  5. In the <triggers> section, adjust the trigger times you'd like the build to run on.

Signing keys generation (one-time-process)

Now note the product name stored in the PRODUCT_NAME variable of the config.xml file. We'll use this shortly.

Create the keys as per the official CopperheadOS build instructions — relevant snippet for one product name quoted here:


To generate keys for marlin (you should use unique keys per device variant / product name):

mkdir keys/marlin
cd keys/marlin
../../development/tools/make_key releasekey '/C=CA/ST=Ontario/L=Toronto/O=CopperheadOS/OU=CopperheadOS/CN=CopperheadOS/[email protected]'
../../development/tools/make_key platform '/C=CA/ST=Ontario/L=Toronto/O=CopperheadOS/OU=CopperheadOS/CN=CopperheadOS/[email protected]'
../../development/tools/make_key shared '/C=CA/ST=Ontario/L=Toronto/O=CopperheadOS/OU=CopperheadOS/CN=CopperheadOS/[email protected]'
../../development/tools/make_key media '/C=CA/ST=Ontario/L=Toronto/O=CopperheadOS/OU=CopperheadOS/CN=CopperheadOS/[email protected]'
../../development/tools/make_key verity '/C=CA/ST=Ontario/L=Toronto/O=CopperheadOS/OU=CopperheadOS/CN=CopperheadOS/[email protected]'
cd ../..

Place those keys in the keys/<PRODUCT_NAME> folder under the job directory you created below the Jenkins jobs folder. You must create one set of keys per device. Secure these keys because if you lose them, you won't be able to create new flashable builds without unlocking and wiping your device.

Ensure the keys under this job directory are readable only by the Jenkins user.

Build slave configuration

Ensure your Jenkins instance has at least one build slave with 16 GB RAM and 200 GB disk space available. Give that build slave the label copperhead. Alternatively, change the node(copperhead) snippet in config.xml to run it on any slave (see the Jenkins Pipeline reference documentation).

The sudo configuration needs to be adjusted in your build slave so that the program $WORKSPACE/bind-mount-dirs-android (with its full path) can be executed via sudo. The program in question will be copied at the start of the build from the master into the build slave, and it is used to wrap calls to ./download-factory-android, ./build-android and ./release-android during various stages of the build. This is needed to to mount the workspace directory into a temporary directory without spaces (otherwise the Android build fails), as well as mount a subdirectory of the workspace onto /tmp for larger disk space (useful in most systems where /tmp is a tmpfs with limited space and causes the build to break).

Additionally, the Preparation stage of the build process will attempt to install several necessary packages at the very beginning, by using dnf with sudo. This is bound to fail on your system, unless you first install the packages in question. In case of failure, run the build and see the log of the Preparation stage -- then install the packages mentioned by the log.

Finishing setup

Restart or reload your Jenkins instance.

You're now ready to go. Build!

copperheados-build's People

Contributors

fspijkerman avatar rudd-o avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

copperheados-build's Issues

Build fails at jack

[ 1% 897/80239] Ensuring Jack server is installed and started
FAILED: setup-jack-server
/bin/bash -c "(prebuilts/sdk/tools/jack-admin install-server prebuilts/sdk/tools/jack-launcher.jar prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 2>&1 || (exit 0) ) && (JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation" prebuilts/sdk/tools/jack-admin start-server 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update server prebuilts/sdk/tools/jack-server-4.11.ALPHA.jar 4.11.ALPHA 2>&1 || exit 0 ) && (prebuilts/sdk/tools/jack-admin update jack prebuilts/sdk/tools/jacks/jack-4.31.CANDIDATE.jar 4.31.CANDIDATE || exit 47 )"
Writing client settings in /root/.jack-settings
prebuilts/sdk/tools/jack-admin: line 57: /root/.jack-settings.23855: Permission denied
ln: failed to access '/root/.jack-settings': Permission denied
rm: cannot remove '/root/.jack-settings.23855': Permission denied
prebuilts/sdk/tools/jack-admin: line 68: /root/.jack-settings: Permission denied
Installing jack server in "/root/.jack-server"
mkdir: cannot create directory '/root': Permission denied
cp: failed to access '/root/.jack-server/launcher.jar': Permission denied
cp: failed to access '/root/.jack-server/server-1.jar': Permission denied
mkdir: cannot create directory '/root/.jack-server/logs': Permission denied
prebuilts/sdk/tools/jack-admin: line 278: SERVER_HOST: unbound variable
Writing client settings in /root/.jack-settings
prebuilts/sdk/tools/jack-admin: line 57: /root/.jack-settings.23871: Permission denied
ln: failed to access '/root/.jack-settings': Permission denied
rm: cannot remove '/root/.jack-settings.23871': Permission denied
prebuilts/sdk/tools/jack-admin: line 68: /root/.jack-settings: Permission denied
Jack server installation not found
Writing client settings in /root/.jack-settings
prebuilts/sdk/tools/jack-admin: line 57: /root/.jack-settings.23878: Permission denied
ln: failed to access '/root/.jack-settings': Permission denied
rm: cannot remove '/root/.jack-settings.23878': Permission denied
prebuilts/sdk/tools/jack-admin: line 68: /root/.jack-settings: Permission denied
prebuilts/sdk/tools/jack-admin: line 358: SERVER_HOST: unbound variable
Communication error with Jack server 1. Try 'jack-diagnose'
Writing client settings in /root/.jack-settings
prebuilts/sdk/tools/jack-admin: line 57: /root/.jack-settings.23889: Permission denied
ln: failed to access '/root/.jack-settings': Permission denied
rm: cannot remove '/root/.jack-settings.23889': Permission denied
prebuilts/sdk/tools/jack-admin: line 68: /root/.jack-settings: Permission denied
prebuilts/sdk/tools/jack-admin: line 358: SERVER_HOST: unbound variable
Communication error with Jack server 1. Try 'jack-diagnose'
[ 1% 898/80239] build out/target/common/obj/all-event-log-tags.txt
[ 1% 899/80239] host StaticLib: libaapt (out/host/linux-x86/obj/STATIC_LIBRARIES/libaapt_intermediates/libaapt.a)
[ 1% 900/80239] host Java: bouncycastle-host (out/host/common/obj/JAVA_LIBRARIES/bouncycastle-host_intermediates/classes)
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
[ 1% 901/80239] build out/target/product/marlin/obj/kernel/google/marlin/usr
make: Entering directory /tmp/android-build-root/src/kernel/google/marlin' make[1]: Entering directory /tmp/android-build-root/src/out/target/product/marlin/obj/kernel/google/marlin'
GEN ./Makefile
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
drivers/soc/qcom/Kconfig:381:warning: choice value used outside its choice group
drivers/soc/qcom/Kconfig:386:warning: choice value used outside its choice group

configuration written to .config

make[1]: Leaving directory /tmp/android-build-root/src/out/target/product/marlin/obj/kernel/google/marlin' make: Leaving directory /tmp/android-build-root/src/kernel/google/marlin'
make: Entering directory /tmp/android-build-root/src/kernel/google/marlin' make[1]: Entering directory /tmp/android-build-root/src/out/target/product/marlin/obj/kernel/google/marlin'
CHK include/generated/uapi/linux/version.h
UPD include/generated/uapi/linux/version.h
WRAP arch/arm64/include/generated/asm/bugs.h
WRAP arch/arm64/include/generated/asm/checksum.h
WRAP arch/arm64/include/generated/asm/clkdev.h
WRAP arch/arm64/include/generated/asm/current.h
WRAP arch/arm64/include/generated/asm/cputime.h
WRAP arch/arm64/include/generated/asm/delay.h
WRAP arch/arm64/include/generated/asm/dma.h
WRAP arch/arm64/include/generated/asm/div64.h
WRAP arch/arm64/include/generated/asm/dma-contiguous.h
WRAP arch/arm64/include/generated/asm/early_ioremap.h
WRAP arch/arm64/include/generated/asm/emergency-restart.h
WRAP arch/arm64/include/generated/asm/errno.h
WRAP arch/arm64/include/generated/asm/ftrace.h
WRAP arch/arm64/include/generated/asm/hash.h
WRAP arch/arm64/include/generated/asm/ioctl.h
WRAP arch/arm64/include/generated/asm/hw_irq.h
WRAP arch/arm64/include/generated/asm/ioctls.h
WRAP arch/arm64/include/generated/asm/ipcbuf.h
WRAP arch/arm64/include/generated/asm/irq_regs.h
WRAP arch/arm64/include/generated/asm/kdebug.h
WRAP arch/arm64/include/generated/asm/kmap_types.h
WRAP arch/arm64/include/generated/asm/local.h
WRAP arch/arm64/include/generated/asm/kvm_para.h
WRAP arch/arm64/include/generated/asm/local64.h
WRAP arch/arm64/include/generated/asm/mcs_spinlock.h
WRAP arch/arm64/include/generated/asm/mman.h
WRAP arch/arm64/include/generated/asm/msgbuf.h
WRAP arch/arm64/include/generated/asm/msi.h
WRAP arch/arm64/include/generated/asm/mutex.h
WRAP arch/arm64/include/generated/asm/pci.h
WRAP arch/arm64/include/generated/asm/pci-bridge.h
WRAP arch/arm64/include/generated/asm/poll.h
WRAP arch/arm64/include/generated/asm/preempt.h
WRAP arch/arm64/include/generated/asm/resource.h
WRAP arch/arm64/include/generated/asm/rwsem.h
WRAP arch/arm64/include/generated/asm/scatterlist.h
WRAP arch/arm64/include/generated/asm/sections.h
WRAP arch/arm64/include/generated/asm/segment.h
WRAP arch/arm64/include/generated/asm/sembuf.h
WRAP arch/arm64/include/generated/asm/serial.h
WRAP arch/arm64/include/generated/asm/shmbuf.h
WRAP arch/arm64/include/generated/asm/simd.h
WRAP arch/arm64/include/generated/asm/sizes.h
WRAP arch/arm64/include/generated/asm/sockios.h
WRAP arch/arm64/include/generated/asm/socket.h
WRAP arch/arm64/include/generated/asm/swab.h
WRAP arch/arm64/include/generated/asm/switch_to.h
WRAP arch/arm64/include/generated/asm/termbits.h
WRAP arch/arm64/include/generated/asm/topology.h
WRAP arch/arm64/include/generated/asm/termios.h
WRAP arch/arm64/include/generated/asm/trace_clock.h
WRAP arch/arm64/include/generated/asm/unaligned.h
WRAP arch/arm64/include/generated/asm/types.h
WRAP arch/arm64/include/generated/asm/user.h
WRAP arch/arm64/include/generated/asm/vga.h
WRAP arch/arm64/include/generated/asm/xor.h
WRAP arch/arm64/include/generated/uapi/asm/kvm_para.h
HOSTCC scripts/unifdef
INSTALL usr/include/drm/ (18 files)
INSTALL usr/include/asm-generic/ (35 files)
INSTALL usr/include/linux/../../../usr/include/linux/staging/android/uapi/ (2 files)
INSTALL usr/include/media/ (21 files)
INSTALL usr/include/linux/byteorder/ (2 files)
INSTALL usr/include/linux/caif/ (2 files)
INSTALL usr/include/linux/can/ (5 files)
INSTALL usr/include/linux/dvb/ (8 files)
INSTALL usr/include/misc/ (1 file)
INSTALL usr/include/linux/hdlc/ (1 file)
INSTALL usr/include/mtd/ (5 files)
INSTALL usr/include/linux/hsi/ (1 file)
INSTALL usr/include/linux/isdn/ (1 file)
INSTALL usr/include/rdma/ (6 files)
INSTALL usr/include/linux/mfd/wcd9xxx/ (2 files)
INSTALL usr/include/scsi/fc/ (4 files)
INSTALL usr/include/linux/mfd/ (1 file)
INSTALL usr/include/scsi/ufs/ (2 files)
INSTALL usr/include/linux/mmc/ (3 files)
INSTALL usr/include/scsi/ (5 files)
INSTALL usr/include/linux/netfilter/ipset/ (4 files)
INSTALL usr/include/sound/ (20 files)
INSTALL usr/include/linux/netfilter/ (85 files)
INSTALL usr/include/video/ (5 files)
INSTALL usr/include/linux/netfilter_arp/ (2 files)
INSTALL usr/include/linux/netfilter_bridge/ (17 files)
INSTALL usr/include/linux/netfilter_ipv4/ (10 files)
INSTALL usr/include/linux/netfilter_ipv6/ (12 files)
INSTALL usr/include/linux/nfsd/ (5 files)
INSTALL usr/include/linux/raid/ (2 files)
INSTALL usr/include/linux/spi/ (1 file)
INSTALL usr/include/linux/sunrpc/ (1 file)
INSTALL usr/include/linux/tc_act/ (8 files)
INSTALL usr/include/linux/tc_ematch/ (4 files)
INSTALL usr/include/linux/usb/ (11 files)
INSTALL usr/include/linux/wimax/ (1 file)
INSTALL usr/include/linux/ (470 files)
INSTALL usr/include/xen/ (4 files)
INSTALL usr/include/uapi/ (0 file)
INSTALL usr/include/asm/ (35 files)
make[1]: Leaving directory /tmp/android-build-root/src/out/target/product/marlin/obj/kernel/google/marlin' make: Leaving directory /tmp/android-build-root/src/kernel/google/marlin'
ninja: build stopped: subcommand failed.
21:54:12 ninja failed with: exit status 1
make: *** [run_soong_ui] Error 1
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 2
Finished: FAILURE

Optimal configuration for slave node

Copperhead OS team recommends using Ubuntu as build OS.
But as I see scripts use some RH commands rpm or dnf.

So what is the best and optimal OS for slave node?
And what are all needed dependencies that have to be installed before build?

local-init fsanitize unsupported?

Getting a lot of these one the build. Is this expected? local-init is part of the copperhead mods so a little concerning to see (thousands) of these errors

error: unsupported argument 'local-init' to option 'fsanitize='

expected?

Setting up slave on Jenkins ver. 2.89.2, and generating keys

This repo does not seem to identify the version of Jenkins used. I am using 2.89.2 and have run into an issue in creating the slave.
Adding node to Jenkins

What would the launch command be?

On a second note, what is the suggested method for generating the keys? I have copied them over from a second VM I was using for manual building.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.