#!/bin/sh

BASE_URL=https://wopr.blih.net/pkgbase/wipbsd/14-CURRENT/\${ABI}/
REPO1=14.snap20210825160516
REPO2=14.snap20210908095137

rm -rf test
rm -rf repos

mkdir repos/
mkdir test

cat > repos/pkgbase.conf <<EOF
pkgbase: {
  url: "${BASE_URL}/${REPO1}"
  enabled: yes
}
EOF

pkg -o ASSUME_ALWAYS_YES=yes \
    -o IGNORE_OSVERSION=yes \
    -o INSTALL_AS_USER=yes \
    -o REPOS_DIR=${PWD}/repos/ \
    -r test update
pkg -o ASSUME_ALWAYS_YES=yes \
    -o IGNORE_OSVERSION=yes \
    -o INSTALL_AS_USER=yes \
    -o REPOS_DIR=${PWD}/repos/ \
    -r test install FreeBSD-utilities

cat > repos/pkgbase.conf <<EOF
pkgbase: {
  url: "${BASE_URL}/${REPO2}"
  enabled: yes
}
EOF

pkg -o ASSUME_ALWAYS_YES=yes \
    -o IGNORE_OSVERSION=yes \
    -o INSTALL_AS_USER=yes \
    -o REPOS_DIR=${PWD}/repos/ \
    -r test update
pkg -o ASSUME_ALWAYS_YES=yes \
    -o IGNORE_OSVERSION=yes \
    -o INSTALL_AS_USER=yes \
    -o REPOS_DIR=${PWD}/repos/ \
    -r test upgrade
