2023-03-18 15:20:03 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
# Download Intel MRC images
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2023-05-14 13:10:51 +00:00
|
|
|
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
|
|
|
set -u -e
|
2023-08-23 17:56:31 +00:00
|
|
|
|
|
|
|
. "include/err.sh"
|
|
|
|
|
2023-05-14 13:10:51 +00:00
|
|
|
export PATH="${PATH}:/sbin"
|
2023-03-18 15:20:03 +00:00
|
|
|
|
|
|
|
# This file is forked from util/chromeos/crosfirmware.sh in coreboot cfc26ce278
|
2023-05-14 13:10:51 +00:00
|
|
|
# Changes to it in *this version* are copyright 2021 and 2023 Leah Rowe, under
|
|
|
|
# the same license as above.
|
2023-03-18 15:20:03 +00:00
|
|
|
|
2023-05-14 13:10:51 +00:00
|
|
|
# use updated manifest from wayback machine, when updating mrc.bin,
|
|
|
|
# and update the other variables below accordingly. current manifest used:
|
|
|
|
# https://web.archive.org/web/20210211071412/https://dl.google.com/dl/edgedl/chromeos/recovery/recovery.conf
|
2023-03-18 15:20:03 +00:00
|
|
|
|
2023-05-14 13:10:51 +00:00
|
|
|
# the wayback machine is used so that we get the same manifest. google
|
|
|
|
# does not seem to version the manifest, but archives are available
|
|
|
|
|
|
|
|
# variables taken from that manifest:
|
|
|
|
|
|
|
|
_board="peppy"
|
|
|
|
_file="chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin"
|
|
|
|
_url="https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin.zip"
|
|
|
|
_url2="https://web.archive.org/web/20200516070928/https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_12239.92.0_peppy_recovery_stable-channel_mp-v3.bin.zip"
|
2023-09-09 15:39:26 +00:00
|
|
|
_sha512sum="340a1cd41136a3ba0de9d306db0e65f51640a2efe63aee9934f326b276adc1af0a2df80c0731c5a749161ec32546909eedfa8ba95801faeb5dcfe1aa4e0840c7"
|
|
|
|
_mrc_complete_hash="e5b6d510a5fdb6a7ba0027588dbceef363a2bf30255e9222020abbe71468822f49962d423d872cc05b37098682281c016445f6aa20f88351a134facfe5f70d5b"
|
2023-05-14 13:10:51 +00:00
|
|
|
_mrc_complete="mrc/haswell/mrc.bin"
|
|
|
|
|
|
|
|
cbdir="coreboot/default"
|
2023-06-24 22:23:16 +00:00
|
|
|
cbfstool="cbutils/default/cbfstool"
|
2023-05-14 13:10:51 +00:00
|
|
|
|
2023-05-14 13:33:21 +00:00
|
|
|
sname=""
|
|
|
|
|
2023-05-14 13:10:51 +00:00
|
|
|
main()
|
|
|
|
{
|
2023-05-14 13:33:21 +00:00
|
|
|
sname=${0}
|
2023-05-14 13:10:51 +00:00
|
|
|
printf "Downloading Intel MRC blobs\n"
|
|
|
|
|
2023-08-23 18:56:01 +00:00
|
|
|
check_existing || return 0
|
|
|
|
build_dependencies
|
2023-08-23 17:56:31 +00:00
|
|
|
fetch_mrc || err "could not fetch mrc.bin"
|
2023-05-14 13:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
check_existing()
|
|
|
|
{
|
2023-08-27 08:25:50 +00:00
|
|
|
[ -f "${_mrc_complete}" ] || \
|
2023-08-23 18:56:01 +00:00
|
|
|
return 0
|
2023-08-21 18:41:49 +00:00
|
|
|
printf 'found existing mrc.bin\n'
|
2023-09-09 15:39:26 +00:00
|
|
|
[ "$(sha512sum "${_mrc_complete}" | awk '{print $1}')" \
|
2023-08-21 18:41:49 +00:00
|
|
|
= "${_mrc_complete_hash}" ] && \
|
2023-08-23 18:56:01 +00:00
|
|
|
return 1
|
2023-08-21 18:41:49 +00:00
|
|
|
printf 'hashes did not match, starting over\n'
|
2023-05-14 13:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_dependencies()
|
|
|
|
{
|
2023-09-01 07:30:08 +00:00
|
|
|
[ -d "${cbdir}/" ] || ./update project trees coreboot default || \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
err "build_dependencies: cannot fetch coreboot/default"
|
2023-08-23 18:56:01 +00:00
|
|
|
./build coreboot utils default || \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
err "build_dependencies: cannot build cbutils/default"
|
2023-05-14 13:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fetch_mrc()
|
|
|
|
{
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
mkdir -p mrc/haswell/ || err "fetch_mrc: !mkdir mrc/haswell"
|
2023-05-14 13:10:51 +00:00
|
|
|
|
|
|
|
(
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
cd mrc/haswell/ || err "fetch_mrc: !cd mrc/haswell"
|
2023-05-14 13:10:51 +00:00
|
|
|
|
2023-09-09 15:39:26 +00:00
|
|
|
download_image "${_url}" "${_file}" "${_sha512sum}"
|
2023-08-21 18:41:49 +00:00
|
|
|
[ -f ${_file} ] || \
|
2023-09-09 15:39:26 +00:00
|
|
|
download_image "${_url2}" "${_file}" "${_sha512sum}"
|
2023-08-21 18:41:49 +00:00
|
|
|
[ -f $_file ] || \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
err "fetch_mrc: ${_file} not downloaded / verification failed."
|
2023-05-14 13:10:51 +00:00
|
|
|
|
2023-08-27 08:25:50 +00:00
|
|
|
extract_partition ROOT-A "${_file}" root-a.ext2
|
2023-05-14 13:10:51 +00:00
|
|
|
extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board}
|
|
|
|
|
|
|
|
extract_coreboot chromeos-firmwareupdate-${_board}
|
|
|
|
|
2023-08-27 08:25:50 +00:00
|
|
|
../../"${cbfstool}" coreboot-*.bin extract -f mrc.bin -n mrc.bin \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
-r RO_SECTION || err "fetch_mrc: could not fetch mrc.bin"
|
2023-05-14 13:10:51 +00:00
|
|
|
rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
"${_file}" "root-a.ext2" || err "fetch_mrc: cannot remove files"
|
2023-05-14 13:10:51 +00:00
|
|
|
|
|
|
|
printf "\n\nmrc.bin saved to ${_mrc_complete}\n\n"
|
|
|
|
)
|
|
|
|
}
|
2023-03-18 15:20:03 +00:00
|
|
|
|
|
|
|
download_image()
|
|
|
|
{
|
2023-05-14 13:44:00 +00:00
|
|
|
url=${1}
|
2023-03-18 15:20:03 +00:00
|
|
|
_file=${2}
|
2023-09-09 15:39:26 +00:00
|
|
|
_sha512sum=${3}
|
2023-03-18 15:20:03 +00:00
|
|
|
|
2023-08-21 18:41:49 +00:00
|
|
|
printf "Downloading recovery image\n"
|
2023-09-04 21:12:02 +00:00
|
|
|
curl --retry 3 "$url" > "$_file.zip" || err "download_image: curl failed"
|
2023-08-21 18:41:49 +00:00
|
|
|
printf "Verifying recovery image checksum\n"
|
2023-09-09 15:39:26 +00:00
|
|
|
if [ "$(sha512sum "${_file}.zip" | awk '{print $1}')" = "${_sha512sum}" ]
|
2023-05-14 13:10:51 +00:00
|
|
|
then
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
unzip -q "${_file}.zip" || err "download_image: cannot unzip"
|
|
|
|
rm -f "${_file}.zip" || err "download_image: can't rm zip {1}"
|
2023-03-18 15:20:03 +00:00
|
|
|
return 0
|
|
|
|
fi
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
rm -f "${_file}.zip" || err "download_image: bad hash, and can't rm zip"
|
|
|
|
err "download_image: Bad checksum. Recovery image deleted"
|
2023-03-18 15:20:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_partition()
|
|
|
|
{
|
|
|
|
NAME=${1}
|
|
|
|
FILE=${2}
|
|
|
|
ROOTFS=${3}
|
|
|
|
_bs=1024
|
|
|
|
|
2023-08-21 18:41:49 +00:00
|
|
|
printf "Extracting ROOT-A partition\n"
|
2023-03-18 15:20:03 +00:00
|
|
|
ROOTP=$( printf "unit\nB\nprint\nquit\n" | \
|
2023-08-27 08:25:50 +00:00
|
|
|
parted "${FILE}" 2>/dev/null | grep "${NAME}" )
|
2023-03-18 15:20:03 +00:00
|
|
|
|
|
|
|
START=$(( $( echo ${ROOTP} | cut -f2 -d\ | tr -d "B" ) ))
|
|
|
|
SIZE=$(( $( echo ${ROOTP} | cut -f4 -d\ | tr -d "B" ) ))
|
|
|
|
|
2023-08-27 08:25:50 +00:00
|
|
|
dd if="${FILE}" of="${ROOTFS}" bs=${_bs} skip=$(( ${START} / ${_bs} )) \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
count=$(( ${SIZE} / ${_bs} )) || \
|
|
|
|
err "extract_partition: can't extract root file system"
|
2023-03-18 15:20:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_shellball()
|
|
|
|
{
|
|
|
|
ROOTFS=${1}
|
|
|
|
SHELLBALL=${2}
|
|
|
|
|
2023-08-21 18:41:49 +00:00
|
|
|
printf "Extracting chromeos-firmwareupdate\n"
|
2023-05-14 13:10:51 +00:00
|
|
|
printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \
|
2023-08-27 08:25:50 +00:00
|
|
|
| debugfs "${ROOTFS}" || err "extract_shellball: debugfs"
|
2023-03-18 15:20:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extract_coreboot()
|
|
|
|
{
|
|
|
|
_shellball=${1}
|
|
|
|
_unpacked=$( mktemp -d )
|
|
|
|
|
2023-08-21 18:41:49 +00:00
|
|
|
printf "Extracting coreboot image\n"
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
|
|
|
|
[ -f "${_shellball}" ] || \
|
|
|
|
err "extract_coreboot: shellball missing in google peppy image"
|
|
|
|
|
2023-08-27 08:25:50 +00:00
|
|
|
sh "${_shellball}" --unpack "${_unpacked}" || \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
err "extract_coreboot: shellball exits with non-zero status"
|
|
|
|
|
|
|
|
# TODO: audit the f* out of that shellball, for each mrc version.
|
|
|
|
# it has to be updated for each mrc update. we should ideally
|
|
|
|
# implement the functionality ourselves.
|
|
|
|
|
|
|
|
[ -f "${_unpacked}/VERSION" ] || \
|
|
|
|
err "extract_coreboot: VERSION file missing on google coreboot rom"
|
2023-03-18 15:20:03 +00:00
|
|
|
|
2023-08-27 08:25:50 +00:00
|
|
|
_version=$( cat "${_unpacked}/VERSION" | grep BIOS\ version: | \
|
2023-08-21 18:41:49 +00:00
|
|
|
cut -f2 -d: | tr -d \ )
|
2023-03-18 15:20:03 +00:00
|
|
|
|
2023-08-27 08:25:50 +00:00
|
|
|
cp "${_unpacked}/bios.bin" "coreboot-${_version}.bin" || \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
err "extract_coreboot: cannot copy google peppy rom"
|
|
|
|
rm -Rf "${_unpacked}" || \
|
|
|
|
err "extract_coreboot: cannot remove extracted google peppy archive"
|
2023-03-18 15:20:03 +00:00
|
|
|
}
|
|
|
|
|
2023-05-14 13:10:51 +00:00
|
|
|
main $@
|