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