You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
521 B

  1. #!/bin/bash
  2. # compose: no-hooks
  3. upstream_version="$1"
  4. version="${upstream_version/./}"
  5. read -r year_month major minor patch <<< ${version//./ }
  6. if ! [ "${#patch}" == 1 ]; then
  7. echo "Error: build number is not a single digit: '${patch}' (upstream: '${upstream_version}')" >&2
  8. exit 1
  9. fi
  10. if [ "${#major}" -gt 2 ]; then
  11. echo "Error: major number is more than 2 digits: '${major}' (upstream: '${upstream_version}')" >&2
  12. exit 1
  13. fi
  14. major=$(printf "%02d" ${major})
  15. echo "${year_month}${major}.${minor}.${patch}"