Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ubuntu 22.04 images #81

Merged
merged 4 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ jobs:
- {image: ubuntu-20.04-oe, provider: podman, sh: bash}
- {image: ubuntu-20.04-oetest, provider: docker, sh: bash}
- {image: ubuntu-20.04-oegarmin, provider: docker, sh: bash}
- {image: ubuntu-22.04-base, provider: docker, sh: bash}
- {image: ubuntu-22.04-oe, provider: docker, sh: bash}
- {image: ubuntu-22.04-oe, provider: podman, sh: bash}
- {image: ubuntu-22.04-oegarmin, provider: docker, sh: bash}

runs-on: ubuntu-20.04

Expand Down
7 changes: 6 additions & 1 deletion ci/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ echo 'ef3d4305054282938bfe70dc5a08eba8a701a22b49795b1c2d8ed5aed90d0581 *poky/pok
wget --no-check-certificate -O "$TOP_DIR/poky/poky-3.1.tar.bz2" "http://downloads.yoctoproject.org/releases/yocto/yocto-3.1/poky-dunfell-23.0.0.tar.bz2"
echo 'c1f4a486e5f090dbdf50c15a5d22afa6689bd609604b48d63eb0643ad58eb370 *poky/poky-3.1.tar.bz2' | sha256sum -c

mkdir "$TOP_DIR/poky/2.6" "$TOP_DIR/poky/3.1"
wget --no-check-certificate -O "$TOP_DIR/poky/poky-4.0.tar.bz2" http://downloads.yoctoproject.org/releases/yocto/yocto-4.0/poky-00cfdde791a0176c134f31e5a09eff725e75b905.tar.bz2
echo '4cedb491b7bf0d015768c61690f30d7d73f4266252d6fba907bba97eac83648c *poky/poky-4.0.tar.bz2' | sha256sum -c

mkdir "$TOP_DIR/poky/2.6" "$TOP_DIR/poky/3.1" "$TOP_DIR/poky/4.0"
echo "Extracting..."
tar -xf "$TOP_DIR/poky/poky-2.6.tar.bz2" -C "$TOP_DIR/poky/2.6" --strip-components=1
tar -xf "$TOP_DIR/poky/poky-3.1.tar.bz2" -C "$TOP_DIR/poky/3.1" --strip-components=1
tar -xf "$TOP_DIR/poky/poky-4.0.tar.bz2" -C "$TOP_DIR/poky/4.0" --strip-components=1
ln -s ../../pyrex-init-build-env "$TOP_DIR/poky/2.6/"
ln -s ../../pyrex-init-build-env "$TOP_DIR/poky/3.1/"
ln -s ../../pyrex-init-build-env "$TOP_DIR/poky/4.0/"
94 changes: 64 additions & 30 deletions ci/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import tempfile
import threading
import unittest
import time

PYREX_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(PYREX_ROOT)
Expand Down Expand Up @@ -63,7 +64,8 @@ def wrapper(self, *args, **kwargs):
class PyrexTest(object):
@property
def pokyroot(self):
return os.path.join(PYREX_ROOT, "poky", self.pokyver)
major, minor = self.pokyver
return os.path.join(PYREX_ROOT, "poky", f"{major}.{minor}")

def setUp(self):
self.build_dir = os.path.join(PYREX_ROOT, "build", "%d" % os.getpid())
Expand Down Expand Up @@ -96,7 +98,11 @@ def cleanup_env():
os.environ["PYREX_BUILD_QUIET"] = "0"
os.environ["PYREX_OEINIT"] = os.path.join(self.pokyroot, "oe-init-build-env")
os.environ["PYREX_CONFIG_BIND"] = PYREX_ROOT
for var in ("SSH_AUTH_SOCK", "BB_ENV_EXTRAWHITE"):
for var in (
"SSH_AUTH_SOCK",
"BB_ENV_EXTRAWHITE",
"BB_ENV_PASSTHROUGH_ADDITIONS",
):
if var in os.environ:
del os.environ[var]

Expand Down Expand Up @@ -202,7 +208,7 @@ def _write_host_command(
cwd=PYREX_ROOT,
builddir=None,
bitbakedir="",
init_env={}
init_env={},
):
if builddir is None:
builddir = self.build_dir
Expand Down Expand Up @@ -246,7 +252,7 @@ def assertPyrexHostCommand(
builddir=None,
bitbakedir="",
init_env={},
**kwargs
**kwargs,
):
cmd_file, command = self._write_host_command(
args,
Expand All @@ -260,7 +266,7 @@ def assertPyrexHostCommand(
[os.environ.get("SHELL", "/bin/bash"), cmd_file],
pretty_command=command,
cwd=cwd,
**kwargs
**kwargs,
)

def assertPyrexContainerShellCommand(self, *args, **kwargs):
Expand Down Expand Up @@ -338,7 +344,7 @@ def capture_pyrex_state(*args, **kwargs):
self.assertPyrexContainerShellCommand(
"cp --no-preserve=all /proc/1/cmdline %s" % capture_file,
*args,
**kwargs
**kwargs,
)
with open(capture_file, "rb") as f:
return f.read()
Expand Down Expand Up @@ -766,17 +772,21 @@ def test_groups(self):

self.assertEqual(groups, my_groups)

def test_bb_env_extrawhite(self):
def test_env_passthrough_var(self):
env = os.environ.copy()
env["BB_ENV_EXTRAWHITE"] = "TEST_BB_EXTRA"
if self.pokyver < (4, 0):
varname = "BB_ENV_EXTRAWHITE"
else:
varname = "BB_ENV_PASSTHROUGH_ADDITIONS"
env[varname] = "TEST_BB_EXTRA"
env["TEST_BB_EXTRA"] = "Hello"

s = set(
self.assertPyrexContainerShellCommand(
"echo $BB_ENV_EXTRAWHITE", env=env, quiet_init=True, capture=True
f"echo ${varname}", env=env, quiet_init=True, capture=True
).split()
)
self.assertIn(env["BB_ENV_EXTRAWHITE"], s)
self.assertIn(env[varname], s)

s = self.assertPyrexContainerShellCommand(
"echo $TEST_BB_EXTRA", env=env, quiet_init=True, capture=True
Expand Down Expand Up @@ -1064,6 +1074,17 @@ def test_top_dir(self):
cwd=cwd,
)

# Since bitbake is being invoked outside of Pyrex, we need to wait
# until it exits before trying to cleanup the build directory,
# otherwise it can race.
wait_time = 20
for _ in range(wait_time):
if not os.path.exists(os.path.join(builddir, "bitbake.lock")):
break
time.sleep(1)
else:
self.fail(f"bitbake did not exit within {wait_time} seconds")

shutil.rmtree(builddir)

pyrex_topdir = self.assertPyrexHostCommand(
Expand All @@ -1078,25 +1099,35 @@ def test_top_dir(self):
self.assertEqual(oe_topdir, pyrex_topdir)

def test_env_capture(self):
extra_white = set(
if self.pokyver < (4, 0):
varname = "BB_ENV_EXTRAWHITE"
else:
varname = "BB_ENV_PASSTHROUGH_ADDITIONS"

extra_env = set(
self.assertPyrexHostCommand(
"echo $BB_ENV_EXTRAWHITE", quiet_init=True, capture=True
f"echo ${varname}", quiet_init=True, capture=True
).split()
)

# The exact values aren't relevant, only that they are correctly
# imported from the capture
self.assertIn("MACHINE", extra_white)
self.assertIn("DISTRO", extra_white)
self.assertIn("MACHINE", extra_env)
self.assertIn("DISTRO", extra_env)

builddir = self.assertPyrexHostCommand(
"echo $BUILDDIR", quiet_init=True, capture=True
)
self.assertEqual(builddir, self.build_dir)

def test_bb_env_extrawhite_parse(self):
def test_bb_env_extra_parse(self):
if self.pokyver < (4, 0):
varname = "BB_ENV_EXTRAWHITE"
else:
varname = "BB_ENV_PASSTHROUGH_ADDITIONS"

env = os.environ.copy()
env["BB_ENV_EXTRAWHITE"] = "TEST_BB_EXTRA"
env[varname] = "TEST_BB_EXTRA"
env["TEST_BB_EXTRA"] = "foo"

s = self.assertPyrexHostCommand(
Expand Down Expand Up @@ -1130,20 +1161,23 @@ class PyrexImageType_oetest(PyrexImageType_oe):
PROVIDERS = ("docker", "podman")

TEST_IMAGES = (
("ubuntu-14.04-base", "2.6"),
("ubuntu-16.04-base", "2.6"),
("ubuntu-18.04-base", "2.6"),
("ubuntu-20.04-base", "3.1"),
("ubuntu-14.04-oe", "2.6"),
("ubuntu-16.04-oe", "2.6"),
("ubuntu-18.04-oe", "2.6"),
("ubuntu-20.04-oe", "3.1"),
("ubuntu-14.04-oegarmin", "2.6"),
("ubuntu-16.04-oegarmin", "2.6"),
("ubuntu-18.04-oegarmin", "2.6"),
("ubuntu-20.04-oegarmin", "3.1"),
("ubuntu-18.04-oetest", "2.6"),
("ubuntu-20.04-oetest", "3.1"),
("ubuntu-14.04-base", (2, 6)),
("ubuntu-16.04-base", (2, 6)),
("ubuntu-18.04-base", (2, 6)),
("ubuntu-20.04-base", (3, 1)),
("ubuntu-22.04-base", (4, 0)),
("ubuntu-14.04-oe", (2, 6)),
("ubuntu-16.04-oe", (2, 6)),
("ubuntu-18.04-oe", (2, 6)),
("ubuntu-20.04-oe", (3, 1)),
("ubuntu-22.04-oe", (4, 0)),
("ubuntu-14.04-oegarmin", (2, 6)),
("ubuntu-16.04-oegarmin", (2, 6)),
("ubuntu-18.04-oegarmin", (2, 6)),
("ubuntu-20.04-oegarmin", (3, 1)),
("ubuntu-22.04-oegarmin", (4, 0)),
("ubuntu-18.04-oetest", (2, 6)),
("ubuntu-20.04-oetest", (3, 1)),
)


Expand Down
110 changes: 110 additions & 0 deletions image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,36 @@ RUN set -x && export DEBIAN_FRONTEND=noninteractive && \
COPY --from=prebuilt-setpriv /dist/setpriv /
COPY --from=prebuilt-tini /dist/tini /

#
# Ubuntu 22.04 Base
#
FROM ubuntu:jammy as ubuntu-22.04-base
ENV PYREX_BASE none
LABEL maintainer="Joshua Watt <Joshua.Watt@garmin.com>"

# Install software required to run init scripts.
RUN set -x && export DEBIAN_FRONTEND=noninteractive && \
ulimit -n 1024 && \
apt-get -y update && apt-get -y install --no-install-recommends \
locales \
lsb-release \
ncurses-term \
python3 \
util-linux \
sudo \
curl \
ca-certificates \
&& \
# Clean up apt-cache
rm -rf /var/lib/apt/lists/* && \
# generate utf8 locale
locale-gen en_US.UTF-8 && \
(locale -a | tee /dev/stderr | grep -qx en_US.utf8)

# Copy prebuilt items
COPY --from=prebuilt-setpriv /dist/setpriv /
COPY --from=prebuilt-tini /dist/tini /

#
# Ubuntu 14.04 Yocto Base
#
Expand Down Expand Up @@ -584,6 +614,80 @@ RUN python3 -m pip install iterfzf testtools python-subunit
# Copy prebuilt items
COPY --from=prebuilt-icecream /dist/icecream /

#
# Ubuntu 22.04 Base
#
FROM ubuntu-22.04-base as ubuntu-22.04-oe
ENV PYREX_BASE none
LABEL maintainer="Joshua Watt <Joshua.Watt@garmin.com>"

RUN set -x && export DEBIAN_FRONTEND=noninteractive && \
sudo dpkg --add-architecture i386 && \
ulimit -n 1024 && \
apt -y update && apt upgrade apt -y && apt -y install --no-install-recommends \
# Poky 4.0 build dependencies
gawk \
wget \
git \
diffstat \
unzip \
texinfo \
gcc \
build-essential \
chrpath \
socat \
cpio \
python3 \
python3-pip \
python3-pexpect \
xz-utils \
debianutils \
iputils-ping \
python3-git \
python3-jinja2 \
libegl1-mesa \
libsdl1.2-dev \
pylint \
xterm \
python3-subunit \
mesa-common-dev \
zstd \
liblz4-tool \
# Testing dependencies
iproute2 \
sysstat \
# Dependencies for "bitbake -c menuconfig"
libncurses5-dev \
libtinfo-dev \
# Not listed, but required dependencies (from ASSUME_PROVIDED)
bzip2 \
libbz2-dev \
sed \
findutils \
# Required for some poorly written 3rd party recipes :(
python3-six \
# Corollary to the core Yocto gcc-multilib package. Allows various
# prebuilt native tools to work
g++-multilib \
# Screen to enable devshell
screen \
# Base OS stuff that reasonable workstations have, but which the registry image
# doesn't
tzdata \
file \
# Dependencies for other layers
xxd \
# Testing requirements
wine \
wine64 \
wine32 \
&& rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install iterfzf testtools python-subunit

# Copy prebuilt items
COPY --from=prebuilt-icecream /dist/icecream /

#
# Ubuntu 18.04 OE Test Image
#
Expand Down Expand Up @@ -620,6 +724,12 @@ ENV PYREX_BASE none
FROM ubuntu-20.04-oe AS ubuntu-20.04-oegarmin
ENV PYREX_BASE none

#
# Ubuntu 22.04 Base, customized with Garmin internal LAN configuration.
#
FROM ubuntu-22.04-oe AS ubuntu-22.04-oegarmin
ENV PYREX_BASE none

#
# Base image target.
#
Expand Down
7 changes: 6 additions & 1 deletion image/capture.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,18 @@ check_bound "$(pwd)"

check_bound "$PYREX_CAPTURE_DEST"

json_str() {
echo "\"$1\": \"${!1}\""
}

cat > "$PYREX_CAPTURE_DEST" <<HEREDOC
{
"tempdir": "$PWD/pyrex",
"user" : {
"cwd": "$PWD",
"export": {
"BB_ENV_EXTRAWHITE": "$BB_ENV_EXTRAWHITE",
${BB_ENV_EXTRAWHITE:+$(json_str "BB_ENV_EXTRAWHITE"),}
${BB_ENV_PASSTHROUGH_ADDITIONS:+$(json_str "BB_ENV_PASSTHROUGH_ADDITIONS"),}
"BUILDDIR": "$BUILDDIR"
}
},
Expand Down
2 changes: 1 addition & 1 deletion pyrex.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ confversion = @CONFVERSION@

# As a convenience, the name of a Pyrex provided image
# can be specified here
%image = ubuntu-20.04-${config:imagetype}
%image = ubuntu-22.04-${config:imagetype}

# As a convenience, the tag of the Pyrex provided image. Defaults to the
# Pyrex version.
Expand Down
9 changes: 5 additions & 4 deletions pyrex.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,11 @@ def prep_container(
container_envvars.extend(config["run"]["envvars"].split())
container_envvars.extend(extra_envvars)

# Pass along BB_ENV_EXTRAWHITE and anything it has whitelisted
if "BB_ENV_EXTRAWHITE" in os.environ:
engine_args.extend(["-e", "BB_ENV_EXTRAWHITE"])
container_envvars.extend(os.environ["BB_ENV_EXTRAWHITE"].split())
# Pass along extra environment variables
for e in ("BB_ENV_EXTRAWHITE", "BB_ENV_PASSTHROUGH_ADDITIONS"):
if e in os.environ:
engine_args.extend(["-e", e])
container_envvars.extend(os.environ[e].split())

# Pass environment variables. If a variable passed with an argument
# "-e VAR" is not set in the parent environment, podman passes an
Expand Down