Files
meta-mortsgna/scripts/update-recipe-checksums.sh
Andreas Müller f62fa64eca update-recipe-checksums: Repeat update procedure as checksums were replaced
There are two cases which are enhanced:

1. A recipe contains one tarball with new checksums: After replacement the
   script fetches again so a valid tarball is available right after running
   this script.
2. A recipe contains multiple tarballs with new checksums: All checksums are
   corrected and on exit tarballs are usable immedately without further fetch.

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
2020-06-10 17:09:28 +02:00

61 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
# raspberrypi-card-write.sh
# (c) Copyright 2020 Andreas Müller <schnitzeltony@gmail.com>
# Licensed under terms of GPLv2
#
# This script updates checksums in recipes after version bump. It is supposed
# to run run in same environment as bitbake:
#
# update-recipe-checksums.sh [-d <recipedir> <recipes>
#
# where <recipe> can be a single recipe, a packagegroup an image or...
# Includes
. `dirname $0`/include/common-helpers.inc
echo
if [ "$1" = "-d" ]; then
shift
_TOPDIR="$1"
echo -e "${style_bold}Use $1 as recipe directory...${style_normal}"
shift
fi
if [ -z "$1" ]; then
ErrorOut "No fetch target set in first parameter!"
fi
if [ "x$_TOPDIR" = "x" ]; then
echo -e "${style_bold}Ask bitbake for recipe directory...${style_normal}"
GetBitbakeEnvVar "TOPDIR"
_TOPDIR="$BitbakeEnvVar"
fi
echo
echo -e "${style_bold}Run bitbake -k --runall=fetch $@...${style_normal}"
while true; do
replaced=""
bitbake -k --runall=fetch "$@" 2>&1 | while read line; do
if echo "$line" | grep -q "was expected"; then
# Shorten line to ensure not being confused by filenames containing spaces
line=`echo "$line" | sed 's:.*checksum ::'`
# Extract checksums
newchecksum=`echo "$line" | awk '{print $1}'`
oldchecksum=`echo "$line" | awk '{print $3}'`
# Lazy way: just grep for old checksums to find recipes
for recipe in `grep -rl "$oldchecksum" "${_TOPDIR}"`; do
if [ -f "$recipe" ]; then
replaced="1"
EvalExAuto "sed -i '"s:$oldchecksum:$newchecksum:"' "$recipe"" "Change checksum in $recipe to $newchecksum"
fi
done
fi
done
if [ $replaced != "1" ]
break
fi
done