github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/scripts/bump-appc-spec-version (about)

     1  #!/bin/bash -e
     2  #
     3  # Attempt to bump the appc/spec version to the version specified in
     4  # glide.yaml by replacing all occurrences of the current/previous
     5  # version. The old version is taken from stage1/aci/aci-manifest.in.
     6  #
     7  # YMMV, no disclaimer or warranty, etc.
     8  
     9  # make sure we are running in a toplevel directory
    10  if ! [[ "$0" =~ "scripts/bump-appc-spec-version" ]]; then
    11  	echo "This script must be run in a toplevel rkt directory"
    12  	exit 255
    13  fi
    14  
    15  function replace_stuff() {
    16  	local FROM
    17  	local TO
    18  	local REPLACE
    19  
    20  	FROM=$1
    21  	TO=$2
    22  	# escape special characters
    23  	REPLACE=$(sed -e 's/[]\/$*.^|[]/\\&/g'<<< $FROM)
    24  	shift 2
    25  	echo $* | xargs sed -i --follow-symlinks -e "s/$REPLACE/$TO/g"
    26  }
    27  
    28  function replace_all() {
    29  	replace_stuff $1 $2 $(git ls-files | grep -Ev "(CHANGELOG.md|vendor|manifest\.d|glide.lock|glide.yaml)")
    30  }
    31  
    32  PREV=$(grep -Pe 'acVersion' stage1/aci/aci-manifest.in | grep -Po '\d+\.\d+\.\d+')
    33  NEXT=$(grep -A 1 -e '^- package: github.com/appc/spec$' glide.yaml | grep -Po '\d+\.\d+\.\d+')
    34  
    35  if [[ ${PREV} = ${NEXT} ]]; then
    36  	exit 0
    37  fi
    38  
    39  replace_all $PREV $NEXT