Preserve custom CBFS files on flashrom updates

This commit is contained in:
Francis Lam 2018-04-21 17:21:37 -07:00
parent 48ca75a482
commit 1cbae3cc12
No known key found for this signature in database
GPG Key ID: 0A59C698920806EB
4 changed files with 45 additions and 8 deletions

View File

@ -8,8 +8,7 @@ if [ -z "$CBFS_PCR" ]; then
fi
# Load individual files
cbfsfiles=`cbfs -t 50 -l 2>/dev/null | grep "^heads/initrd/"` \
|| die "cbfs list files failed"
cbfsfiles=`cbfs -t 50 -l 2>/dev/null | grep "^heads/initrd/"`
for cbfsname in `echo $cbfsfiles`; do
filename=${cbfsname:12}

View File

@ -1,13 +1,24 @@
#!/bin/sh
. /etc/functions
ROM="$1"
if [ -z "$1" ]; then
die "Usage: $0 /media/kgpe-d16.rom"
if [ "$1" = "-c" ]; then
CLEAN=1
ROM="$2"
else
CLEAN=0
ROM="$1"
fi
if [ ! -e "$ROM" ]; then
die "Usage: $0 [-c] /media/kgpe-d16.rom"
fi
cp "$ROM" /tmp/kgpe-d16.rom
sha256sum /tmp/kgpe-d16.rom
if [ "$CLEAN" -eq 0 ]; then
preserve_rom /tmp/kgpe-d16.rom \
|| die "$ROM: Config preservation failed"
fi
flashrom \
--force \

View File

@ -1,13 +1,24 @@
#!/bin/sh
. /etc/functions
ROM="$1"
if [ -z "$1" ]; then
die "Usage: $0 /media/x230.rom"
if [ "$1" = "-c" ]; then
CLEAN=1
ROM="$2"
else
CLEAN=0
ROM="$1"
fi
if [ ! -e "$ROM" ]; then
die "Usage: $0 [-c] /media/x230.rom"
fi
cp "$ROM" /tmp/x230.rom
sha256sum /tmp/x230.rom
if [ "$CLEAN" -eq 0 ]; then
preserve_rom /tmp/x230.rom \
|| die "$ROM: Config preservation failed"
fi
flashrom \
--force \

View File

@ -198,3 +198,19 @@ check_config() {
cp $1/kexec*.txt /tmp/kexec \
|| die "Failed to copy kexec boot params to tmp"
}
preserve_rom() {
new_rom="$1"
old_files=`cbfs -t 50 -l 2>/dev/null | grep "^heads/"`
for old_file in `echo $old_files`; do
new_file=`cbfs -o $1 -l | grep -x $old_file`
if [ -z "$new_file" ]; then
echo "+++ Adding $old_file to $1"
cbfs -t 50 -r $old_file >/tmp/rom.$$ \
|| die "Failed to read cbfs file from ROM"
cbfs -o $1 -a $old_file -f /tmp/rom.$$ \
|| die "Failed to write cbfs file to new ROM file"
fi
done
}