scripts: avoid relying on spaces from sha1sum output

fsdg20230625
Alexei Sorokin 2022-11-29 23:00:51 +03:00 committed by Leah Rowe
parent 7c5334ca0e
commit ec082429ab
4 changed files with 7 additions and 9 deletions

View File

@ -5,13 +5,13 @@
# If you want to make additions, try to add a backup url for download links and # If you want to make additions, try to add a backup url for download links and
# list hashes as sha1 sums. # list hashes as sha1 sums.
{x230 x230t x230i t430 x230edp}{ {x230 x230t x230i x230edp t430}{
ME_hash 039c89c6d44ae11ae2510cbd5fed756e97ed9a31 ME_hash 039c89c6d44ae11ae2510cbd5fed756e97ed9a31
ME_dl https://download.lenovo.com/pccbbs/mobiles/g1rg24ww.exe ME_dl https://download.lenovo.com/pccbbs/mobiles/g1rg24ww.exe
ME_bkup_dl https://web.archive.org/web/20210706183911/https://download.lenovo.com/pccbbs/mobiles/g1rg24ww.exe ME_bkup_dl https://web.archive.org/web/20210706183911/https://download.lenovo.com/pccbbs/mobiles/g1rg24ww.exe
} }
{x220 x220t t420 t520 t420s t520}{ {x220 x220t t420 t520 t420s}{
ME_hash fa0f96c8f36646492fb8c57ad3296bf5f647d9c5 ME_hash fa0f96c8f36646492fb8c57ad3296bf5f647d9c5
ME_dl https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles/83rf46ww.exe ME_dl https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles/83rf46ww.exe
ME_bkup_dl https://web.archive.org/web/20220202201637/https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles/83rf46ww.exe ME_bkup_dl https://web.archive.org/web/20220202201637/https://download.lenovo.com/ibmdl/pub/pc/pccbbs/mobiles/83rf46ww.exe

View File

@ -66,7 +66,7 @@ Extract_me(){
curl ${me_dl} > blobs/me.exe || curl ${me_dl_bkup} > blobs/me.exe curl ${me_dl} > blobs/me.exe || curl ${me_dl_bkup} > blobs/me.exe
if [ ! "$(sha1sum blobs/me.exe)" = "${me_hash} blobs/me.exe" ]; then if [ "$(sha1sum blobs/me.exe | awk '{print $1}')" != "${me_hash}" ]; then
printf 'checksum of downloaded me did not mactch\ncorrupted me downloaded or wrong me for board\n' printf 'checksum of downloaded me did not mactch\ncorrupted me downloaded or wrong me for board\n'
rm blobs/me.exe rm blobs/me.exe
return 1 return 1

View File

@ -230,10 +230,8 @@ rm -f "${romdir}"/*
if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then
if [ -f "payload/grub/grub_usqwerty.cfg" ]; then if [ -f "payload/grub/grub_usqwerty.cfg" ]; then
grubrefchecksum="$(sha1sum resources/grub/config/grub.cfg)" grubrefchecksum="$(sha1sum resources/grub/config/grub.cfg | awk '{print $1}')"
grubrefchecksum="${grubrefchecksum% resources/grub/config/grub.cfg}" grubbuildchecksum="$(sha1sum payload/grub/grub_usqwerty.cfg | awk '{print $1}')"
grubbuildchecksum="$(sha1sum payload/grub/grub_usqwerty.cfg)"
grubbuildchecksum="${grubbuildchecksum% payload/grub/grub_usqwerty.cfg}"
if [ "${grubrefchecksum}" != "${grubbuildchecksum}" ]; then if [ "${grubrefchecksum}" != "${grubbuildchecksum}" ]; then
rm -Rf payload/grub/ rm -Rf payload/grub/
printf "Changes detected to GRUB. Re-building now:\n" printf "Changes detected to GRUB. Re-building now:\n"

View File

@ -35,7 +35,7 @@ download_image()
echo "Downloading recovery image" echo "Downloading recovery image"
curl "$_url" > "$_file.zip" curl "$_url" > "$_file.zip"
if [ "$(sha1sum ${_file}.zip)" = "${_sha1sum} ${_file}.zip" ]; then if [ "$(sha1sum ${_file}.zip | awk '{print $1}')" = "${_sha1sum}" ]; then
unzip -q "${_file}.zip" unzip -q "${_file}.zip"
rm "${_file}.zip" rm "${_file}.zip"
echo "Checksum verification passed for recovery image." echo "Checksum verification passed for recovery image."
@ -95,7 +95,7 @@ check_existing()
_mrc_complete_hash="d18de1e3d52c0815b82ea406ca07897c56c65696" _mrc_complete_hash="d18de1e3d52c0815b82ea406ca07897c56c65696"
if [ -f mrc/haswell/mrc.bin ]; then if [ -f mrc/haswell/mrc.bin ]; then
printf 'found existing mrc.bin, checking its hash\n' printf 'found existing mrc.bin, checking its hash\n'
if [ "$(sha1sum mrc/haswell/mrc.bin)" = "${_mrc_complete_hash} mrc/haswell/mrc.bin" ]; then if [ "$(sha1sum mrc/haswell/mrc.bin | awk '{print $1}')" = "${_mrc_complete_hash}" ]; then
printf 'checksums matched, skipping redownloading image\n' printf 'checksums matched, skipping redownloading image\n'
return 0 return 0
else else