From c4a532ebae13ec5fdb2b6348652a74c2ca96613c Mon Sep 17 00:00:00 2001 From: Max Weiss Date: Fri, 14 May 2021 15:31:29 -0700 Subject: [PATCH] Add functionality for BuildBot to build and release IPXE EFI --- buildbot/buildbot_steps.sh | 149 ++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 1 deletion(-) diff --git a/buildbot/buildbot_steps.sh b/buildbot/buildbot_steps.sh index ceceda6..dd71a60 100755 --- a/buildbot/buildbot_steps.sh +++ b/buildbot/buildbot_steps.sh @@ -159,6 +159,43 @@ function make_ipxe_pxe() { return 0 } +function make_ipxe_efi() { + local ipxe_src_dir="$1" + local embed_file="$2" + local signing_cert="$3" + local ca_cert="$4" + + embed_file="$(realpath "${embed_file}")" + signing_cert="$(realpath "${signing_cert}")" + ca_cert="$(realpath "${ca_cert}")" + + if [ ! -d "$ipxe_src_dir" ]; then + >&2 echo "IPXE supplied directory does not exist." + return 1 + fi + if [[ ! -f "$embed_file" ]]; then + >&2 echo "IPXE embedded file does not exist." + return 1 + fi + if [[ ! -f "$signing_cert" ]]; then + >&2 echo "IPXE signing cert does not exist." + return 1 + fi + if [[ ! -f "${ca_cert}" ]]; then + >&2 echo "IPXE CA cert does not exist." + return 1 + fi + + curr="$(pwd)" + cd "${ipxe_src_dir}/src/" || return 1 + + make bin-x86_64-efi/ipxe.efi EMBED="${embed_file}" CERT="${signing_cert},${ca_cert}" TRUST="${ca_cert}" || return 2 + mv bin-x86_64-efi/ipxe.efi bin/ + + cd "$curr" + return 0 +} + function make_ipxe_bin_shasums() { local ipxe_src_dir="$1" @@ -178,11 +215,16 @@ function make_ipxe_bin_shasums() { >&2 echo "IPXE pxe build file does not exist." return 1 fi + if [[ ! -f "${ipxe_src_dir}/src/bin/ipxe.efi" ]]; then + >&2 echo "IPXE efi build file does not exist." + return 1 + fi curr="$(pwd)" cd "${ipxe_src_dir}/src/bin/" || return 1 - sha256sum ipxe.lkrn ipxe.iso ipxe.pxe > SHA256SUMS || return 2 + sha256sum ipxe.lkrn ipxe.iso ipxe.pxe ipxe.efi > SHA256SUMS || return 2 + cd "$curr" return 0 } @@ -341,6 +383,10 @@ function upload_release_ipxe_lkrn() { >&2 echo "IPXE pxe build file does not exist." return 1 fi + if [[ ! -f "${ipxe_src_dir}/src/bin/ipxe.efi" ]]; then + >&2 echo "IPXE efi build file does not exist." + return 1 + fi if [[ ! -f "${ipxe_src_dir}/src/bin/SHA256SUMS" ]]; then >&2 echo "IPXE sha256sums file does not exist." return 1 @@ -426,6 +472,10 @@ function upload_release_ipxe_iso() { >&2 echo "IPXE pxe build file does not exist." return 1 fi + if [[ ! -f "${ipxe_src_dir}/src/bin/ipxe.efi" ]]; then + >&2 echo "IPXE efi build file does not exist." + return 1 + fi if [[ ! -f "${ipxe_src_dir}/src/bin/SHA256SUMS" ]]; then >&2 echo "IPXE sha256sums file does not exist." return 1 @@ -511,6 +561,10 @@ function upload_release_ipxe_pxe() { >&2 echo "IPXE pxe build file does not exist." return 1 fi + if [[ ! -f "${ipxe_src_dir}/src/bin/ipxe.efi" ]]; then + >&2 echo "IPXE efi build file does not exist." + return 1 + fi if [[ ! -f "${ipxe_src_dir}/src/bin/SHA256SUMS" ]]; then >&2 echo "IPXE sha256sums file does not exist." return 1 @@ -552,6 +606,95 @@ function upload_release_ipxe_pxe() { return 0 } +function upload_release_ipxe_efi() { + local ipxe_src_dir="$1" + local git_repo_dir="$2" + local branch="$3" + local repo_user="$4" + local repo_name="$5" + local api_token_file="$6" + + if [ ! -d "$git_repo_dir" ]; then + >&2 echo "Supplied directory does not exist." + return 1 + fi + if [[ -z "$branch" ]]; then + >&2 echo "No branch specified." + return 1 + fi + if [[ -z "$repo_user" ]]; then + >&2 echo "No repo username specified." + return 1 + fi + if [[ -z "$repo_name" ]]; then + >&2 echo "No repo name specified." + return 1 + fi + if [[ ! -f "$api_token_file" ]]; then + >&2 echo "API token file does not exist." + return 1 + fi + if [ ! -d "$ipxe_src_dir" ]; then + >&2 echo "IPXE supplied directory does not exist." + return 1 + fi + if [[ ! -f "${ipxe_src_dir}/src/bin/ipxe.lkrn" ]]; then + >&2 echo "IPXE lkrn build file does not exist." + return 1 + fi + if [[ ! -f "${ipxe_src_dir}/src/bin/ipxe.iso" ]]; then + >&2 echo "IPXE iso build file does not exist." + return 1 + fi + if [[ ! -f "${ipxe_src_dir}/src/bin/ipxe.pxe" ]]; then + >&2 echo "IPXE pxe build file does not exist." + return 1 + fi + if [[ ! -f "${ipxe_src_dir}/src/bin/ipxe.efi" ]]; then + >&2 echo "IPXE efi build file does not exist." + return 1 + fi + if [[ ! -f "${ipxe_src_dir}/src/bin/SHA256SUMS" ]]; then + >&2 echo "IPXE sha256sums file does not exist." + return 1 + fi + + curr="$(pwd)" + cd "$git_repo_dir" + + cat release_results.txt | grep ^HTTP/ | grep 201 >/dev/null + if [ $? -ne 0 ]; then + >&2 echo "The release info from the curl step cannot be found." + return 2 + fi + tail -n 1 release_results.txt | jq .id | grep -P '^(\d)+$' >/dev/null + if [ $? -ne 0 ]; then + >&2 echo "The release info from the curl step cannot be found." + return 2 + fi + + releaseid="$(tail -n 1 release_results.txt | jq .id)" + curl -X POST "https://git.bitmessage.org/api/v1/repos/${repo_user}/${repo_name}/releases/${releaseid}/assets?name=ipxe.efi" \ + -H "accept: application/json" \ + -H "Authorization: token $(cat $api_token_file)" \ + -i \ + -F "attachment=@${ipxe_src_dir}/src/bin/ipxe.efi" > release_efi.txt + + cat release_efi.txt | grep ^HTTP/ | grep 201 >/dev/null + if [ $? -ne 0 ]; then + >&2 echo "The upload of ipxe.efi as a release attachment failed." + return 2 + fi + tail -n 1 release_efi.txt | jq .id | grep -P '^(\d)+$' >/dev/null + if [ $? -ne 0 ]; then + >&2 echo "The upload of ipxe.efi as a release attachment failed." + return 2 + fi + + cd "$curr" + return 0 +} + function upload_release_ipxe_shasums() { local ipxe_src_dir="$1" local git_repo_dir="$2" @@ -596,6 +739,10 @@ function upload_release_ipxe_shasums() { >&2 echo "IPXE pxe build file does not exist." return 1 fi + if [[ ! -f "${ipxe_src_dir}/src/bin/ipxe.efi" ]]; then + >&2 echo "IPXE efi build file does not exist." + return 1 + fi if [[ ! -f "${ipxe_src_dir}/src/bin/SHA256SUMS" ]]; then >&2 echo "IPXE sha256sums file does not exist." return 1