#!/usr/bin/env bash

# omarchy:summary=Print the active Omarchy mirror and package channel

# Based: the channel is the based-* apt source the machine tracks.
# based-ddev, based-udev and based-u26dev are the dev channel; based-d13,
# based-u24 and based-u26 the stable one.
apt_dir=${OMARCHY_APT_DIR:-/etc/apt}
sources=$(cat "$apt_dir/sources.list" "$apt_dir"/sources.list.d/* 2>/dev/null)

if grep -qE '/based-(ddev|udev|u26dev)([[:space:]/]|$)' <<<"$sources"; then
  echo dev
elif grep -qE '/based-(d13|u24|u26)([[:space:]/]|$)' <<<"$sources"; then
  echo stable
else
  echo unknown
fi
