#!/usr/bin/env bash
#
# 古いパッケージを previous-releases に移動する

BASEDIR="$(dirname $0)"
BACKUP_DIR="${BASEDIR}/previous-releases"

function main() {
  pushd "${BASEDIR}"
  rotate_file "osstech-ucidm-1*.el8*"
  rotate_file "osstech-ucidm-1*.el9*"
}

function rotate_file() {
  target_files=(${1})
  unset 'target_files[-1]'
  for rotate_file in "${target_files[@]}"; do
    mv -v ${rotate_file} ${BACKUP_DIR}/
  done
}

main
