2566c1
#!/bin/bash
2566c1
# This script assures we always deliver the current documentation/configs
2566c1
# for the c/storage, c/image and c/common vendored in podman, skopeo, buildah
2566c1
# For questions reach to Jindrich Novy <jnovy@redhat.com>
2566c1
rm -f /tmp/ver_image /tmp/ver_common /tmp/ver_storage
2566c1
CENTOS=""
2566c1
pwd | grep /tmp/centos > /dev/null
2566c1
if [ $? == 0 ]; then
2566c1
  CENTOS=1
2566c1
fi
2566c1
set -e
2566c1
for P in podman skopeo buildah; do
2566c1
  BRN=`pwd | sed 's,^.*/,,'`
2566c1
  rm -rf $P
2566c1
  pkg clone $P
2566c1
  cd $P
2566c1
  [ -z "$CENTOS" ] && pkg switch-branch $BRN
2566c1
  if [ $BRN != stream-container-tools-rhel8 ]; then
2566c1
    pkg prep
2566c1
  else
2566c1
    pkg --release rhel-8 prep
2566c1
  fi
2566c1
  DIR=`ls -d -- */ | grep -v ^tests | head -n1`
2566c1
  grep github.com/containers/image $DIR/go.mod | grep -v - | cut -d\  -f2 >> /tmp/ver_image
2566c1
  grep github.com/containers/common $DIR/go.mod | grep -v - | cut -d\  -f2 >> /tmp/ver_common
2566c1
  grep github.com/containers/storage $DIR/go.mod | grep -v - | cut -d\  -f2 >> /tmp/ver_storage
2566c1
  cd -
2566c1
done
2566c1
IMAGE_VER=`sort -n /tmp/ver_image | head -n1`
2566c1
COMMON_VER=`sort -n /tmp/ver_common | head -n1`
2566c1
STORAGE_VER=`sort -n /tmp/ver_storage | head -n1`
2566c1
sed -i "s,^%global.*image_branch.*,%global image_branch $IMAGE_VER," containers-common.spec
2566c1
sed -i "s,^%global.*common_branch.*,%global common_branch $COMMON_VER," containers-common.spec
2566c1
sed -i "s,^%global.*storage_branch.*,%global storage_branch $STORAGE_VER," containers-common.spec
2566c1
rm -f /tmp/ver_image /tmp/ver_common /tmp/ver_storage
2566c1
rm -rf podman skopeo buildah