#!/bin/sh
#
#    Copyright (C) 2008-2023  Ruben Rodriguez <ruben@trisquel.info>
#    Copyright (C)      2024  Luis Guzmán <ark@switnet.org>
#    Copyright (C)      2019  Mason Hock <mason@masonhock.com>
#
#    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=24
DEPENDS=at-spi2-core

. ./config

PRE_REVISION=11.0
PRE_UPSTREAMRELEASE=22.04

rm UpdateManager/Core/LivePatchSocket.py
rm tests/test_livepatch_socket.py

# Important patch make sure to update when necessary.
patch_p1 $DATA/remove-livepatch2.patch

#Closes #12545
patch_p1 $DATA/trisquel-versions.patch

cp $DATA/index.docbook help/C/index.docbook

# Prevent automated connections
patch_p1 $DATA/prevent-autoconnection.patch
# NOTE: prevent-autoconnection.patch l10n is now part of the DATA/l10n/ patches.

# Remove Ubuntu Pro packages updates ; yet another important patch.
patch_p1 $DATA/rm_pro.packages.updates_from_u-m.patch

# Remove snap backend.
#sed -i "/gir1.2-snapd-2,/d" debian/control
#patch_p1 $DATA/rm_snap_backend.patch

replace internet Internet .
replace Ubuntu Trisquel .
replace TrisquelDistroInfo UbuntuDistroInfo .
replace "Trisquel-Gettext" "Ubuntu-Gettext" .

sed -i "s|Trisquel $PRE_UPSTREAMRELEASE LTS to Trisquel $UPSTREAMRELEASE LTS|Trisquel $PRE_REVISION LTS to Trisquel $REVISION LTS|" \
  HweSupportStatus/consts.py

replace kubuntu-desktop triskel .
replace xubuntu-desktop trisquel-mini .
replace edubuntu-desktop toast .
replace ubuntu-desktop trisquel .

# Remove upstream name flavor and python translation module
sed '/%s base/ s/name.*/name = "Trisquel base"/' -i ./UpdateManager/Core/UpdateList.py
sed -i '/from gettext import gettext as _/d' ./UpdateManager/Core/UpdateList.py

sed 's_https://changelogs.ubuntu.com/changelogs/pool/_https://packages.trisquel.org/changelogs/pool/_' -i UpdateManager/Core/MyCache.py

#Make sure apt_pkg is enabled for prevent-autoconnection.patch to work.
[ -z "$(grep 'import apt_pkg' UpdateManager/UpdateManager.py)" ] && \
sed -i '/import distro_info/i import apt_pkg' UpdateManager/UpdateManager.py

#Make use of new TrisquelDistroInfo
for i in UpdateManager/UpdateManager.py hwe-support-status \
	 ubuntu-security-status tests/test_meta_release_core.py \
	 UpdateManager/Core/MetaRelease.py
do
    sed -i 's|UbuntuDistroInfo|TrisquelDistroInfo|g' $i
done

#Fix partial upgrade button
sed -i '/do-partial-upgrade/s|ubuntu-release|trisquel-release|' UpdateManager/Dialogs.py

#Fix base_uri for trisquel meta-release-lts
sed -i 's|changelogs.ubuntu.com/|archive.trisquel.org/trisquel/|' UpdateManager/Core/MetaRelease.py

# Trisquel l10n modifications using git patches.
for patch in $(ls -v ${DATA}/l10n/*.patch)
do
    patch_p1 $patch
done

# Add global pycodestyle patch
echo "> Apply 99_pycodestyle_pass.patch"
patch_p1 $DATA/extra/99_pycodestyle_pass.patch

changelog "Compiled for Trisquel"

package

