Skip to content

Commit 22ac3da

Browse files
authored
dunfell setup (#3)
1 parent 35b9fa5 commit 22ac3da

File tree

15 files changed

+428
-2
lines changed

15 files changed

+428
-2
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: dunfell
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: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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

.gitmodules

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "meta-swift"]
22
path = meta-swift
3-
url = [email protected]:xavgru12/meta-swift.git
3+
url = [email protected]:jeremy-prater/meta-swift.git
4+
[submodule "poky"]
5+
path = poky
6+
url = https://github.com/MillerTechnologyPeru/poky.git

Dockerfile-Ubuntu-20.04

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM ubuntu:20.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: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Clone
2+
3+
```
4+
git clone [email protected]:xavgru12/meta-swift-project.git --recurse-submodules
5+
```
6+
7+
# Build
8+
9+
```
10+
./build-docker.sh
11+
```
12+
13+
```
14+
./run-docker.sh
15+
```
16+
17+
```
18+
./build.sh
19+
```
20+
21+
# Execution
22+
23+
```
24+
./execute.exp
25+
```
26+
27+
# Github Actions
28+
29+
Start runner and trigger job via Github API:
30+
31+
https://github.com/xavgru12/github-self-hosted-runner
32+

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-20.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+
9+
MACHINE="${MACHINE:=qemuarm}"
10+
11+
# Build Yocto Poky
12+
cd $POKY_DIR
13+
14+
BBLAYERS_FILE=${POKY_DIR}/build/conf/bblayers.conf
15+
if [ -e "$BBLAYERS_FILE" ]; then
16+
rm -rf "$BBLAYERS_FILE"
17+
fi
18+
19+
source oe-init-build-env
20+
bitbake-layers add-layer $META_SWIFT_DIR
21+
echo "BBFILES += \"${SRC_ROOT}/meta-swift-overrides/*.bbappend\"" >> $BBLAYERS_FILE
22+
23+
# Customize build
24+
touch conf/sanity.conf
25+
CONF_FILE=./conf/local.conf
26+
rm -rf $CONF_FILE
27+
echo "# Swift for Yocto" >> $CONF_FILE
28+
echo "MACHINE=\"${MACHINE}\"" >> $CONF_FILE
29+
echo 'IMAGE_FEATURES += "debug-tweaks"' >> $CONF_FILE
30+
echo 'IMAGE_INSTALL:append = " swift-hello-world"' >> $CONF_FILE
31+
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: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/expect -f
2+
3+
spawn bash -c "cd poky && source oe-init-build-env && runqemu qemuarm nographic"
4+
5+
set timeout 180
6+
7+
expect {
8+
-re ".*login: " {
9+
send "root\r"
10+
}
11+
timeout {
12+
puts "ERROR: Login prompt not received"
13+
exit 1
14+
}
15+
}
16+
17+
expect {
18+
-re {root@.*# } {
19+
# got shell prompt after login
20+
}
21+
timeout {
22+
puts "ERROR: Timeout waiting for root shell prompt after login"
23+
exit 1
24+
}
25+
}
26+
27+
send "hello-world\r"
28+
29+
expect {
30+
-re {root@.*# } {
31+
# got shell prompt after command
32+
}
33+
timeout {
34+
puts "ERROR: Timeout waiting for shell prompt after command"
35+
exit 1
36+
}
37+
}
38+
39+
# Optional: interact to keep session open
40+
#interact
41+

0 commit comments

Comments
 (0)