#!/bin/sh
#
#    Copyright (C) 2025 Luis Guzman <ark@switnet.org>
#    Copyright (C) 2011-2022  Ruben Rodriguez <ruben@trisquel.info>
#    Copyright (C) 2019 Mason Hock <mason@masonhock.com>
#    Copyright (C) 2011  Carlos Pais <freemind@lavabit.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=17
EXTERNAL='deb-src http://archive.ubuntu.com/ubuntu plucky main'

. ./config

#Remove logo
rm data/ubuntu-pro-logo*.svg
sed -i '/ubuntu-pro-logo/d' debian/software-properties-gtk.install

rm softwareproperties/gtk/UbuntuProPage.py
patch_p1 $DATA/remove_snap_label.patch

#Python specific changes
cp $DATA/trisquel_info.py softwareproperties/
sed -i '/import softwareproperties.SoftwareProperties/a from softwareproperties.trisquel_info import trisquel_rel_desc, trisquel_eol' \
       softwareproperties/gtk/SoftwarePropertiesGtk.py
sed -i 's|eol_date = distro.eol|eol_date = trisquel_eol|' softwareproperties/gtk/SoftwarePropertiesGtk.py
sed -i 's|eol_text = .*|eol_text = trisquel_rel_desc|' softwareproperties/gtk/SoftwarePropertiesGtk.py
#Allow to start and remove drivers tab for qt flavor
sed -i '/UbuntuDrivers/d' softwareproperties/qt/SoftwarePropertiesQt.py
sed -i '/tab_switched(self)/i \ \ \ \ self.userinterface.tabWidget.removeTab(4)' softwareproperties/qt/SoftwarePropertiesQt.py
sed -i '/tab_switched(self)/,/self.button_revert.setVisible(True)/{//!d}' softwareproperties/qt/SoftwarePropertiesQt.py

sed '/UbuntuDrivers/d' -i softwareproperties/gtk/SoftwarePropertiesGtk.py
sed '/vbox_drivers/,+1 s/True/False/' -i data/gtkbuilder/main.ui

replace Kubuntu Triskel .
replace Ubuntu Trisquel .
replace ftpmaster@ubuntu.com trisquel-devel@listas.trisquel.info .
replace cdimage@ubuntu.com trisquel-devel@listas.trisquel.info .
replace TrisquelDistribution UbuntuDistribution .
sed '/NoDisplay/d; s/Trisquel/Ubuntu/' -i data/software-properties-gtk.desktop.in

sed '/ubuntu-drivers-common/d' -i debian/control
sed '/ubuntu-pro-client/d' -i debian/control
sed '/ubuntu-advantage-desktop-daemon/d' -i debian/control
sed '/software-properties-drivers/d' -i debian/software-properties-gtk.install setup.cfg

replace "Trisquel-Gettext" "Ubuntu-Gettext" .

#sed '/test_suite/d' -i setup.py
rm -rf tests

rm data/software-properties-drivers.desktop.in
sed -i '/software-properties-drivers/d' po/POTFILES.in
sed -i '/TrisquelProPage/d' po/POTFILES.in

rm data/software-properties-livepatch.desktop.in
sed -i '/software-properties-livepatch.desktop.in/d' po/POTFILES.in
sed -i '/software-properties-livepatch.desktop.in/d' setup.cfg
sed -i '/software-properties-livepatch.desktop/s|^|#|' debian/software-properties-gtk.install

#Remove ProPage
patch_p1 $DATA/rm_init_ubuntu_pro_if_lts.patch
sed -i '/.TrisquelProPage/d' softwareproperties/gtk/SoftwarePropertiesGtk.py

##Apply patch changes
# Livepatch - aramo
# Patch codename for PPAs
# Fix mention of "other packages" as we don't distribute snap.
# Remove extend esm url from update tabs
# Add s-p - 111 new dependency
apply_patch_changes

# Make software-properties-qt visible on Triskel
sed -i '/^NoDisplay=/s|true|false|' data/software-properties-qt.desktop.in
sed -i '/^Icon=/s|applications-other|system-software-install|' data/software-properties-qt.desktop.in

# Trisquel l10n modifications using git patches.
for patch in $(ls -v ${DATA}/l10n/*.patch)
do
    echo "> Applying $(echo $patch|xargs basename)"
    patch_p1 $patch
done

changelog "Removed Ubuntu-specifc tests, Livepatch, Snap and fix PPA integration.
Backport v111 on Ecne for improved deb822 sources support."

package

