github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/contrib/containers-common/containers-common.sh (about)

     1  #!/usr/bin/bash -e
     2  #
     3  # Script used for downloading man pages and config files from
     4  # github.com/containers libraries (storage, common, image)
     5  #
     6  # Must be run from directory containing input specfile
     7  #
     8  
     9  die() {
    10      echo "$(basename $0): $*" >&2
    11      exit 1
    12  }
    13  
    14  branchversion() {
    15      gomod=$(git rev-parse --show-toplevel)/go.mod
    16      v=$(awk -v X=github.com/containers/$1 '$1 ~ X { print $2 }' <$gomod)
    17      hash=$(expr "$v" : "v.*-[0-9.]\+-\([0-9a-f]\+\)")
    18      if [[ -n "$hash" ]]; then
    19          v="$hash"
    20      fi
    21      echo "$v"
    22  }
    23  
    24  
    25  SPECFILE=containers-common.spec
    26  if [[ ! -e $SPECFILE.in ]]; then
    27      die "Please run me from the same directory as $SPECFILE.in"
    28  fi
    29  
    30  declare -A moduleversion
    31  for module in common image storage; do
    32      v=$(branchversion $module)
    33      if [[ -z "$v" ]]; then
    34          die "Could not find version for module '$v'"
    35      fi
    36      moduleversion[$module]=$v
    37  done
    38  
    39  builddir=containers-common-${moduleversion[common]}
    40  mkdir -p $builddir
    41  
    42  sed -e "s/COMMON_BRANCH/${moduleversion[common]}/g" \
    43      -e "s/IMAGE_BRANCH/${moduleversion[image]}/g"  \
    44      -e "s/STORAGE_BRANCH/${moduleversion[storage]}/g"  \
    45      <$SPECFILE.in >$builddir/$SPECFILE
    46  
    47  cd $builddir
    48  spectool -fg $SPECFILE
    49  
    50  if [[ ! -e storage.conf ]]; then
    51      die "spectool did not pull storage.conf"
    52  fi
    53  
    54  echo "Changing storage.conf..."
    55  sed -i -e 's/^driver.*=.*/driver = "overlay"/' -e 's/^mountopt.*=.*/mountopt = "nodev,metacopy=on"/' \
    56          storage.conf