@@ -10,6 +10,28 @@ git clone $lkurl $tdir/lk
1010
1111lkrev=$( git -C $tdir /lk show --oneline -s HEAD)
1212
13+ update_hash () {
14+ local tag=$1 ; shift
15+ echo " Updating to $tag "
16+
17+ image=${tag%:* }
18+ sed -i -e " s,$image :[[:xdigit:]]\{40\}\(-dirty\)\?,$tag ,g" $@
19+ }
20+
21+ # First update alpine build bases
22+
23+ # Alpine base image does not use linuxkit pkg, grab the tag from versions.x86_64 instead.
24+ if [ ! -f " $tdir /lk/tools/alpine/versions.x86_64" ] ; then
25+ echo " tools/alpine lacks versions.x86_64 file" >&2
26+ exit 1
27+ fi
28+ tag=$( sed -n -e ' 1s,^\# \(linuxkit/alpine:[[:xdigit:]]\{40\}\)-amd64$,\1,p' $tdir /lk/tools/alpine/versions.x86_64)
29+ if [ ! -n " $tag " ] ; then
30+ echo " Failed to extract tools/alpine tag" >&2
31+ exit 1
32+ fi
33+ update_hash $tag pkg/* /Dockerfile
34+
1335for i in $tdir /lk/pkg/* ; do
1436 if [ ! -d " $i " ] ; then
1537 continue
@@ -21,12 +43,25 @@ for i in $tdir/lk/pkg/* ; do
2143 fi
2244
2345 tag=$( linuxkit pkg show-tag " $i " )
24- echo " Updating to $tag "
25-
26- image=${tag%:* }
27- sed -i -e " s,$image :[[:xdigit:]]\{40\}\(-dirty\)\?,$tag ,g" yml/* .yml
46+ update_hash " $tag " yml/* .yml
2847done
2948
49+ # Kernel doesn't use `linuxkit pkg` and uses a different
50+ # tagging strategy, so we do it manually by extracting the
51+ # "recommended" one from the toplevel linuxkit.yml
52+ # example.
53+ # TODO: add a target to kernel/Makefile which will show
54+ # the recommended kernel.
55+ tag=$( sed -n -e ' s,^\s*image: \(linuxkit/kernel:.\+\)\s*,\1,p' $tdir /lk/linuxkit.yml)
56+ if [ ! -n " $tag " ] ; then
57+ echo " Failed to extract kernel tag" >&2
58+ exit 1
59+ fi
60+ # Not update_hash since the tag is not a hash in this case
61+
62+ echo " Updating to $tag "
63+ sed -i -e " s,linuxkit/kernel:.\+,$tag ,g" yml/* .yml
64+
3065# We manually construct the S-o-b because -F strips the trailing blank
3166# lines, meaning that with -s there is no blank between the "Commit:
3267# ..." and the S-o-b.
@@ -41,4 +76,10 @@ Commit: $lkrev
4176Signed-off-by: $uname <$email >
4277EOF
4378
44- git commit --only -F $tdir /commit-msg yml/* .yml
79+ git commit --only -F $tdir /commit-msg yml/* .yml pkg/* /Dockerfile
80+
81+ # Now update for the result of changes to pkg/*/Dockerfile, this is
82+ # defered until now so we get the new hash instead of the old hash
83+ # with a -dirty suffix.
84+ make update-hashes
85+ git commit --amend --only --no-edit yml/* .yml
0 commit comments