2021-04-28 02:06:56 +00:00
#!/usr/bin/env bash
function clone_ipxe_upstream( ) {
local ipxe_src_dir = " $1 "
2021-04-29 06:03:21 +00:00
#if [ -d "$ipxe_src_dir" ]; then
# >&2 echo "Clone dir location already exists."
# return 1
#fi
2021-04-28 02:06:56 +00:00
2021-04-29 06:03:21 +00:00
#git clone git://git.ipxe.org/ipxe.git "$ipxe_src_dir" || return 1
2021-04-29 21:19:26 +00:00
git submodule update --init --recursive
2021-04-29 22:34:05 +00:00
curr = " $( pwd ) "
2021-04-28 02:06:56 +00:00
cd " $ipxe_src_dir "
# Known good commit
git checkout 56f7d44fde1d6ac196d115cc7dddd58e7ec098fa || return 1
2021-04-29 22:34:05 +00:00
cd " $curr "
2021-04-28 02:06:56 +00:00
return 0
}
function sed_enabled_ipxe_features( ) {
local ipxe_src_dir = " $1 "
if [ ! -d " $ipxe_src_dir " ] || [ [ ! -f " ${ ipxe_src_dir } /src/config/general.h " ] ] ; then
>& 2 echo "Either no IXPE src dir was supplied, or the supplied dir does not exist."
return 1
fi
2022-09-20 10:54:44 +00:00
for OPTION in DOWNLOAD_PROTO_HTTPS \
NSLOOKUP_CMD \
TIME_CMD \
DIGEST_CMD \
REBOOT_CMD \
POWEROFF_CMD \
IMAGE_TRUST_CMD \
NTP_CMD \
CERT_CMD
do
2022-09-20 10:59:59 +00:00
sed -i -r \
2022-09-20 10:58:14 +00:00
" s/^\\/+#define[[:space:]]+ $OPTION [[:space:]]/#define $OPTION /g " \
2022-09-20 10:54:44 +00:00
" ${ ipxe_src_dir } /src/config/general.h "
2022-09-20 10:59:59 +00:00
sed -i -r \
2022-09-20 10:58:14 +00:00
" s/^#undef[[:space:]]+ $OPTION [[:space:]]/#define $OPTION /g " \
2022-09-20 10:54:44 +00:00
" ${ ipxe_src_dir } /src/config/general.h "
done
2021-04-28 02:06:56 +00:00
2022-09-20 11:28:10 +00:00
echo "Downloading default iPXE CA certificate"
wget -O ipxe_root_ca.crt https://ipxe.org/_media/certs/ca.crt
2021-04-28 02:06:56 +00:00
return 0
}
function make_ipxe_lkrn( ) {
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
2021-04-29 22:34:05 +00:00
curr = " $( pwd ) "
2021-04-28 02:06:56 +00:00
cd " ${ ipxe_src_dir } /src/ " || return 1
2022-09-20 12:26:11 +00:00
make bin/ipxe.lkrn EMBED = " ${ embed_file } " CERT = " ../../ipxe_root_ca.crt, ${ signing_cert } , ${ ca_cert } " TRUST = " ../../ipxe_root_ca.crt, ${ ca_cert } " DEBUG = x509:15 || return 2
2021-04-29 22:42:11 +00:00
2021-04-29 22:34:05 +00:00
cd " $curr "
2021-04-28 02:06:56 +00:00
return 0
}
function make_ipxe_iso( ) {
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
2021-04-29 22:34:05 +00:00
curr = " $( pwd ) "
2021-04-28 02:06:56 +00:00
cd " ${ ipxe_src_dir } /src/ " || return 1
2022-09-20 11:39:53 +00:00
make bin/ipxe.iso EMBED = " ${ embed_file } " CERT = " ../../ipxe_root_ca.crt, ${ signing_cert } , ${ ca_cert } " TRUST = " ../../ipxe_root_ca.crt, ${ ca_cert } " || return 2
2021-04-29 22:42:11 +00:00
2021-04-29 22:34:05 +00:00
cd " $curr "
2021-04-28 02:06:56 +00:00
return 0
}
2021-11-29 06:58:38 +00:00
function make_ipxe_dsk( ) {
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
2022-09-20 11:39:53 +00:00
make bin/ipxe.usb EMBED = " ${ embed_file } " CERT = " ../../ipxe_root_ca.crt, ${ signing_cert } , ${ ca_cert } " TRUST = " ../../ipxe_root_ca.crt, ${ ca_cert } " || return 2
2021-11-29 06:58:38 +00:00
cd " $curr "
return 0
}
2021-05-04 05:26:48 +00:00
function make_ipxe_pxe( ) {
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
2022-09-20 11:39:53 +00:00
make bin/ipxe.pxe EMBED = " ${ embed_file } " CERT = " ../../ipxe_root_ca.crt, ${ signing_cert } , ${ ca_cert } " TRUST = " ../../ipxe_root_ca.crt, ${ ca_cert } " || return 2
2021-05-04 05:26:48 +00:00
cd " $curr "
return 0
}
2021-05-14 22:31:29 +00:00
function make_ipxe_efi( ) {
local ipxe_src_dir = " $1 "
local embed_file = " $2 "
local signing_cert = " $3 "
local ca_cert = " $4 "
2021-12-01 15:04:35 +00:00
local efi_key = " $5 "
2021-12-01 14:14:29 +00:00
local efi_cert = " $6 "
2021-05-14 22:31:29 +00:00
embed_file = " $( realpath " ${ embed_file } " ) "
signing_cert = " $( realpath " ${ signing_cert } " ) "
ca_cert = " $( realpath " ${ ca_cert } " ) "
2021-12-01 14:30:46 +00:00
efi_key = " $( realpath " ${ efi_key } " ) "
efi_cert = " $( realpath " ${ efi_cert } " ) "
2021-05-14 22:31:29 +00:00
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
2022-09-20 11:39:53 +00:00
make bin-x86_64-efi/ipxe.efi EMBED = " ${ embed_file } " CERT = " ../../ipxe_root_ca.crt, ${ signing_cert } , ${ ca_cert } " TRUST = " ../../ipxe_root_ca.crt, ${ ca_cert } " || return 2
2021-05-14 22:31:29 +00:00
mv bin-x86_64-efi/ipxe.efi bin/
2021-12-01 14:14:29 +00:00
sbsign --key ${ efi_key } --cert ${ efi_cert } --output bin/ipxe.efi bin/ipxe.efi
2021-05-14 22:31:29 +00:00
cd " $curr "
return 0
}
2021-04-28 02:06:56 +00:00
function make_ipxe_bin_shasums( ) {
local ipxe_src_dir = " $1 "
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
2022-09-19 12:31:35 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.usb " ] ] ; then
>& 2 echo "IPXE USB build file does not exist."
2021-11-29 06:58:38 +00:00
return 1
fi
2021-05-04 05:26:48 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.pxe " ] ] ; then
>& 2 echo "IPXE pxe build file does not exist."
return 1
fi
2021-05-14 22:31:29 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.efi " ] ] ; then
>& 2 echo "IPXE efi build file does not exist."
return 1
fi
2021-04-28 02:06:56 +00:00
2021-04-29 22:34:05 +00:00
curr = " $( pwd ) "
2021-04-28 02:06:56 +00:00
cd " ${ ipxe_src_dir } /src/bin/ " || return 1
2022-09-19 12:31:35 +00:00
sha256sum ipxe.lkrn ipxe.iso ipxe.usb ipxe.pxe ipxe.efi > SHA256SUMS || return 2
2021-05-14 22:31:29 +00:00
2021-04-29 22:34:05 +00:00
cd " $curr "
2021-04-28 02:06:56 +00:00
return 0
}
# Gitconfig needs to already be setup to allow automatic push.
# This function may not be called, and instead builtbot steps like GitTag will
# be used.
function tag_head_and_push( ) {
local git_repo_dir = " $1 "
local remote = " $2 "
local branch = " $3 "
if [ ! -d " $git_repo_dir " ] ; then
>& 2 echo "Supplied directory does not exist."
return 1
fi
if [ [ -z " $remote " ] ] ; then
>& 2 echo "No remote specified."
return 1
fi
if [ [ -z " $branch " ] ] ; then
>& 2 echo "No branch specified."
return 1
fi
2021-04-29 22:34:05 +00:00
curr = " $( pwd ) "
2021-04-28 02:06:56 +00:00
cd " $git_repo_dir "
2021-04-29 21:46:51 +00:00
git config user.name "BuildBot"
git config user.email "buildbot@bitmessage.io"
2021-04-28 02:06:56 +00:00
git tag -n | grep $( git rev-parse HEAD)
if [ $? -eq 0 ] ; then
>& 2 echo 'HEAD tag already exists, bailing out...'
return 1
fi
git tag -a " g_ $( git rev-parse HEAD) " HEAD -m " BuildBot: tag commit for release $( git rev-parse HEAD) " || return 2
2021-04-29 22:42:11 +00:00
#git push --tags origin master
2021-04-28 02:06:56 +00:00
if [ $? -ne 0 ] ; then
>& 2 echo 'Error during attempted git push of new tag'
return 3
fi
2021-04-29 22:34:05 +00:00
cd " $curr "
2021-04-28 02:06:56 +00:00
return 0
}
function create_release( ) {
local git_repo_dir = " $1 "
local branch = " $2 "
local repo_user = " $3 "
local repo_name = " $4 "
local api_token_file = " $5 "
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
2021-04-29 22:34:05 +00:00
curr = " $( pwd ) "
2021-04-28 02:06:56 +00:00
cd " $git_repo_dir "
head = " $( git rev-parse HEAD) "
# Note that the tag_name below must match the tag name in the tag_head_and_push step
tee "release.json" > /dev/null <<EOF
{
"body" : " BuildBot automated release for commit $head " ,
"draft" : false,
"prerelease" : false,
"name" : " r_ $head " ,
"tag_name" : " g_ $head "
}
EOF
curl -X POST " https://git.bitmessage.org/api/v1/repos/ ${ repo_user } / ${ repo_name } /releases " \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H " Authorization: token $( cat $api_token_file ) " \
-i \
-d "@release.json" > release_results.txt
cat release_results.txt | grep ^HTTP/ | grep 201 >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "There was an error creating the release. Manual intervention is needed."
return 2
fi
tail -n 1 release_results.txt | jq .id | grep -P '^(\d)+$' >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "There was an error creating the release. Manual intervention is needed."
return 2
fi
2021-04-29 22:34:05 +00:00
cd " $curr "
2021-04-28 02:06:56 +00:00
return 0
}
function upload_release_ipxe_lkrn( ) {
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
2022-09-19 12:31:35 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.usb " ] ] ; then
>& 2 echo "IPXE USB build file does not exist."
2021-11-29 06:58:38 +00:00
return 1
fi
2021-05-04 05:26:48 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.pxe " ] ] ; then
>& 2 echo "IPXE pxe build file does not exist."
return 1
fi
2021-05-14 22:31:29 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.efi " ] ] ; then
>& 2 echo "IPXE efi build file does not exist."
return 1
fi
2021-04-28 02:06:56 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/SHA256SUMS " ] ] ; then
>& 2 echo "IPXE sha256sums file does not exist."
return 1
fi
2021-04-29 22:34:05 +00:00
curr = " $( pwd ) "
2021-04-28 02:06:56 +00:00
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.lkrn " \
-H "accept: application/json" \
-H " Authorization: token $( cat $api_token_file ) " \
-i \
-F " attachment=@ ${ ipxe_src_dir } /src/bin/ipxe.lkrn " > release_lkrn.txt
cat release_lkrn.txt | grep ^HTTP/ | grep 201 >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "The upload of ipxe.lkrn as a release attachment failed."
return 2
fi
tail -n 1 release_lkrn.txt | jq .id | grep -P '^(\d)+$' >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "The upload of ipxe.lkrn as a release attachment failed."
return 2
fi
2021-04-29 22:34:05 +00:00
cd " $curr "
2021-04-28 02:06:56 +00:00
return 0
}
function upload_release_ipxe_iso( ) {
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
2021-05-04 05:26:48 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.pxe " ] ] ; then
>& 2 echo "IPXE pxe build file does not exist."
return 1
fi
2021-05-14 22:31:29 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.efi " ] ] ; then
>& 2 echo "IPXE efi build file does not exist."
return 1
fi
2021-04-28 02:06:56 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/SHA256SUMS " ] ] ; then
>& 2 echo "IPXE sha256sums file does not exist."
return 1
fi
2021-04-29 22:34:05 +00:00
curr = " $( pwd ) "
2021-04-28 02:06:56 +00:00
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.iso " \
-H "accept: application/json" \
-H " Authorization: token $( cat $api_token_file ) " \
-i \
-F " attachment=@ ${ ipxe_src_dir } /src/bin/ipxe.iso " > release_iso.txt
cat release_iso.txt | grep ^HTTP/ | grep 201 >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "The upload of ipxe.iso as a release attachment failed."
return 2
fi
tail -n 1 release_iso.txt | jq .id | grep -P '^(\d)+$' >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "The upload of ipxe.iso as a release attachment failed."
return 2
fi
2021-04-29 22:34:05 +00:00
cd " $curr "
2021-04-28 02:06:56 +00:00
return 0
}
2021-11-29 06:58:38 +00:00
function upload_release_ipxe_dsk( ) {
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
2022-09-19 12:31:35 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.usb " ] ] ; then
>& 2 echo "IPXE USB build file does not exist."
2021-11-29 06:58:38 +00:00
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) "
2022-09-19 12:31:35 +00:00
curl -X POST " https://git.bitmessage.org/api/v1/repos/ ${ repo_user } / ${ repo_name } /releases/ ${ releaseid } /assets?name=ipxe.usb " \
2021-11-29 06:58:38 +00:00
-H "accept: application/json" \
-H " Authorization: token $( cat $api_token_file ) " \
-i \
2022-09-19 12:31:35 +00:00
-F " attachment=@ ${ ipxe_src_dir } /src/bin/ipxe.usb " > release_usb.txt
2021-11-29 06:58:38 +00:00
2022-09-19 12:31:35 +00:00
cat release_usb.txt | grep ^HTTP/ | grep 201 >/dev/null
2021-11-29 06:58:38 +00:00
if [ $? -ne 0 ] ; then
2022-09-19 12:31:35 +00:00
>& 2 echo "The upload of ipxe.usb as a release attachment failed."
2021-11-29 06:58:38 +00:00
return 2
fi
2022-09-19 12:31:35 +00:00
tail -n 1 release_usb.txt | jq .id | grep -P '^(\d)+$' >/dev/null
2021-11-29 06:58:38 +00:00
if [ $? -ne 0 ] ; then
2022-09-19 12:31:35 +00:00
>& 2 echo "The upload of ipxe.usb as a release attachment failed."
2021-11-29 06:58:38 +00:00
return 2
fi
cd " $curr "
return 0
}
2021-05-04 05:26:48 +00:00
function upload_release_ipxe_pxe( ) {
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
2021-05-14 22:31:29 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.efi " ] ] ; then
>& 2 echo "IPXE efi build file does not exist."
return 1
fi
2021-05-04 05:26:48 +00:00
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.pxe " \
-H "accept: application/json" \
-H " Authorization: token $( cat $api_token_file ) " \
-i \
-F " attachment=@ ${ ipxe_src_dir } /src/bin/ipxe.pxe " > release_pxe.txt
cat release_pxe.txt | grep ^HTTP/ | grep 201 >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "The upload of ipxe.pxe as a release attachment failed."
return 2
fi
tail -n 1 release_pxe.txt | jq .id | grep -P '^(\d)+$' >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "The upload of ipxe.pxe as a release attachment failed."
return 2
fi
cd " $curr "
return 0
}
2021-05-14 22:31:29 +00:00
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
}
2021-04-28 02:06:56 +00:00
function upload_release_ipxe_shasums( ) {
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
2021-05-04 05:26:48 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.pxe " ] ] ; then
>& 2 echo "IPXE pxe build file does not exist."
return 1
fi
2021-05-14 22:31:29 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/ipxe.efi " ] ] ; then
>& 2 echo "IPXE efi build file does not exist."
return 1
fi
2021-04-28 02:06:56 +00:00
if [ [ ! -f " ${ ipxe_src_dir } /src/bin/SHA256SUMS " ] ] ; then
>& 2 echo "IPXE sha256sums file does not exist."
return 1
fi
2021-04-29 22:34:05 +00:00
curr = " $( pwd ) "
2021-04-28 02:06:56 +00:00
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=SHA256SUMS " \
-H "accept: application/json" \
-H " Authorization: token $( cat $api_token_file ) " \
-i \
-F " attachment=@ ${ ipxe_src_dir } /src/bin/SHA256SUMS " > release_shasums.txt
cat release_shasums.txt | grep ^HTTP/ | grep 201 >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "The upload of ipxe SHA256SUMS as a release attachment failed."
return 2
fi
tail -n 1 release_shasums.txt | jq .id | grep -P '^(\d)+$' >/dev/null
if [ $? -ne 0 ] ; then
>& 2 echo "The upload of ipxe SHA256SUMS as a release attachment failed."
return 2
fi
2021-04-29 22:34:05 +00:00
cd " $curr "
2021-04-28 02:06:56 +00:00
return 0
}
2021-04-29 05:14:33 +00:00
if [ [ ! " $( ps -o cmd -p $$ | tail -n 1 | tr -d '\n' ) " = ~ "bash" ] ] ; then
>& 2 echo "Shell not bash, exiting."
exit 1
fi
# This is a bash-specific hack to determine if the file is being sourced or
# run as a script. It will only work in bash, not other shells.
( return 0 2>/dev/null) || " $@ "