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