#!/bin/sh
#
#    Copyright (C) 2022 Trisquel GNU/Linux developers
#                       <trisquel-devel@listas.trisquel.info>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
#

VERSION=6

EXTERNAL='deb-src http://ftp.us.debian.org/debian bookworm main'
REPOKEY=6ED0E7B82643E131

. ./config

rd_domain=($(cat $DATA/recommended-distros|grep -v \#|awk '{print$3}'))

# Apply latest patches
for patch in $(ls -v ${DATA}/*.patch)
do
    echo "Applying $patch"
    patch --no-backup-if-mismatch -Np1 < $patch
done

# Remove non-free distros references.
TMPDIR=$(mktemp -d os-XXXX)
for i in "${rd_domain[@]}"
do
    mv data/os/$i $TMPDIR || true
done
# Remove iso url for non-recommended distros, along with manjaro using custom url.
grep -rl "<url>.*.iso.*</url>" data/os/|xargs sed -i "/.iso/d"
grep -rl '<url>' data/os/manjaro.org/|xargs sed -i "/<url>/d"
mv $TMPDIR/* data/os/
# Remove tests that will fail from previos iso url removal.
rm tests/test_isoinfo.py tests/test_schema.py

# Remove ubuntu's artwork to prevent any trademark issue.
sed -i '/derives-from/d' data/os/trisquel.info/trisquel-*.xml.in

changelog "Remove links to non-free distros suggestion from osinfo-db."

compile
