#!/bin/sh
#
#    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=1
EXTERNAL='deb-src http://ppa.launchpad.net/ubuntustudio-ppa/backports/ubuntu bionic main '
REPOKEY=F596CF7036BBAA6D
BACKPORTS=true

. ./config

# remove dependency on ubuntustudio-installer
sed 's/ubuntustudio-installer, //g' debian/control -i

# remove ubuntu-specific data
rm usr/share/applications/ubuntustudio-*
rm usr/share/desktop-directories/ubuntustudio-info.directory

sed 's/ubuntu-software-center.desktop/gnome-app-install.desktop/g' -i etc/xdg/menus/applications-merged/studio.menu
sed 's/ubuntu/trisquel/g' -i etc/xdg/menus/applications-merged/studio.menu
sed 's/Ubuntu/Trisquel/g' -i etc/xdg/menus/applications-merged/studio.menu

sed 's/Package: ubuntustudio-menu/Package: trisquelstudio-menu/g' -i debian/control

for file in $(grep -l ubuntu usr/share/desktop-directories/ubuntustudio-*); do
	sed 's/ubuntu/trisquel/g' -i $file; done

for file in $(grep -l Ubuntu usr/share/desktop-directories/ubuntustudio-*); do
	sed 's/Ubuntu/Trisquel/g' -i $file; done

mv usr/share/ubuntustudio usr/share/trisquelstudio
mv usr/share/lintian/overrides/ubuntustudio-menu usr/share/lintian/overrides/trisquelstudio-menu
rename  's/ubuntu/trisquel/' usr/share/icons/hicolor/scalable/categories/ubuntustudio-*.svg;
rename  's/ubuntu/trisquel/' usr/share/icons/hicolor/*/places/ubuntustudio-*.png
rename  's/ubuntu/trisquel/' usr/share/desktop-directories/ubuntustudio-*.directory

changelog "Compiled for Trisquel"

compile
