shamelessly taken from https://github.com/Thrilleratplay/coreboot-builder-scripts thanks a lot!pull/35/head
@ -0,0 +1,103 @@ | |||||
#!/bin/sh | |||||
# SPDX-License-Identifier: GPL-3.0+ | |||||
set -e | |||||
## import variables | |||||
. ./common/variables.sh | |||||
################################################################################ | |||||
## Menu | |||||
################################################################################ | |||||
## Parse avialble models from directory names | |||||
AVAILABLE_MODELS=$(find ./ -maxdepth 1 -mindepth 1 -type d | sed 's/\.\///g' | grep -Ev "common|git") | |||||
## Help menu | |||||
usage() | |||||
{ | |||||
echo "Usage: " | |||||
echo | |||||
echo " $0 [-t <TAG>] [-c <COMMIT>] [--config] [--bleeding-edge] [--clean-slate] <model>" | |||||
echo | |||||
echo " --bleeding-edge Build from the latest commit" | |||||
echo " --clean-slate Purge previous build directory and config" | |||||
echo " -c, --commit <commit> Git commit hash" | |||||
echo " --flash Flash BIOS if build is successful" | |||||
echo " -h, --help Show this help" | |||||
echo " -i, --config Execute with interactive make config" | |||||
echo " -t, --tag <tag> Git tag/version" | |||||
echo | |||||
echo "If a tag, commit or bleeding-edge flag is not given, the latest Coreboot release will be built." | |||||
echo | |||||
echo | |||||
echo "Available models:" | |||||
for AVAILABLE_MODEL in $AVAILABLE_MODELS; do | |||||
echo "$(printf '\t')$AVAILABLE_MODEL" | |||||
done | |||||
} | |||||
## Iterate through command line parameters | |||||
while : | |||||
do | |||||
case "$1" in | |||||
--bleeding-edge) | |||||
COREBOOT_COMMIT="master" | |||||
shift 1;; | |||||
--clean-slate) | |||||
CLEAN_SLATE=true | |||||
shift 1;; | |||||
-c | --commit) | |||||
COREBOOT_COMMIT="$2" | |||||
shift 2;; | |||||
--flash) | |||||
FLASH_AFTER_BUILD=true | |||||
shift 1;; | |||||
-h | --help) | |||||
usage >&2 | |||||
exit 0;; | |||||
-i | --config) | |||||
COREBOOT_CONFIG=true | |||||
shift 1;; | |||||
-t | --tag) | |||||
COREBOOT_TAG="$2" | |||||
shift 2;; | |||||
-*) | |||||
echo "Error: Unknown option: $1" >&2 | |||||
usage >&2 | |||||
exit 1;; | |||||
*) | |||||
break;; | |||||
esac | |||||
done | |||||
## Validate and normalize given model number | |||||
MODEL=$(echo "$@" | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]'); | |||||
## Check if valid model | |||||
if [ -z "$MODEL" ] || [ ! -d "$PWD/$MODEL" ]; then | |||||
usage | |||||
exit 1; | |||||
fi; | |||||
################################################################################ | |||||
################################################################################ | |||||
if [ ! -d "$PWD/$MODEL/build" ]; then | |||||
mkdir "$PWD/$MODEL/build" | |||||
elif [ "$CLEAN_SLATE" ]; then | |||||
rm -rf "$PWD/$MODEL/build" || true | |||||
mkdir "$PWD/$MODEL/build" | |||||
fi | |||||
## Run Docker | |||||
docker run --rm -it \ | |||||
--user "$(id -u):$(id -g)" \ | |||||
-v "$PWD/$MODEL/build:$DOCKER_COREBOOT_DIR" \ | |||||
-v "$PWD/$MODEL:$DOCKER_SCRIPT_DIR" \ | |||||
-v "$PWD/common:$DOCKER_COMMON_SCRIPT_DIR" \ | |||||
-v "$PWD/$MODEL/stock_bios:$DOCKER_STOCK_BIOS_DIR:ro" \ | |||||
-e COREBOOT_COMMIT="$COREBOOT_COMMIT" \ | |||||
-e COREBOOT_TAG="$COREBOOT_TAG" \ | |||||
-e COREBOOT_CONFIG="$COREBOOT_CONFIG" \ | |||||
coreboot/coreboot-sdk:"$COREBOOT_SDK_VERSION" \ | |||||
/home/coreboot/scripts/compile.sh && [ -n "$FLASH_AFTER_BUILD" ] && ./flash.sh "$MODEL" |
@ -0,0 +1,46 @@ | |||||
#!/bin/bash | |||||
# SPDX-License-Identifier: GPL-3.0+ | |||||
# shellcheck disable=SC1091 | |||||
source /home/coreboot/common_scripts/variables.sh | |||||
################################################################################ | |||||
## Copy config and run make | |||||
################################################################################ | |||||
function configAndMake() { | |||||
###################### | |||||
## Copy config ## | |||||
###################### | |||||
if [ -f "$DOCKER_COREBOOT_DIR/.config" ]; then | |||||
echo "Using existing config" | |||||
else | |||||
if [ -f "$DOCKER_SCRIPT_DIR/config-$COREBOOT_COMMIT" ]; then | |||||
cp "$DOCKER_SCRIPT_DIR/config-$COREBOOT_COMMIT" "$DOCKER_COREBOOT_DIR/.config" | |||||
echo "Using config-$COREBOOT_COMMIT" | |||||
elif [ -f "$DOCKER_SCRIPT_DIR/config-$COREBOOT_TAG" ]; then | |||||
cp "$DOCKER_SCRIPT_DIR/config-$COREBOOT_TAG" "$DOCKER_COREBOOT_DIR/.config" | |||||
echo "Using config-$COREBOOT_TAG" | |||||
else | |||||
cp "$DOCKER_SCRIPT_DIR/config" "$DOCKER_COREBOOT_DIR/.config" | |||||
echo "Using default config" | |||||
fi | |||||
fi | |||||
################################# | |||||
## Copy in the X230 VGA BIOS ## | |||||
################################# | |||||
if [ -f "$DOCKER_SCRIPT_DIR/pci8086,0166.rom" ]; then | |||||
cp "$DOCKER_SCRIPT_DIR/pci8086,0166.rom" "$DOCKER_COREBOOT_DIR/pci8086,0166.rom" | |||||
fi | |||||
############## | |||||
## make ## | |||||
############## | |||||
cd "$DOCKER_COREBOOT_DIR" || exit; | |||||
if [ "$COREBOOT_CONFIG" ]; then | |||||
make nconfig | |||||
fi | |||||
make | |||||
} |
@ -0,0 +1,96 @@ | |||||
#!/bin/bash | |||||
# SPDX-License-Identifier: GPL-3.0+ | |||||
# shellcheck disable=SC1091 | |||||
source /home/coreboot/common_scripts/variables.sh | |||||
IS_BUILD_DIR_EMPTY=$(ls -A "$DOCKER_COREBOOT_DIR") | |||||
################################################################################ | |||||
## Update or clone git coreboot repo | |||||
################################################################################ | |||||
function gitUpdate() { | |||||
if [ -z "$IS_BUILD_DIR_EMPTY" ]; then | |||||
# Clone Coreboot and fetch submodules | |||||
git clone https://github.com/coreboot/coreboot.git "$DOCKER_COREBOOT_DIR" | |||||
cd "$DOCKER_COREBOOT_DIR" || exit | |||||
git submodule update --init --recursive --remote | |||||
# blobs are ignored from updates. Manually clone to prevent compile errors later from non empty directory cloning | |||||
git clone https://github.com/coreboot/blobs.git 3rdparty/blobs/ | |||||
else | |||||
cd "$DOCKER_COREBOOT_DIR" || exit | |||||
git fetch --all --tags --prune | |||||
cd "$DOCKER_COREBOOT_DIR/3rdparty/blobs/" || exit | |||||
git fetch --all --tags --prune | |||||
fi | |||||
} | |||||
################################################################################ | |||||
################################################################################ | |||||
## | |||||
################################################################################ | |||||
function checkoutTag() { | |||||
git checkout tags/"$COREBOOT_TAG" || exit | |||||
git submodule update --recursive --remote | |||||
} | |||||
################################################################################ | |||||
################################################################################ | |||||
## | |||||
################################################################################ | |||||
function checkoutCommit() { | |||||
#edge should checkout master | |||||
git checkout "$COREBOOT_COMMIT" || exit | |||||
git submodule update --recursive --remote | |||||
} | |||||
################################################################################ | |||||
################################################################################ | |||||
## Download the latest released version of Coreboot | |||||
################################################################################ | |||||
function downloadCoreboot() { | |||||
CB_RELEASES=$(wget -q -O- https://coreboot.org/releases/sha256sum.txt | sed 's/[^*]*\*//') | |||||
LATEST_RELEASE=$(echo -n "$CB_RELEASES" | grep "coreboot-" | grep -v "coreboot-blobs-" | sort -V | tail -n1) | |||||
LATEST_BLOBS=$(echo -n "$CB_RELEASES" | grep "coreboot-blobs-" | sort -V | tail -n1) | |||||
COREBOOT_VERSION=$(echo -n "$LATEST_RELEASE" | sed 's/coreboot-//' | sed 's/.tar.xz//') | |||||
echo "Beginning download of $LATEST_RELEASE..." | |||||
wget -q -O- "https://coreboot.org/releases/$LATEST_RELEASE" | unxz -c | tar -C "$DOCKER_COREBOOT_DIR" -x --strip 1 | |||||
wget -q -O- "https://coreboot.org/releases/$LATEST_BLOBS" | unxz -c | tar -C "$DOCKER_COREBOOT_DIR" -x --strip 1 | |||||
echo "Downloading $LATEST_RELEASE complete" | |||||
export COREBOOT_VERSION; | |||||
} | |||||
################################################################################ | |||||
################################################################################ | |||||
## MAIN FUNCTION: download/clone/checkout appropriate version of CoreBoot | |||||
######################################## | |||||
######################################################################################################################## | |||||
function downloadOrUpdateCoreboot() { | |||||
if [ -z "$COREBOOT_COMMIT" ] && [ -z "$COREBOOT_TAG" ] && [ -z "$IS_BUILD_DIR_EMPTY" ]; then | |||||
# If a no commit nor tag is given and the directory is empty download Coreboot release | |||||
downloadCoreboot; | |||||
elif [ "$COREBOOT_COMMIT" ]; then | |||||
# DOCKER_COMMIT?=$(shell git log -n 1 --pretty=%h) | |||||
gitUpdate | |||||
checkoutCommit | |||||
elif [ "$COREBOOT_TAG" ]; then | |||||
gitUpdate | |||||
checkoutTag | |||||
fi | |||||
} | |||||
################################################################################ |
@ -0,0 +1,13 @@ | |||||
#!/bin/bash | |||||
# SPDX-License-Identifier: GPL-3.0+ | |||||
################################################################################ | |||||
## VARIABLES | |||||
################################################################################ | |||||
export COREBOOT_SDK_VERSION="1.50" | |||||
export DOCKER_ROOT_DIR="/home/coreboot" | |||||
export DOCKER_SCRIPT_DIR="$DOCKER_ROOT_DIR/scripts" | |||||
export DOCKER_COMMON_SCRIPT_DIR="$DOCKER_ROOT_DIR/common_scripts" | |||||
export DOCKER_COREBOOT_DIR="$DOCKER_ROOT_DIR/cb_build" | |||||
export DOCKER_STOCK_BIOS_DIR="$DOCKER_ROOT_DIR/stock_bios/" |
@ -0,0 +1,43 @@ | |||||
#!/bin/bash | |||||
# SPDX-License-Identifier: GPL-3.0+ | |||||
# shellcheck disable=SC1091 | |||||
source /home/coreboot/common_scripts/variables.sh | |||||
source /home/coreboot/common_scripts/download_coreboot.sh | |||||
source /home/coreboot/common_scripts/config_and_make.sh | |||||
################################################################################ | |||||
## MODEL VARIABLES | |||||
################################################################################ | |||||
MAINBOARD="lenovo" | |||||
MODEL="x230" | |||||
################################################################################ | |||||
############################################### | |||||
## download/git clone/git pull Coreboot ## | |||||
############################################### | |||||
downloadOrUpdateCoreboot | |||||
############################## | |||||
## Copy config and make ## | |||||
############################## | |||||
configAndMake | |||||
##################### | |||||
## Post build ## | |||||
##################### | |||||
if [ ! -f "$DOCKER_COREBOOT_DIR/build/coreboot.rom" ]; then | |||||
echo "Uh oh. Things did not go according to plan." | |||||
exit 1; | |||||
else | |||||
#split out top BIOS | |||||
if [ ! -z "$COREBOOT_COMMIT" ]; then | |||||
RELEASEFILE="${MODEL}_coreboot_seabios_$(echo ${COREBOOT_COMMIT} | cut -c 1-10)_top.rom" | |||||
else | |||||
RELEASEFILE="coreboot_$MAINBOARD-$MODEL-top.rom" | |||||
fi | |||||
dd if="$DOCKER_COREBOOT_DIR/build/coreboot.rom" of="$DOCKER_COREBOOT_DIR/$RELEASEFILE" bs=1M skip=8 | |||||
sha256sum "$DOCKER_COREBOOT_DIR/$RELEASEFILE" > "$DOCKER_COREBOOT_DIR/${RELEASEFILE}".sha256 | |||||
fi |