Automate bitmap image regeneration.

This CL modifies the bitmap generation script as follows:

- allow to specify required geometry of the images and to
 generate a single set per FWID instead of generating all
 geometries for all FWIDs

- store the images and the zip archive in a directory with
  the name derived from FWID.

The CL also adds a wrapper, which given the path to the tree
containing already released GBB firmware volumes would find
all valid (as verified by the CRC in the file name) FWIDs
and generate new images for all detected FWIDs.

The geometry of the generated images is based on the FWID
contents, Marios get 1280x800 and ZGAs - 1366x768.

Once this script stops running, the scripts/bitmaps
directory contains a set of subdirectories, one per
generated set of images.

Another script ran by cygwin on a windows machine was used
to pick up all image sets and regenerate GBB firmware
volumes, will be published under a separate CL.

BUG=chrome-os-partner:792
TEST=see below:

Ran the following command:
 ./process_all_targets.sh  ../../../chromeos-internal/third_party/autotest/files/client/site_tests/

After command completed, the following out_* directories showed up:

(bitmaps 144) ls -1d out*
out_ACER_ASPIREONE_001_8012/
out_ACER_ASPIREONE_001_DEV_0393/
out_ACER_ASPIREONE_002_0710/
out_ACER_ASPIREONE_002_DEV_1017/
out_IEC_MARIO_FISH_2330/
out_IEC_MARIO_PONY_6101/
out_IEC_MARIO_PONY_DEV_3342/
out_IEC_MARIO_PONY_DVT_8784/
out_IEC_MARIO_PONY_EVT_3495/
out_IEC_MARIO_PONY_PREDVT_6766/

with typical directory contents as follows:

(bitmaps 145) tree out_ACER_ASPIREONE_001_8012/
out_ACER_ASPIREONE_001_8012/
|-- 1366x768.zip
|-- BlankBmp
|   `-- BlankBmp.bmp
|-- DeveloperBmp
|   `-- DeveloperBmp.bmp
|-- RecoveryBmp
|   `-- RecoveryBmp.bmp
|-- RecoveryMissingOSBmp
|   `-- RecoveryMissingOSBmp.bmp
`-- RecoveryNoOSBmp
    `-- RecoveryNoOSBmp.bmp

5 directories, 6 files

Review URL: http://codereview.chromium.org/4147008
This commit is contained in:
vbendeb
2010-10-29 08:09:48 -07:00
parent ba04b8b24c
commit 10fce4aa5d
2 changed files with 86 additions and 33 deletions

View File

@@ -15,20 +15,20 @@
# Require one arg
if [ $# -ne "1" ]; then
echo "Usage: $(basename $0) MODEL" 1>&2
if [ $# -ne "2" ]; then
echo "Usage: $(basename $0) <MODEL> <screen geometry>" 1>&2
exit 1
fi
MODEL=$1
geom_crop=$2
nicename=${MODEL// /_}
# Default URL
URL='http://google.com/chromeos/recovery'
# Image parameters
geom_orig='1366x800'
geom_crop_a='1366x768'
geom_crop_b='1280x800'
geom_final='800x600!'
bluecolor='#9ccaec'
bluefont="Helvetica-Narrow"
@@ -38,23 +38,18 @@ whitepointsize=48
# Temporary files
tmpdir=$(mktemp -d /tmp/tmp.XXXXXXXXX)
tmpdir=$(mktemp -d /tmp/tmp.bmp.XXXXXX)
trap "rm -rf $tmpdir" EXIT
img_orig="${tmpdir}/img_orig.bmp"
img_crop_a="${tmpdir}/img_crop_a.bmp"
img_crop_b="${tmpdir}/img_crop_b.bmp"
img_txt_a="${tmpdir}/img_txt_a.bmp"
img_txt_b="${tmpdir}/img_txt_b.bmp"
img_crop="${tmpdir}/img_crop.bmp"
img_txt="${tmpdir}/img_txt.bmp"
label_file="${tmpdir}/label.txt"
label_img="${tmpdir}/label.bmp"
# Output directories
thisdir=$(readlink -e $(dirname $0))
outdir_a=${thisdir}/out_${geom_crop_a}
[ -d "$outdir_a" ] || mkdir -p "$outdir_a"
outdir_b=${thisdir}/out_${geom_crop_b}
[ -d "$outdir_b" ] || mkdir -p "$outdir_b"
outdir="${thisdir}/out_${nicename}"
[ -d "$outdir" ] || mkdir -p "$outdir"
function find_background_color {
src_img=$1
@@ -70,12 +65,9 @@ function process_one_file {
root=$(basename "$src_img")
root=${root%*.*}
# one more layer of heirarchy to match BIOS source tree
dst_dir_a="${outdir_a}/${root}"
[ -d "$dst_dir_a" ] || mkdir -p "$dst_dir_a"
dst_dir_b="${outdir_b}/${root}"
[ -d "$dst_dir_b" ] || mkdir -p "$dst_dir_b"
dst_img_a="${dst_dir_a}/${root}.bmp"
dst_img_b="${dst_dir_b}/${root}.bmp"
dst_dir="${outdir}/${root}"
[ -d "$dst_dir" ] || mkdir -p "$dst_dir"
dst_img="${dst_dir}/${root}.bmp"
echo "processing $root ..."
# First, make sure we start with the right-size original
@@ -85,9 +77,7 @@ function process_one_file {
# Now crop that to the two target sizes
convert "$img_orig" -gravity Center \
-crop "$geom_crop_a"+0+0 +repage "$img_crop_a"
convert "$img_orig" -gravity Center \
-crop "$geom_crop_b"+0+0 +repage "$img_crop_b"
-crop "$geom_crop"+0+0 +repage "$img_crop"
# Add the labels in
if [ -r "$txt_file" ]; then
@@ -118,16 +108,13 @@ function process_one_file {
convert -background "$bg" -gravity center ${tmpdir}/linetxt_*.bmp \
label:'\n\n\n\n' -append "$label_img"
# Finally, layer the label image on top of the original.
composite "$label_img" -gravity south "$img_crop_a" "$img_txt_a"
composite "$label_img" -gravity south "$img_crop_b" "$img_txt_b"
composite "$label_img" -gravity south "$img_crop" "$img_txt"
else
mv "$img_crop_a" "$img_txt_a"
mv "$img_crop_b" "$img_txt_b"
mv "$img_crop" "$img_txt"
fi
# Now scale the result to the final size
convert "$img_txt_a" -scale "$geom_final" -alpha off "$dst_img_a"
convert "$img_txt_b" -scale "$geom_final" -alpha off "$dst_img_b"
convert "$img_txt" -scale "$geom_final" -alpha off "$dst_img"
}
@@ -137,6 +124,4 @@ for file in originals/*.gif; do
done
# Zip up the bitmaps
nicename=${MODEL// /_}
(cd "$outdir_a" && zip -qr "${thisdir}/out_${nicename}__${geom_crop_a}.zip" *)
(cd "$outdir_b" && zip -qr "${thisdir}/out_${nicename}__${geom_crop_b}.zip" *)
(cd "$outdir" && zip -qr "${geom_crop}.zip" *)

View File

@@ -0,0 +1,68 @@
#!/bin/bash -e
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# This script searches the directory tree passed in as the parameter for
# bmp_*.fv files, figures out the FWID strings from files' names, verifies the
# FWIDs' integrity (by recalculating the CRC included in the FWID string) and
# then rebuilds the bitmaps with the appropriate text and target specific
# geometry.
#
# Given a string "<prefix>_<el1>_<el2>_.._<eln>_<suffix>" print string
# '<el1> <el2> .. <eln>', i.e. <prefix>_ and _<suffix> dropped and underscores
# replaced with spaces.
get_elements() {
echo $1 | awk 'BEGIN {FS="_"}; {
x = 2;
do {
printf "%s ", $x;
x += 1
} while (x < (NF - 1))
printf "%s", $(NF-1);
}'
}
# Concatenate input parameters into a space separated string, calculate the
# string's CRC32 and print the last four hex digits of the crc.
signer() {
python -c "import sys,zlib;
me=' '.join(sys.argv[1:]);
print ('%04u'%(zlib.crc32(me)&0xffffffffL))[-4:]" $1
}
if [ "$#" != "1" -o ! -d "$1" ]; then
echo "One parameter is required, the path to the chromeos release tree" >&2
exit 1
fi
tree=$(readlink -f $1)
cd $(dirname "$0")
for f in $(find "${tree}" -type f -name 'bmp_*_[0-9]*.fv'); do
filename=$(basename "$f")
elements="$(get_elements $filename)"
signature=$(signer "${elements}")
# Rebuild file name to verify CRC.
comp_name=bmp_${elements// /_}_${signature}.fv
if [ "${filename}" != "${comp_name}" ]; then
echo "skipping ${filename} (crc mismatch with ${comp_name})"
continue
fi
echo "Processing ${filename}"
case "${elements}" in
(*ACER*) geometry='1366x768'
;;
(*MARIO*) geometry='1280x800'
;;
(*) echo "skipping ${filename}, unknown target geometry"
echo
continue
;;
esac
./make_bmp_images.sh "${elements} ${signature}" "${geometry}"
echo
done