Skip to content

Commit 1def8f3

Browse files
Upgrade meta-swift-examples to support meta-raspberrypi and share downloads/sstate-cache on Swift 6.1.2 (#4)
Co-authored-by: Xaver Gruber <[email protected]>
1 parent 35b9fa5 commit 1def8f3

15 files changed

+468
-1
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: scarthgap
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
runqemu:
8+
runs-on: self-hosted
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v3
12+
with:
13+
clean: false
14+
submodules: recursive
15+
- name: build Docker
16+
run: ./build-docker.sh
17+
- name: build Yocto
18+
run: ./server-run-docker.sh ./build.sh
19+
- name: runqemu swift hello world
20+
run: ./server-run-docker.sh ./execute.exp
21+

.gitignore

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Object files
5+
*.o
6+
*.ko
7+
*.obj
8+
*.elf
9+
10+
# Linker output
11+
*.ilk
12+
*.map
13+
*.exp
14+
15+
# Precompiled Headers
16+
*.gch
17+
*.pch
18+
19+
# Libraries
20+
*.lib
21+
*.a
22+
*.la
23+
*.lo
24+
25+
# Shared objects (inc. Windows DLLs)
26+
*.dll
27+
*.so
28+
*.so.*
29+
*.dylib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
*.i*86
36+
*.x86_64
37+
*.hex
38+
39+
# Debug files
40+
*.dSYM/
41+
*.su
42+
*.idb
43+
*.pdb
44+
45+
# Kernel Module Compile Results
46+
*.mod*
47+
*.cmd
48+
.tmp_versions/
49+
modules.order
50+
Module.symvers
51+
Mkfile.old
52+
dkms.conf
53+
54+
# Ignore build directories
55+
build*/
56+
tmp/
57+
sstate-cache/
58+
cache/
59+
deploy/
60+
downloads/
61+
62+
# Ignore BitBake temporary files
63+
bitbake.lock
64+
*.run
65+
*.lock
66+
*.log
67+
*.sigdata
68+
*.siginfo
69+
*.done
70+
*.failed
71+
*.conf.old
72+
73+
# Ignore editor/IDE files
74+
.vscode/
75+
.idea/
76+
*.swp
77+
*.swo
78+
*~
79+
.DS_Store
80+
81+
# Ignore output files
82+
*.tar.gz
83+
*.bin
84+
*.wic*
85+
*.ext4
86+
*.rootfs.*
87+
88+
# Ignore user-specific config
89+
conf/local.conf
90+
conf/site.conf
91+
conf/bblayers.conf
92+
93+
# Ignore custom scripts and artifacts
94+
*.pyc
95+
*.pyo
96+
*.o
97+
*.a
98+
*.so
99+
*.la
100+
*.lo
101+
*.rej
102+
*.orig
103+
104+
# Ignore Git submodule locks
105+
.gitmodules.lock
106+
.repo
107+
108+
# Shared state
109+
downloads/
110+
sstate-cache/

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
[submodule "meta-swift"]
22
path = meta-swift
33
url = [email protected]:xavgru12/meta-swift.git
4+
[submodule "meta-raspberrypi"]
5+
path = meta-raspberrypi
6+
url = https://github.com/agherzan/meta-raspberrypi.git
7+
[submodule "poky"]
8+
path = poky
9+
url = https://git.yoctoproject.org/poky

Dockerfile-Ubuntu-22.04

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM ubuntu:22.04
2+
3+
# Update system and install required packages
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
RUN apt update && apt upgrade -y && \
6+
apt install -y gawk wget git-core diffstat unzip texinfo \
7+
gcc-multilib build-essential chrpath socat file cpio python3 \
8+
python3-pip python3-pexpect xz-utils debianutils iputils-ping \
9+
libsdl1.2-dev xterm tar locales net-tools rsync sudo vim curl zstd \
10+
liblz4-tool libssl-dev bc lzop libgnutls28-dev efitools git-lfs \
11+
keychain pipx make ninja-build tmux xclip xsel iproute2 \
12+
bridge-utils iptables expect
13+
14+
# Install Neovim
15+
COPY neovim-installer.sh /neovim-installer.sh
16+
RUN chmod +x /neovim-installer.sh && \
17+
/neovim-installer.sh && \
18+
rm -f /neovim-installer.sh
19+
20+
# Set up locales
21+
RUN locale-gen en_US.UTF-8 && \
22+
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
23+
ENV LANG en_US.UTF-8
24+
ENV LC_ALL en_US.UTF-8
25+
26+
# Ensure /bin/sh points to bash (Yocto requires this)
27+
RUN ln -sf bash /bin/sh
28+
29+
# Install repo
30+
ADD https://storage.googleapis.com/git-repo-downloads/repo /usr/local/bin/repo
31+
RUN chmod 755 /usr/local/bin/repo
32+
33+
ARG USER
34+
# Create the user with a home directory and set Bash as the default shell
35+
RUN useradd -m -s /bin/bash ${USER} && \
36+
echo "${USER} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/${USER} && \
37+
chmod 0440 /etc/sudoers.d/${USER}
38+
39+
40+
# Ensure user has the correct UID/GID for volume-mounted builds
41+
ARG USER
42+
RUN usermod -u $(id -u ${USER}) -g $(id -g ${USER}) ${USER}
43+
44+
# Set working directory
45+
ARG DOCKER_WORKDIR
46+
WORKDIR ${DOCKER_WORKDIR}
47+
48+
# Switch to the Yocto user
49+
USER ${USER}

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# meta-swift examples
2+
3+
This repo provides a simple workspace to compile the [meta-swift](https://github.com/jeremy-prater/meta-swift) layer
4+
for a sizeable set of supported Yocto machines for the purpose of evalulation and testing.
5+
6+
The following machines are supported and have been tested:
7+
8+
- `qemuarm`
9+
- `qemuarm64`
10+
- `qemux86-64`
11+
- `beaglebone-yocto`
12+
- `raspberrypi-armv7`
13+
- `raspberrypi-armv8`
14+
15+
Others will likely also work, but have not been tested.
16+
17+
## Clone
18+
19+
```console
20+
git clone [email protected]:xavgru12/meta-swift-project.git --recurse-submodules
21+
```
22+
23+
## Build
24+
25+
It is recommended to build and run the included Docker container for a working environment for
26+
building Yocto:
27+
28+
```console
29+
./build-docker.sh
30+
./run-docker.sh
31+
```
32+
33+
Build the `core-image-minimal` for the default architecture (`qemuarm`):
34+
35+
```console
36+
./build.sh
37+
```
38+
39+
You may also customize the ./build.sh invocation by adding `MACHINE=` and/or `EXTRA_IMAGE_INSTALL=`:
40+
41+
```console
42+
MACHINE=beaglebone-yocto EXTRA_IMAGE_INSTALL="openssh" ./build.sh
43+
```
44+
45+
Builds will be found under poky/build-$MACHINE. Downloads and sstate-cache are shared between builds to keep disk size down as much as possible.
46+
47+
## Execution
48+
49+
Execute `hello-world` for the default `qemuarm` machine. This is an easy way to confirm that the meta-swift build worked correctly:
50+
51+
```console
52+
./execute.exp
53+
```
54+
55+
If you built for a different machine, prefix the command with `MACHINE=` like this:
56+
57+
```console
58+
MACHINE=beaglebone-yocto ./build.sh
59+
```
60+
61+
## Github Actions
62+
63+
Start runner and trigger job via Github API:
64+
65+
https://github.com/xavgru12/github-self-hosted-runner
66+

build-docker.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
#
3+
# This script creates the yocto-ready docker image.
4+
# The --build-arg options are used to pass data about the current user.
5+
# Also, a tag is used for easy identification of the generated image.
6+
#
7+
8+
# source the common variables
9+
. ./env.sh
10+
11+
if [[ $PWD != $HOME* && $(whoami) != "root" ]]; then
12+
echo "Error: Current directory is outside $HOME"
13+
exit 1
14+
fi
15+
16+
USERNAME=$(whoami)
17+
if [[ $USERNAME == "root" ]]; then
18+
USERNAME=yocto
19+
fi
20+
21+
docker build --tag "${DOCKER_IMAGE_TAG}" \
22+
--build-arg "DOCKER_WORKDIR=${DOCKER_WORKDIR}" \
23+
--build-arg "USER=$USERNAME" \
24+
--build-arg "host_uid=$(id -u)" \
25+
--build-arg "host_gid=$(id -g)" \
26+
-f Dockerfile-Ubuntu-22.04 \
27+
.
28+

build.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Configuration
5+
SRC_ROOT="${SRC_ROOT:=$(pwd)}"
6+
POKY_DIR="${POKY_DIR:=$SRC_ROOT/poky}"
7+
META_SWIFT_DIR="${META_SWIFT_DIR:=$SRC_ROOT/meta-swift}"
8+
META_RASPBERRYPI_DIR=${META_RASPBERRYPI_DIR:=$SRC_ROOT/meta-raspberrypi}
9+
10+
MACHINE="${MACHINE:=qemuarm}"
11+
DOWNLOADS_DIR=${DOWNLOADS_DIR:=$SRC_ROOT/downloads}
12+
SSTATE_DIR=${SSTATE_DIR:=$SRC_ROOT/sstate-cache}
13+
14+
# Build Yocto Poky
15+
cd $POKY_DIR
16+
source oe-init-build-env build-$MACHINE
17+
bitbake-layers add-layer $META_SWIFT_DIR
18+
# Support for Raspberry PI devices
19+
if [[ $MACHINE == "raspberrypi"* ]]; then
20+
bitbake-layers add-layer $META_RASPBERRYPI_DIR
21+
fi
22+
# Customize build
23+
touch conf/sanity.conf
24+
CONF_FILE=./conf/local.conf
25+
rm -rf $CONF_FILE
26+
echo "# Swift for Yocto" >> $CONF_FILE
27+
echo "MACHINE=\"${MACHINE}\"" >> $CONF_FILE
28+
echo "DL_DIR ?= \"${DOWNLOADS_DIR}\"" >> $CONF_FILE
29+
echo "SSTATE_DIR ?= \"${SSTATE_DIR}\"" >> $CONF_FILE
30+
echo 'IMAGE_FEATURES += "debug-tweaks"' >> $CONF_FILE
31+
echo "IMAGE_INSTALL:append = \" swift-hello-world ${EXTRA_IMAGE_INSTALL}\"" >> $CONF_FILE
32+
33+
#echo 'SSTATE_MIRRORS ?= "file://.* http://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH"' >> $CONF_FILE
34+
#echo "USER_CLASSES += \"buildstats buildstats-summary\"" >> $CONF_FILE
35+
36+
# build Swift
37+
bitbake core-image-minimal

env.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# Here are some default settings.
3+
# Make sure DOCKER_WORKDIR is created and owned by current user.
4+
5+
# Docker
6+
7+
DOCKER_IMAGE_TAG="meta-swift-project"
8+
DOCKER_WORKDIR="$PWD"
9+
10+
# Yocto
11+
12+
YOCTO_DIR="$PWD"
13+

execute.exp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/expect -f
2+
3+
# Grab machine from env
4+
set MACHINE qemuarm
5+
catch {set MACHINE $env(MACHINE)}
6+
7+
spawn bash -c "cd poky && source oe-init-build-env build-${MACHINE} && runqemu ${MACHINE} nographic"
8+
9+
set timeout 180
10+
11+
expect {
12+
-re ".*login: " {
13+
send "root\r"
14+
}
15+
timeout {
16+
puts "ERROR: Login prompt not received"
17+
exit 1
18+
}
19+
}
20+
21+
expect {
22+
-re {root@.*# } {
23+
# got shell prompt after login
24+
}
25+
timeout {
26+
puts "ERROR: Timeout waiting for root shell prompt after login"
27+
exit 1
28+
}
29+
}
30+
31+
send "hello-world\r"
32+
33+
expect {
34+
-re {root@.*# } {
35+
# got shell prompt after command
36+
}
37+
timeout {
38+
puts "ERROR: Timeout waiting for shell prompt after command"
39+
exit 1
40+
}
41+
}
42+
43+
# Optional: interact to keep session open
44+
#interact
45+

meta-raspberrypi

Submodule meta-raspberrypi added at 4845244

0 commit comments

Comments
 (0)