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