From e3f46e8a74d90ba22df65495dbd35e3847c029e0 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Thu, 3 Aug 2017 14:54:24 +0800 Subject: [PATCH] Initial Makefile, config, upload script and documentation Create a Makefile that does the lifting of setting up the config as it is done on the system. Handles the creation of the .ssh/config for upload. In the past upstream poned on such master Makefiles but as we customize our build environment quite a bit it probably makes sense and reduces the clone+set-up to two calls. --- .gitignore | 4 + Makefile | 155 +++++++++++++++++++++++++++++++++++++ README | 45 +++++++++++ cfg/bblayers.conf | 16 ++++ cfg/common/10_debug | 2 + cfg/common/10_gpl | 2 + cfg/common/10_misc | 5 ++ cfg/common/10_packaging | 1 + cfg/common/10_sdk | 2 + cfg/common/10_shared_dldir | 1 + cfg/common/10_systemd | 3 + cfg/sysmobts/01_sysmobts | 11 +++ cfg/sysmocom-alix/01_alix | 6 ++ cfg/sysmocom-apu2/01_apu2 | 4 + scripts/upload-build.sh | 22 ++++++ 15 files changed, 279 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README create mode 100644 cfg/bblayers.conf create mode 100644 cfg/common/10_debug create mode 100644 cfg/common/10_gpl create mode 100644 cfg/common/10_misc create mode 100644 cfg/common/10_packaging create mode 100644 cfg/common/10_sdk create mode 100644 cfg/common/10_shared_dldir create mode 100644 cfg/common/10_systemd create mode 100644 cfg/sysmobts/01_sysmobts create mode 100644 cfg/sysmocom-alix/01_alix create mode 100644 cfg/sysmocom-apu2/01_apu2 create mode 100755 scripts/upload-build.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..117c38e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +cfg/*/99_do_not_commit +git/ +build.* +*.sw? diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..99f4899 --- /dev/null +++ b/Makefile @@ -0,0 +1,155 @@ +# makefile to set-up the environment for building... + +# This is probably only working with GNU make. The file is structured +# to have variables in the beginning, some helper functions, then so +# implicit rules and in the end targets that invoke them all. +# +# If you need to change sysmocom release or poky base branch then the +# two variables need to be changed. +# If you add a machine then MACHINES need to be adjusted and a new config +# in cfg/NAME/10_NAME needs to be created. +# +# Implicit rules: I used WILDCARD-action for the rules and then get the +# name of the rule from $@ in the rule itself or % when still being in +# the dependency list. + + +# Make everything more verbose by V=1. Taken from kbuild +ifeq ("$(origin V)", "command line") + Q = +else + Q = @ +endif + +# Variables +SYSMOCOM_RELEASE=201705 +POKY_RELEASE=pyro +REPOS=poky meta-telephony meta-sysmocom-bsp meta-qt5 meta-sysmocom-bsp meta-smalltalk +MACHINES=sysmobts sysmocom-apu2 sysmocom-alix +FEED_NAME=$(SYSMOCOM_RELEASE)-testing + +# The default targets to pick depending on machine +BUILD_TARGET_sysmobts = "meta-toolchain-osmo task-sysmocom-feed sysmocom-nitb-image sysmocom-nitb-rauc-image image-rauc-rescue-initramfs image-rauc-slot-initramfs image-rauc-ubi" +BUILD_TARGET_sysmocom-apu2 = "core-image-minimal-initramfs meta-toolchain-osmo task-sysmocom-feed sysmocom-nitb-image core-image-minimal-initramfs" +BUILD_TARGET_sysmocom-alix = "core-image-minimal-initramfs meta-toolchain-osmo task-sysmocom-feed sysmocom-nitb-image core-image-minimal-initramfs" + +# Pick the one depending on $@. Not sure if .SECONDEXPANSION is more +# approiate here or not. +BUILD_TARGETS=$(BUILD_TARGET_$(CUR_MACHINE)) + +# +usage: + @echo "Pick a target like help, update or sysmocom-alix-setup" + +help: + @echo "Set-up build environment and execute builds. This is intended" + @echo "for customers and employees." + @echo "" + @echo "Available targets:" + @echo " usage - Default target and print usage" + @echo " help - This output" + @echo " update - git pull --rebase and initial git clone" + @echo " setup-all - Set-up all build directories" + @echo " build-all - Build all targets" + @echo " clean-all - Clean all targets after build" + @echo " upload-all - Upload all targets" + @echo ' install-ssh-config - Install Host to $$HOME/.ssh/config' + @echo "Board specific targets:" + @$(foreach machine, $(MACHINES), \ + printf " %-16s - Configure build directory\\n" $(machine)-setup;) + @$(foreach machine, $(MACHINES), \ + printf " %-16s - Configure build directory\\n" $(machine)-build;) + @$(foreach machine, $(MACHINES), \ + printf " %-16s - Configure build directory\\n" $(machine)-upload;) + @echo "Available variables:" + @echo " V=1 - Enable verbose command output" + @echo " SYSMOCOM_RELEASE=name - Pick branch during clone" + @echo " POKY_RELEASE=name - Pick branch during clone" + +# Fetch/update all repos... Expand REPOS and append -update to the rule +# e.g. poky-update meta-telephony-update +update: $(foreach repo, $(REPOS), $(repo)-update) + +# helper rules + +# crazy as I don't know a split()[0] +CUR_MACHINE=$(subst build.,,$(subst -upload,,$(subst -clean,,$(subst -build,,$@)))) + + +## Create a new directory +git: + $(V)mkdir $@ + +## Clone repositories. The other option is by variable something like BRNACH_poky, REPO_poky +git/poky: | git + $(V)cd git && git clone --branch=$(POKY_RELEASE) --depth=1 git://git.yoctoproject.org/poky +git/meta-sysmocom-bsp: | git + cd git && git clone --branch=$(SYSMOCOM_RELEASE) git://git.sysmocom.de/poky/meta-sysmocom-bsp +git/meta-telephony: | git + cd git && git clone --branch=$(SYSMOCOM_RELEASE) git://github.com/sysmocom/meta-telephony +git/meta-smalltalk: | git + cd git && git clone --branch=$(SYSMOCOM_RELEASE) git://github.com/sysmocom/meta-smalltalk +git/meta-qt5: | git + cd git && git clone --branch=$(SYSMOCOM_RELEASE) git://github.com/sysmocom/meta-qt5 + +## Create a build directory, e.g. build.sysmobts +## Use Poky to set-up the directory and then customize it. Copy files +## around and append to the local.conf and layers.conf +CFG_FILES = $(sort $(wildcard cfg/common/*)) $(sort $(wildcard cfg/$(CUR_MACHINE)/*)) +build.%: | git/poky + @echo "Creating build directory for $(CUR_MACHINE)" + $(Q)/bin/bash -c "source git/poky/oe-init-build-env $@" + + # Append entries to conf/local.conf. Common first, machine second... filter + $(Q)$(foreach file,$(CFG_FILES), \ + cat $(file) | sed s,BASE_DIR,$(PWD), >> $@/conf/local.conf;) + @echo "require conf/distro/include/sysmocom-defaults.conf" >> $@/conf/local.conf + + $(Q)cat cfg/bblayers.conf | sed s,BASE_DIR,$(PWD), > $@/conf/bblayers.conf + + +# generic git pull --rebase rule. Let's assume this is matching poky-update +# then the dependency will be "git/poky" and a clone rule will be built. +%-update: | git/$(subst -update,,%) + @echo "Updating $(subst -update,,$@) ..." + $(Q)cd git/$(subst -update,,$@) && git pull --rebase + +# Setup a build directory +%-setup: | build.$(subst -setup,,%) git/poky + @echo "Please place proprietary firmware into the downloads directory." + +# Start a build.. +%-build: | build.$(subst -build,,%) git/poky + $(Q)/bin/bash -c "source git/poky/oe-init-build-env build.$(CUR_MACHINE) && bitbake $(BUILD_TARGETS)" + +%-upload: | build.$(subst -upload,,%) git/poky + $(Q)cd build.$(CUR_MACHINE) && ../scripts/upload-build.sh $(CUR_MACHINE) $(FEED_NAME) + +# Create all build directories, build everything, upload everything, clean everything +setup-all: | $(foreach machine, $(MACHINES), $(machine)-setup) + +build-all: | $(foreach machine, $(MACHINES), $(machine)-build) + +upload-all: | $(foreach machine, $(MACHINES), $(machine)-upload) + +clean-all: | $(foreach machine, $(MACHINES), $(machine)-clean) + + +install-ssh-config: | $(HOME)/.ssh +ifndef SSH_HOST + $(error "Please call with make $@ SSH_HOST=xyz...") +endif +ifndef SSH_PORT + $(error "Please call with make $@ SSH_PORT=abc...") +endif +ifndef SSH_USER + $(error "Please call with make $@ SSH_USER=def...") +endif + @echo "Host = sysmocom-downloads" >> $(HOME)/.ssh/config + @echo " HostName = $(SSH_HOST)" >> $(HOME)/.ssh/config + @echo " Port = $(SSH_PORT)" >> $(HOME)/.ssh/config + @echo " AddressFamily = inet" >> $(HOME)/.ssh/config + @echo " User = $(SSH_USER)" >> $(HOME)/.ssh/config +# Target classification +.PHONY: update setup-all install-ssh-config +.SECONDARY: $(foreach repo, $(REPOS), git/$(repo)) $(foreach machine, $(MACHINES), build.$(machine)) diff --git a/README b/README new file mode 100644 index 0000000..c23d395 --- /dev/null +++ b/README @@ -0,0 +1,45 @@ +Scripts and documentation for building system images for our target platforms. The +goal is to help anyone checking out the right repositories, configuring a target +and build the images that are built by CI (in fact CI will use these scripts). + +The central piece is a Makefile that helps to: + + * Git clone the necessary layers + * Update/git pull --rebase all of them + * Set-up the build as used by sysmocom + * Configure .ssh/config for uploading to sysmocom + * Do the upload + * Clean after a build + +The bblayers.conf is created from a template located in cfg/ and the local.conf +will be created by using Poky's oe-init-build-env and then files from cfg/common/* +and cfg/BOARD/*. Files will be sorted in their alphabetically sort order and first +come from the common directory and then the board specific one. At the end an include +directive will be issued. + + +Using the Makefile: + + $ make help + ... + +Example of building everything + + # make install-ssh-config SSH_HOST=build-upload.foo.bar SSH_PORT=2342 + $ make setup-all V=1 + ... git clone + ... git pull --rebase + ... creating build directories + + For the sysmobts firmware needs to be copied to the downloads directory. + As a customer you should have received instructions for doing it and as + an employee it should be mentioned in the wiki + + $ make build-all # Build for all boards the default targets + ... + + $ make upload-all # Make an upload to testing for all boards + ... + + $ make clean-all # Clean the tmp directory for all boards + ... diff --git a/cfg/bblayers.conf b/cfg/bblayers.conf new file mode 100644 index 0000000..8e4754f --- /dev/null +++ b/cfg/bblayers.conf @@ -0,0 +1,16 @@ +# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf +# changes incompatibly +POKY_BBLAYERS_CONF_VERSION = "2" + +BBPATH = "${TOPDIR}" +BBFILES ?= "" + +BBLAYERS ?= " \ + BASE_DIR/git/poky/meta \ + BASE_DIR/git/poky/meta-poky \ + BASE_DIR/git/poky/meta-yocto-bsp \ + BASE_DIR/git/meta-telephony \ + BASE_DIR/git/meta-sysmocom-bsp \ + BASE_DIR/git/meta-smalltalk \ + BASE_DIR/git/meta-qt5 \ + " diff --git a/cfg/common/10_debug b/cfg/common/10_debug new file mode 100644 index 0000000..cd0eb69 --- /dev/null +++ b/cfg/common/10_debug @@ -0,0 +1,2 @@ +# Do not put the sourcecode into the debug packages +PACKAGE_DEBUG_SPLIT_STYLE = "debug-without-src" diff --git a/cfg/common/10_gpl b/cfg/common/10_gpl new file mode 100644 index 0000000..4fe3114 --- /dev/null +++ b/cfg/common/10_gpl @@ -0,0 +1,2 @@ +SOURCE_ARCHIVE_PACKAGE_TYPE = "tar" +INHERIT += "sysmocom-archive-patched-source" diff --git a/cfg/common/10_misc b/cfg/common/10_misc new file mode 100644 index 0000000..64324f0 --- /dev/null +++ b/cfg/common/10_misc @@ -0,0 +1,5 @@ +# Enable the prserver host +PRSERV_HOST = "localhost:0" + +# legacy and remove it in the future +ROOTFS_PKGMANAGE_BOOTSTRAP = "" diff --git a/cfg/common/10_packaging b/cfg/common/10_packaging new file mode 100644 index 0000000..e2a9baa --- /dev/null +++ b/cfg/common/10_packaging @@ -0,0 +1 @@ +PACKAGE_CLASSES = "package_ipk" diff --git a/cfg/common/10_sdk b/cfg/common/10_sdk new file mode 100644 index 0000000..22f9413 --- /dev/null +++ b/cfg/common/10_sdk @@ -0,0 +1,2 @@ +# SDK parts +BB_GENERATE_MIRROR_TARBALLS="1" diff --git a/cfg/common/10_shared_dldir b/cfg/common/10_shared_dldir new file mode 100644 index 0000000..891abb1 --- /dev/null +++ b/cfg/common/10_shared_dldir @@ -0,0 +1 @@ +DL_DIR = "BASE_DIR/downloads" diff --git a/cfg/common/10_systemd b/cfg/common/10_systemd new file mode 100644 index 0000000..9ab7de5 --- /dev/null +++ b/cfg/common/10_systemd @@ -0,0 +1,3 @@ +# Default to systemd +DISTRO_FEATURES_append = " systemd " +VIRTUAL-RUNTIME_init_manager = "systemd" diff --git a/cfg/sysmobts/01_sysmobts b/cfg/sysmobts/01_sysmobts new file mode 100644 index 0000000..ca8af99 --- /dev/null +++ b/cfg/sysmobts/01_sysmobts @@ -0,0 +1,11 @@ +MACHINE = "sysmobts-v2" + +# feed +PACKAGE_FEED_URIS="https://autoupdate:eechiesuboot@downloads.sysmocom.de/generic/sysmobts/201705/ipk/" + +# HW doesn't have rtc +MACHINE_FEATURES_BACKFILL_CONSIDERED = "rtc" + +# Ignore old kernels +BBMASK="recipes-bsp/linux/linux_2.6.39.bb recipes-bsp/linux/linux-sysmocom_3.10.bb" +PREFERRED_VERSION_linux-sysmocom = "4.9.14+git%" diff --git a/cfg/sysmocom-alix/01_alix b/cfg/sysmocom-alix/01_alix new file mode 100644 index 0000000..fc0feba --- /dev/null +++ b/cfg/sysmocom-alix/01_alix @@ -0,0 +1,6 @@ +MACHINE = "sysmocom-alix" +PACKAGE_FEED_URIS="https://autoupdate:eechiesuboot@downloads.sysmocom.de/generic/sysmocom-alix/201705/ipk/" + +MACHINE_FEATURES_BACKFILL_CONSIDERED = "rtc" + +BBMASK="recipes-bsp/linux/linux_2.6.39.bb recipes-bsp/linux/linux-sysmocom_3.10.bb" diff --git a/cfg/sysmocom-apu2/01_apu2 b/cfg/sysmocom-apu2/01_apu2 new file mode 100644 index 0000000..1ad2166 --- /dev/null +++ b/cfg/sysmocom-apu2/01_apu2 @@ -0,0 +1,4 @@ +MACHINE = "sysmocom-apu2" +PACKAGE_FEED_URIS="https://autoupdate:eechiesuboot@downloads.sysmocom.de/generic/sysmocom-apu2/201705/ipk/" +MACHINE_FEATURES_BACKFILL_CONSIDERED = "rtc" +BBMASK="recipes-bsp/linux/linux_2.6.39.bb recipes-bsp/linux/linux-sysmocom_3.10.bb" diff --git a/scripts/upload-build.sh b/scripts/upload-build.sh new file mode 100755 index 0000000..5cacf8a --- /dev/null +++ b/scripts/upload-build.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Upload build results, config and cache to the downloads server. Use +# make install-ssh-config SSH_PORT=XYZ SSH_HOST=abc SSH_USER=foo to +# install the right entry for the .ssh/config. + +if [ $# -ne 2 ]; then + echo "Need to pass MACHINE RELEASE as argument for upload" + exit 1 +fi + +set -ex + +rsync --delete -avz tmp/deploy/ipk/ sysmocom-downloads:$1/$2/ipk +rsync --delete -avz tmp/deploy/images/ sysmocom-downloads:$1/$2/images +rsync --delete -avz tmp/deploy/tools/ sysmocom-downloads:$1/$2/tools +rsync --delete -avz tmp/deploy/sdk/ sysmocom-downloads:$1/$2/sdk +rsync --delete -avz tmp/cache/ sysmocom-downloads:$1/$2/cache-state +rsync --delete -avz cache/ sysmocom-downloads:$1/$2/cache +rsync --delete -avz conf/ sysmocom-downloads:$1/$2/conf +rsync -avz tmp/deploy/sources/ sysmocom-downloads:$1/$2/sources +