#!/bin/bash

wget -qO- https://files.openscad.org/OBS-Repository-Key.pub | sudo tee /etc/apt/trusted.gpg.d/obs-openscad-nightly.asc >/dev/null || error "Failed to get repo key"

if [ "$__os_codename" == bookworm ] || [ "$__os_codename" == buster ];then
  sources_codename=Raspbian_12
else
  sources_codename=Raspbian_13
fi

echo "X-Repolib-Name: obs-openscad-nightly
Types: deb
Suites: ./
URIs: https://download.opensuse.org/repositories/home:/t-paul/${sources_codename}/
Architectures: arm64
Signed-By: /etc/apt/trusted.gpg.d/obs-openscad-nightly.asc" | sudo tee /etc/apt/sources.list.d/obs-openscad-nightly.sources >/dev/null || error "Failed to write repo file"

install_packages openscad-nightly
