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

extend support for variant builds #578

Merged
merged 6 commits into from
Dec 13, 2019
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
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ RUN --mount=source=.cargo,target=/home/builder/.cargo \
--mount=source=workspaces,target=/home/builder/rpmbuild/BUILD/workspaces \
rpmbuild -ba --clean rpmbuild/SPECS/${PACKAGE}.spec

FROM scratch AS rpm
FROM scratch AS package
COPY --from=rpmbuild /home/builder/rpmbuild/RPMS/*/*.rpm /output/

FROM sdk AS imgbuild
ARG PACKAGES
ARG ARCH
ARG NOCACHE
ARG FLAVOR
ENV FLAVOR=${FLAVOR}
ARG VARIANT
ENV VARIANT=${VARIANT}
WORKDIR /root

USER root
Expand Down Expand Up @@ -91,5 +91,5 @@ RUN --mount=target=/host \
--output-dir=/local/output \
&& echo ${NOCACHE}

FROM scratch AS image
FROM scratch AS variant
COPY --from=imgbuild /local/output/* /output/
55 changes: 29 additions & 26 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ BUILDSYS_TOOLS_DIR = "${BUILDSYS_ROOT_DIR}/tools"
BUILDSYS_SOURCES_DIR = "${BUILDSYS_ROOT_DIR}/workspaces"
BUILDSYS_TIMESTAMP = { script = ["date +%s"] }
BUILDSYS_VERSION = { script = ["git describe --tag --dirty || date +%Y%m%d"] }
BUILDSYS_VARIANT = "aws-k8s"

CARGO_HOME = "${BUILDSYS_ROOT_DIR}/.cargo"
CARGO_MAKE_CARGO_ARGS = "--jobs 8 --offline --locked"
GO_MOD_CACHE = "${BUILDSYS_ROOT_DIR}/.gomodcache"
GO_VERSION = "1.12.5"
DOCKER_BUILDKIT = "1"

[env.development]
IMAGE = "aws-k8s"
# Defined here to allow us to override ${BUILDSYS_ARCH} on the command line.
BUILDSYS_SDK_IMAGE = "thar/sdk-${BUILDSYS_ARCH}:0.0.1"
# Permit pulling directly Upstream URLs when lookaside cache results in MISSes.
Expand Down Expand Up @@ -69,7 +70,7 @@ fi
dependencies = ["setup"]
script = [
'''
for ws in workspaces packages images tools/buildsys ; do
for ws in workspaces packages variants tools/buildsys ; do
cargo fetch --locked --manifest-path ${ws}/Cargo.toml
done
chmod o+r -R ${CARGO_HOME}
Expand Down Expand Up @@ -133,24 +134,24 @@ cargo build \
'''
]

[tasks.build-images]
[tasks.build-variant]
dependencies = ["build-packages"]
script = [
'''
export PATH="${BUILDSYS_TOOLS_DIR}/bin:${PATH}"
cargo build \
${CARGO_BUILD_ARGS} \
${CARGO_MAKE_CARGO_ARGS} \
--manifest-path images/Cargo.toml \
--package ${IMAGE}
--manifest-path variants/Cargo.toml \
--package ${BUILDSYS_VARIANT}
'''
]

[tasks.world-packages]
alias = "build-packages"

[tasks.world-images]
alias = "build-images"
[tasks.world-variant]
alias = "build-variant"

[tasks.check-licenses]
dependencies = ["fetch"]
Expand All @@ -165,37 +166,39 @@ script = [
dependencies = ["fetch"]
script = [
'''
for link in ${BUILDSYS_OUTPUT_DIR}/thar*.lz4; do
if [ -L "${link}" ]; then
rm ${link}
fi
PREFIX="thar-${BUILDSYS_ARCH}-${BUILDSYS_VARIANT}"
for link in ${BUILDSYS_OUTPUT_DIR}/${PREFIX}-*.lz4; do
if [ -L "${link}" ]; then
rm ${link}
fi
done
'''
]

[tasks.link-images]
[tasks.link-variant]
script = [
'''
PREFIX="thar-${BUILDSYS_ARCH}-${IMAGE}-${BUILDSYS_VERSION}"
ln -s ${BUILDSYS_OUTPUT_DIR}/thar-${BUILDSYS_ARCH}.img.lz4 \
${BUILDSYS_OUTPUT_DIR}/${PREFIX}.img.lz4
ln -s ${BUILDSYS_OUTPUT_DIR}/thar-${BUILDSYS_ARCH}-data.img.lz4 \
${BUILDSYS_OUTPUT_DIR}/${PREFIX}-data.img.lz4
ln -s ${BUILDSYS_OUTPUT_DIR}/thar-${BUILDSYS_ARCH}-boot.ext4.lz4 \
${BUILDSYS_OUTPUT_DIR}/${PREFIX}-boot.ext4.lz4
ln -s ${BUILDSYS_OUTPUT_DIR}/thar-${BUILDSYS_ARCH}-root.ext4.lz4 \
${BUILDSYS_OUTPUT_DIR}/${PREFIX}-root.ext4.lz4
ln -s ${BUILDSYS_OUTPUT_DIR}/thar-${BUILDSYS_ARCH}-root.verity.lz4 \
${BUILDSYS_OUTPUT_DIR}/${PREFIX}-root.verity.lz4
PREFIX="thar-${BUILDSYS_ARCH}-${BUILDSYS_VARIANT}"
VERSIONED="${PREFIX}-${BUILDSYS_VERSION}"
ln -snf ${BUILDSYS_OUTPUT_DIR}/${PREFIX}.img.lz4 \
${BUILDSYS_OUTPUT_DIR}/${VERSIONED}.img.lz4
ln -snf ${BUILDSYS_OUTPUT_DIR}/${PREFIX}-data.img.lz4 \
${BUILDSYS_OUTPUT_DIR}/${VERSIONED}-data.img.lz4
ln -snf ${BUILDSYS_OUTPUT_DIR}/${PREFIX}-boot.ext4.lz4 \
${BUILDSYS_OUTPUT_DIR}/${VERSIONED}-boot.ext4.lz4
ln -snf ${BUILDSYS_OUTPUT_DIR}/${PREFIX}-root.ext4.lz4 \
${BUILDSYS_OUTPUT_DIR}/${VERSIONED}-root.ext4.lz4
ln -snf ${BUILDSYS_OUTPUT_DIR}/${PREFIX}-root.verity.lz4 \
${BUILDSYS_OUTPUT_DIR}/${VERSIONED}-root.verity.lz4
'''
]

[tasks.build]
dependencies = [
"link-clean",
"build-images",
"build-variant",
"check-licenses",
"link-images",
"link-variant",
]

[tasks.world]
Expand All @@ -207,7 +210,7 @@ script = ['tools/gen-docs.sh']
[tasks.clean]
script = [
'''
for ws in workspaces packages images tools/buildsys ; do
for ws in workspaces packages variants tools/buildsys ; do
cargo clean --manifest-path ${ws}/Cargo.toml
done
rm -f ${BUILDSYS_TOOLS_DIR}/bin/buildsys
Expand Down
2 changes: 2 additions & 0 deletions macros/shared
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
%_cross_unitdir %{_cross_rootdir}%{_unitdir}
%_cross_userunitdir %{_cross_rootdir}%{_userunitdir}
%_cross_journalcatalogdir %{_cross_rootdir}%{_journalcatalogdir}
%_cross_systemdgeneratordir %{_cross_rootdir}%{_systemdgeneratordir}
%_cross_systemdusergeneratordir %{_cross_rootdir}%{_systemdusergeneratordir}
%_cross_sysusersdir %{_cross_rootdir}%{_sysusersdir}
%_cross_sysctldir %{_cross_rootdir}%{_sysctldir}
%_cross_templatedir %{_cross_datadir}/templates
Expand Down
1 change: 1 addition & 0 deletions packages/host-ctr/host-containerd-tmpfiles.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C /etc/host-containerd/config.toml - - - -
18 changes: 17 additions & 1 deletion packages/host-ctr/host-ctr.spec
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
%global workspace_name host-ctr
%global systemd_systemdir %{_cross_libdir}/systemd/system

Name: %{_cross_os}%{workspace_name}
Version: 0.0
Release: 0%{?dist}
Summary: Thar host container runner
License: FIXME
BuildRequires: %{_cross_os}glibc-devel
Requires: %{_cross_os}containerd

Source10: host-containerd.service
Source11: host-containerd-tmpfiles.conf
Source12: host-containerd-config.toml

%description
%{summary}.
Expand All @@ -24,7 +28,19 @@ go build -buildmode=pie -tags="${BUILDTAGS}" -o host-ctr
install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 host-ctr %{buildroot}%{_cross_bindir}

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:10} %{buildroot}%{_cross_unitdir}

install -d %{buildroot}%{_cross_tmpfilesdir}
install -p -m 0644 %{S:11} %{buildroot}%{_cross_tmpfilesdir}/host-containerd.conf

install -d %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}/host-containerd
install -p -m 0644 %{S:12} %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}/host-containerd/config.toml

%files
%{_cross_bindir}/host-ctr
%{_cross_unitdir}/host-containerd.service
%{_cross_tmpfilesdir}/host-containerd.conf
%{_cross_factorydir}%{_cross_sysconfdir}/host-containerd/config.toml

%changelog
2 changes: 2 additions & 0 deletions packages/login/login
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
exec bash --login
6 changes: 0 additions & 6 deletions packages/login/login.c

This file was deleted.

13 changes: 5 additions & 8 deletions packages/login/login.spec
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
Name: %{_cross_os}login
Version: 0.0.1
Release: 1%{?dist}
Summary: A login that doesn't actually allow logins
Summary: A login helper
License: FIXME
Source0: login.c
Source0: login
BuildRequires: %{_cross_os}glibc-devel

# This package should only be installed if there is no shell.
Conflicts: %{_cross_os}bash
Requires: %{_cross_os}bash
Requires: %{_cross_os}systemd-console

%description
%{summary}.

%prep

%build
%set_cross_build_flags
%{_cross_target}-gcc ${CFLAGS} ${LDFLAGS} -o login %{S:0}

%install
install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 login %{buildroot}%{_cross_bindir}/login
install -p -m 0755 %{S:0} %{buildroot}%{_cross_bindir}/login

%files
%{_cross_bindir}/login
Expand Down
4 changes: 0 additions & 4 deletions packages/release/login

This file was deleted.

1 change: 0 additions & 1 deletion packages/release/release-tmpfiles.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
C /etc/hosts - - - -
C /etc/nsswitch.conf - - - -
C /etc/wicked/ifconfig/eth0.xml - - - -
C /etc/host-containerd/config.toml - - - -
30 changes: 1 addition & 29 deletions packages/release/release.spec
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# To include a shell in Thar, set this to bcond_without.
%bcond_with shell # without

Name: %{_cross_os}release
Version: 0.1.6
Release: 1%{?dist}
Summary: Thar release
License: Public Domain

Source1: login

Source10: hosts
Source11: nsswitch.conf
Source98: release-sysctl.conf
Expand All @@ -19,8 +14,6 @@ Source200: hostname.template

Source1000: eth0.xml
Source1002: configured.target
Source1003: host-containerd.service
Source1004: host-containerd-config.toml
Source1006: prepare-local.service
Source1007: var.mount
Source1008: opt.mount
Expand All @@ -30,9 +23,6 @@ BuildArch: noarch
Requires: %{_cross_os}acpid
Requires: %{_cross_os}apiclient
Requires: %{_cross_os}apiserver
%if %{with shell}
Requires: %{_cross_os}bash
%endif
Requires: %{_cross_os}ca-certificates
Requires: %{_cross_os}chrony
Requires: %{_cross_os}coreutils
Expand All @@ -47,9 +37,6 @@ Requires: %{_cross_os}iproute
Requires: %{_cross_os}kernel
Requires: %{_cross_os}kernel-modules
Requires: %{_cross_os}bork
%if %{without shell}
Requires: %{_cross_os}login
%endif
tjkirch marked this conversation as resolved.
Show resolved Hide resolved
Requires: %{_cross_os}moondog
Requires: %{_cross_os}netdog
Requires: %{_cross_os}signpost
Expand All @@ -65,7 +52,6 @@ Requires: %{_cross_os}updog
Requires: %{_cross_os}util-linux
Requires: %{_cross_os}preinit
Requires: %{_cross_os}wicked
Requires: %{_cross_os}host-ctr
tjkirch marked this conversation as resolved.
Show resolved Hide resolved

%description
%{summary}.
Expand All @@ -75,21 +61,12 @@ Requires: %{_cross_os}host-ctr
%build

%install

%if %{with shell}
install -d %{buildroot}%{_cross_bindir}
install -p -m 0755 %{S:1} %{buildroot}%{_cross_bindir}
%endif

install -d %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}
install -p -m 0644 %{S:10} %{S:11} %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}

install -d %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}/wicked/ifconfig
install -p -m 0644 %{S:1000} %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}/wicked/ifconfig

install -d %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}/host-containerd
install -p -m 0644 %{S:1004} %{buildroot}%{_cross_factorydir}%{_cross_sysconfdir}/host-containerd/config.toml

install -d %{buildroot}%{_cross_sysctldir}
install -p -m 0644 %{S:98} %{buildroot}%{_cross_sysctldir}/80-release.conf

Expand All @@ -104,24 +81,19 @@ VERSION_ID=%{version}
EOF

install -d %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1002} %{S:1003} %{S:1006} %{S:1007} %{S:1008} %{S:1010} %{buildroot}%{_cross_unitdir}
install -p -m 0644 %{S:1002} %{S:1006} %{S:1007} %{S:1008} %{S:1010} %{buildroot}%{_cross_unitdir}

install -d %{buildroot}%{_cross_templatedir}
install -p -m 0644 %{S:200} %{buildroot}%{_cross_templatedir}/hostname

%files
%if %{with shell}
%{_cross_bindir}/login
%endif
%{_cross_factorydir}%{_cross_sysconfdir}/hosts
%{_cross_factorydir}%{_cross_sysconfdir}/nsswitch.conf
%{_cross_factorydir}%{_cross_sysconfdir}/wicked/ifconfig/eth0.xml
%{_cross_factorydir}%{_cross_sysconfdir}/host-containerd/config.toml
%{_cross_sysctldir}/80-release.conf
%{_cross_tmpfilesdir}/release.conf
%{_cross_libdir}/os-release
%{_cross_unitdir}/configured.target
%{_cross_unitdir}/host-containerd.service
%{_cross_unitdir}/prepare-local.service
%{_cross_unitdir}/var.mount
%{_cross_unitdir}/opt.mount
Expand Down
19 changes: 19 additions & 0 deletions packages/systemd/systemd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ Requires: %{_cross_os}libxcrypt
%description
%{summary}.

%package console
Summary: Files for console login using the System and Service Manager

%description console
%{summary}.

%package devel
Summary: Files for development using the System and Service Manager
Requires: %{name}
Expand Down Expand Up @@ -250,6 +256,19 @@ rm -f %{buildroot}%{_cross_libdir}/systemd/network/*
%exclude %{_cross_localstatedir}/log/README
%exclude %{_cross_rundir}

%exclude %{_cross_systemdgeneratordir}/systemd-getty-generator
%exclude %{_cross_unitdir}/console-getty.service
%exclude %{_cross_unitdir}/[email protected]
%exclude %{_cross_unitdir}/[email protected]
%exclude %{_cross_unitdir}/[email protected]

%files console
%{_cross_systemdgeneratordir}/systemd-getty-generator
%{_cross_unitdir}/console-getty.service
%{_cross_unitdir}/[email protected]
%{_cross_unitdir}/[email protected]
%{_cross_unitdir}/[email protected]

%files devel
%{_cross_libdir}/libsystemd.so
%{_cross_libdir}/libudev.so
Expand Down
1 change: 1 addition & 0 deletions packages/workspaces/workspaces.spec
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Requires: %{_cross_os}apiserver = %{version}-%{release}
%package -n %{_cross_os}host-containers
Summary: Manages system- and user-defined host containers
Requires: %{_cross_os}apiserver = %{version}-%{release}
Requires: %{_cross_os}host-ctr
%description -n %{_cross_os}host-containers
%{summary}.

Expand Down
Loading