Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
8fc69ef
Added draft of a recursive scandir generator
frzb Mar 31, 2022
2f2401c
Corrected import
frzb Mar 31, 2022
5591fc4
Moved creation of tar archive to separate function
frzb Mar 31, 2022
11a6411
Added archive_name to create_tar_archive function
frzb Mar 31, 2022
1981909
Updated package name of r8168 driver package
frzb Mar 31, 2022
4028103
Added remove of duplicates from list of files
frzb Mar 31, 2022
2d13366
Disabled recursively adding directorries
frzb Mar 31, 2022
171d325
Added sorted output excluded and included files
frzb Mar 31, 2022
d5a35d9
Added option keeping metadata of existing dirs
frzb Mar 31, 2022
df2917e
Added reworkerd job from 48_amdgpu_21.50_plugin
frzb Mar 31, 2022
3c8196e
Corrected syntax for calling tar
frzb Apr 1, 2022
2eefdaa
Fixed screwed up tar syntax
frzb Apr 2, 2022
962bb9c
Added draft of a recursive scandir generator
frzb Mar 31, 2022
ff5894b
Added sorted output excluded and included files
frzb Mar 31, 2022
c53c44d
Corrected syntax for calling tar
frzb Apr 2, 2022
a9478b5
Merge branch '58-plugin-directorries-not-owned-by-root-get-root-owner…
frzb Apr 2, 2022
701aeb6
Added test-plugin
frzb Apr 2, 2022
20f6a38
Added closing bracket to function
frzb Apr 2, 2022
49bbbb8
Corrected indentation
frzb Apr 3, 2022
3326c32
Fixed wrong HEREDOC call
frzb Apr 3, 2022
57ac7ab
Excluded tags of prereleases and for sure get last
frzb Apr 3, 2022
5ca9013
Added debugging for extraction of initramfs
frzb Apr 3, 2022
20ac482
Enabled bash debugging output for coinbootmaker
frzb Apr 3, 2022
f235612
Changed from zcat to zstdcat
frzb Apr 3, 2022
b348cc3
Fixed cache path
frzb Apr 3, 2022
dee1ef6
Changed removed rootfs file suffix
frzb Apr 3, 2022
210ccc7
Added debugging copying of plugin
frzb Apr 3, 2022
b8426e9
Add .keep files to keep empty directories in VCS
frzb Feb 7, 2022
7136082
Introduce directory for enabled plugins
frzb Jan 28, 2022
5de8fba
Removed non-used environment variables
frzb Apr 3, 2022
27f5a0b
Set fallback to "latest" for RELEASE
frzb Apr 3, 2022
eb55f83
Added debugging for environment of coinbootmaker
frzb Apr 3, 2022
7f06902
Disabled loading the default environment file
frzb Apr 4, 2022
b2619d1
Added handling of manual set RELEASE/TAG
frzb Apr 4, 2022
65ad679
Corrected wording of nvram
frzb Apr 4, 2022
3b710ce
Added reworked version of Coinbootmaker
frzb Apr 4, 2022
99b0132
Added debugging of /init2 stage
frzb Apr 4, 2022
3b43373
Added debugging of provided plugins
frzb Apr 4, 2022
18a876b
Used proper IP of server
frzb Apr 4, 2022
4fbadda
Put curl ouput to stdout for debugging
frzb Apr 4, 2022
ec81d92
Write output of curl to file for plugin debugging
frzb Apr 4, 2022
64c6ed9
Add interactive debugging access
frzb Apr 4, 2022
4f87a9e
Change execution order for interactive debugging
frzb Apr 4, 2022
0ef7686
Added corrected path for enabled plugins directory
frzb Apr 4, 2022
d36de06
Re-enable steps skipped for debugging
frzb Apr 4, 2022
426c1d2
Added ownership tests for test plugin
frzb Apr 4, 2022
40d50b5
Reorder steps
frzb Apr 5, 2022
0ea3864
Fixed while syntax of test command line
frzb Apr 5, 2022
5e0e7f8
Corrected quoting
frzb Apr 5, 2022
67eb8a1
Set up Ruby via GitHub Actions
frzb Apr 5, 2022
1979a73
Corrected indentation and syntax
frzb Apr 5, 2022
62ef989
Corrected wording
frzb Apr 5, 2022
d96debd
Switched working-directory to server/test
frzb Apr 5, 2022
d461022
Switch over to InSpec tests
frzb Apr 6, 2022
5145bca
Debug cinc-auditor install
frzb Apr 6, 2022
6440f51
Rn cinc-auditor with bundler
frzb Apr 6, 2022
426ab5a
Refined tests
frzb Apr 7, 2022
d9a7aed
Restructure tests, cookstlye linter suggestions
frzb Apr 7, 2022
c7474f5
Added test for Coinboot server plugin endpoint
frzb Apr 7, 2022
33d5167
Add missing trailing / on plugins URL
frzb Apr 7, 2022
aa0b906
Replace matcher and value for plugin body check
frzb Apr 7, 2022
cb2fa3f
Debug plugin deployment
frzb Apr 7, 2022
f07df13
Keep node running for debugging
frzb Apr 7, 2022
8c4c8bd
Improved RELEASE variable handling for Coinbootmaker
frzb Apr 8, 2022
0e85a2b
Corrected file name in test
frzb Apr 8, 2022
e4486b0
Debug pwd before entering test directory
frzb Apr 8, 2022
b6aee4e
Remove cd into test directory
frzb Apr 8, 2022
7d4c338
Further debugging of entering the bundle context
frzb Apr 8, 2022
03974c9
Use ./test to not trigger the command test
frzb Apr 8, 2022
883910d
Slow down for debugging
frzb Apr 8, 2022
97c848e
Enter and leave test directory after inspec run
frzb Apr 9, 2022
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
1 change: 0 additions & 1 deletion .env

This file was deleted.

23 changes: 16 additions & 7 deletions .github/workflows/build_and_run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,20 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Download build artifacts

- name: Download build artifact
uses: actions/download-artifact@v2
with:
path: debirf/build

- name: Setup Ruby and InSpec/Cinc-Auditor
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
working-directory: server/test

- name: Set up Coinboot requirements
shell: bash
# run: https://raw.githubusercontent.com/frzb/coinboot/"${GITHUB_REF##*/}"/setup_coinboot_requirements | bash
run: ./setup_coinboot_requirements

- name: Run Coinboot server and boot workers
Expand All @@ -87,10 +96,10 @@ jobs:
export RELEASE=$PRE_RELEASE_TAG
./server/run_coinboot

- name: Download build artifact
uses: actions/download-artifact@v2
with:
path: debirf/build
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true

- name: Create release on main or develop
# Release on develop keeps the type pre-release
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ The RootFS (`*initramfs*`) and Kernel (`*vmlinuz*`) you want to use are to be pl

#### Plugins

Coinboot plugins should be placed into the directory `./server/plugins`
Coinboot plugins should be placed into the directory `./plugins/enabled`

You can create your own plugins (see below) or pick some at: [./plugins](./plugins)

Expand Down
92 changes: 54 additions & 38 deletions coinbootmaker/coinbootmaker
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -Eeo pipefail

# Copyright (C) 2018 - 2021 Gunter Miegel coinboot.io
# Copyright (C) 2018 - 2022 Gunter Miegel coinboot.io
#
# This file is part of Coinboot.
# This software may be modified and distributed under the terms
Expand All @@ -16,22 +16,27 @@ display_help() {
echo
echo 'Packaged Coinboot pluings are written to the ./builds directory'
echo
echo 'Usage: coinbootmaker [-i] [-h] [-l] [-p <plugin name> <path to initramfs>]'
echo 'Usage: coinbootmaker [-i] [-h] [-l] [-p <plugin build script path>]'
echo
echo '-i Interactive mode - opens a shell in the build environment'
echo '-p <file name> Plugin to build'
echo '-l List plugins available to build'
echo '-h Display this help'
echo '-i Interactive mode - opens a shell in the build environment'
echo '-p <plugin build script path> Plugin to build'
echo '-l List plugins available to build'
echo '-h Display this help'
echo
}

list_plugins() {
echo
echo 'Available plugin build scripts'
echo
pushd . > /dev/null
cd src
find . -type f ! -wholename '*\/upstream*' -name "*.yaml" -printf '%P\n'
popd > /dev/null
echo
find * -type f -print
echo 'Usage: ./coinbootmaker -p <plugin build script path>'
echo
popd > /dev/null

}

while getopts "ip:lh" opt; do
Expand All @@ -58,33 +63,33 @@ done

shift $((OPTIND -1))


WGET='wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0'
CURL='curl --max-time 5 --retry-max-time 20 --retry 999'
CACHE_DIR=$(readlink -f ./cache)
GITHUB_REPO=frzb/coinboot
RELEASE=latest
RELEASE=${RELEASE:-latest}
## initramfs and kernel vmlinuz ##
# RELEASE is set via an environment variable under ./conf/environment
# If the value is 'latest' we determine the latest release, else we use the set value.



if [ $RELEASE = latest ]; then
RESPONSE=$($CURL --silent "https://api.github.com/repos/${GITHUB_REPO}/tags")
sleep 5
while ! TAG=$(echo $RESPONSE | jq -r '.[0].name'); do
while ! TAG=$(echo $RESPONSE | jq -r '[ .[].name | select(test("^pre.*") | not) ] | sort | last'); do
echo "Calling the Github API has failed, repeat ..."
RESPONSE=$($CURL --silent "https://api.github.com/repos/${GITHUB_REPO}/tags")
sleep 5
done
echo "Using latest coinboot-debirf release: $TAG"
sleep 5
done
echo "Coinbootmaker is using the latest (default) Coinboot release: $TAG"
else
TAG=$RELEASE
echo "Coinbootmaker is using Coinboot release: $TAG"
fi

DOWNLOAD_URL=https://github.com/${GITHUB_REPO}/releases/download/${TAG}

if [ -z $KERNEL ]; then
KERNEL=5.4.0-58-generic
KERNEL=5.11.0-46-generic
fi
INITRAMFS=coinboot-initramfs-$KERNEL

Expand All @@ -93,33 +98,44 @@ $WGET $DOWNLOAD_URL/$INITRAMFS -P $CACHE_DIR
fi

BASEDIR=$PWD
#INITRAMFS=$(readlink -f $1)
LOWER=/tmp/$(basename $INITRAMFS)_extracted_by_coinbootmaker/lower
UPPER=/tmp/$(basename $INITRAMFS)_extracted_by_coinbootmaker/upper
WORKING_DIRECTORY=/tmp/$(basename $INITRAMFS)_extracted_by_coinbootmaker/working_dir
MERGED=/tmp/$(basename $INITRAMFS)_extracted_by_coinbootmaker/merged

while sudo runc list | grep coinbootmaker | grep running; do
# Initial Cleanup

while sudo runc list | grep coinbootmaker | grep -q running; do
echo 'Waiting for Coinbootmaker container to be stopped ...'
sudo runc kill coinbootmaker KILL
sleep 1
done

while sudo runc list | grep coinbootmaker | grep stopped; do
while sudo runc list | grep coinbootmaker | grep -q stopped; do
echo 'Waiting for Coinbootmaker container to be cleaned up ...'
sudo runc delete coinbootmaker
sleep 1
done

sudo runc delete coinbootmaker || true
sudo ip link delete cbm-host || true
sudo ip netns delete coinbootmaker || true
if mountpoint $MERGED; then
sudo umount $MERGED
fi
sudo rm -rf $UPPER $LOWER $WORKING_DIRECTORY $MERGED
while sudo ip link | grep -q cbm-host; do
echo 'Waiting for Coinbootmaker network interface to be cleaned up ...'
sudo ip link delete cbm-host
sleep 1
done

while sudo ip netns | grep -q coinbootmaker; do
echo 'Waiting for Coinbootmaker network namespace to be cleaned up ...'
sudo ip netns delete coinbootmaker
sleep 1
done

if mountpoint -q $MERGED; then
sudo umount $MERGED
fi

sudo rm -rf $UPPER $LOWER $WORKING_DIRECTORY $MERGED

# End of initial Cleanup

sudo mkdir -p $UPPER $LOWER $WORKING_DIRECTORY $MERGED
# We create our own TMPFS.
Expand All @@ -136,20 +152,20 @@ cd $LOWER/rootfs
# We have to use 'sudo' for 'cpio' else the ownership of the files in the
# archive is messed up.
# We just extract the nested initramfs archive
zcat $CACHE_DIR/$INITRAMFS | sudo cpio -idvm "rootfs.cgz"
zcat rootfs.cgz | sudo cpio -idm
zstd -d $CACHE_DIR/$INITRAMFS -c | sudo cpio -idm --quiet "rootfs.czst"
zstd -d rootfs.czst -c | sudo cpio -idm --quiet

# The nested initramfs archive can be removed now
sudo rm -v rootfs.cgz
sudo rm rootfs.czst

# Adapt nameserver settings.
# resolv.conf is a symling to the systemd stub resolver which we have to delete beforehand.
sudo rm etc/resolv.conf
sudo tee etc/resolv.conf << EOF
sudo tee etc/resolv.conf << EOF 1> /dev/null
nameserver 1.1.1.1
EOF

sudo tee etc/hosts << EOF
sudo tee etc/hosts << EOF 1> /dev/null
127.0.1.1 coinbootmaker
EOF

Expand All @@ -162,7 +178,7 @@ cd $LOWER
# So we omit the jq limbo and the dependency to jq.
# We use the same set of capabilities as Docker by default does.
#https://github.com/moby/moby/blob/master/oci/defaults.go#L14-L30
sudo tee ./config.json << EOF
sudo tee ./config.json << EOF 1> /dev/null
{
"ociVersion": "1.0.0",
"process": {
Expand Down Expand Up @@ -439,7 +455,7 @@ sudo runc run -d coinbootmaker

# This commands can only be executed if the container is already running.
# So let's wait until it is ready.
while ! sudo runc list | grep coinbootmaker; do
while ! sudo runc list | grep -q coinbootmaker; do
echo 'Waiting for Coinbootmaker container...'
sleep 1
done
Expand All @@ -464,7 +480,7 @@ fi

# Cleanup
sudo runc kill coinbootmaker KILL
while ! sudo runc list | grep coinbootmaker | grep stopped; do
while ! sudo runc list | grep coinbootmaker | grep -q stopped; do
echo 'Waiting for Coinbootmaker container to be stopped ...'
sleep 1
done
Expand All @@ -474,7 +490,7 @@ sudo runc delete coinbootmaker
sudo ip link delete cbm-host
sudo ip netns delete coinbootmaker

echo "Cleaning up directories"
echo "Cleaning up temporary working directories ..."
cd $BASEDIR
sudo umount -v $MERGED
sudo rm -rf $UPPER $LOWER $WORKING_DIRECTORY $MERGED
sudo umount --quiet $MERGED
sudo rm -rf $BASEDIR/plugin $UPPER $LOWER $WORKING_DIRECTORY $MERGED
1 change: 0 additions & 1 deletion debirf/build_and_run_images
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
set -e -o pipefail
set -x

# Copyright (C) 2019 Gunter Miegel coinboot.io
#
Expand Down
2 changes: 1 addition & 1 deletion debirf/debirf
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ else
# FIXME: Move this stuff to Python.
curl -s http://$HTTP_SERVER/plugins/ | grep -v -Fe '[' -e ']' | cut -f 4 -d'"' | while read plugin; do
echo "Downloading and extracting plugin: $plugin"
wget http://$HTTP_SERVER/plugins/$plugin -O - | tar ---no-overwrite -dirPxzvf -
wget http://$HTTP_SERVER/plugins/$plugin -O - | tar --no-overwrite-dir -Pxzvf -
/usr/local/bin/dpkg_status.py --new /tmp/dpkg_status --old /var/lib/dpkg/status --union > /tmp/status_$plugin
mv -v /tmp/status_$plugin /var/lib/dpkg/status
echo '----------------------------'
Expand Down
2 changes: 2 additions & 0 deletions debirf/scripts/create_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ def main(arguments):

print("------------------------------------")

print("------------------------------------")

print("Created Coinboot Plugin:", archive_name)


Expand Down
File renamed without changes.
Empty file added plugins/enabled/.keep
Empty file.
2 changes: 1 addition & 1 deletion server/docker/coinboot-download-helper
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ GITHUB_REPO=frzb/coinboot
if [ $RELEASE = latest ]; then
RESPONSE=$($CURL --silent "https://api.github.com/repos/${GITHUB_REPO}/tags")
sleep 5
while ! TAG=$(echo $RESPONSE | jq -r '.[0].name'); do
while ! TAG=$(echo $RESPONSE | jq -r '[ .[].name | select(test("^pre.*") | not) ] | sort | last'); do
echo "Calling the Github API has failed, repeat ..."
RESPONSE=$($CURL --silent "https://api.github.com/repos/${GITHUB_REPO}/tags")
sleep 5
Expand Down
1 change: 1 addition & 0 deletions server/plugins
Loading