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