#!/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=9

. ./config

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

# Apply patches
apply_patch_changes

# 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 -r sed -i "/\.iso/d"
grep -rl '<url>' data/os/manjaro.org/|xargs -r sed -i "/<url>/d"
mv $TMPDIR/* data/os/

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

package
