#!/usr/bin/bash

# Copyright 2020-2025 Mechtilde and Michael Stehmann <mechtilde@debian.org>
# version 0.9.9

# python plugin for build-gbp.sh

# 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 3 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., 31 Milk Street, #960789 Boston,
# MA 02196, USA.

function PythonRulesDH {
    # Called by DebianRulesTemplate

    sed --in-place \
    --expression="s/dh \$@/dh \$@ --with python3 --buildsystem=pybuild/" \
    ${GitPath}/debian/rules

}
function PythonRules {
    # Called by DebianRulesTemplate

    # These strings will be added to str4rules
    echo -e "export PYBUILD_NAME="${SourceName}"\n" >> ${GitPath}/Debian/rules
    echo -e "export PYBUILD_SYSTEM=distutils\n" >> ${GitPath}/Debian/rules
}

function PythonControl {
    # Called by DebianControlTemplate

    # Recent Python version
    PythonVersion=$(py3versions --installed)

    sed --in-place \
    --expression="s/Section:/Section: python/" ${GitPath}/debian/control

    sed --in-place \
    --expression="/Build-Depends: debhelper-compat ${str4versiondebhelpers}/ \
    a , dh-python@X , python3-all@X , python3-setuptools@X\
    #X-Python3-Version: >=${PythonVersion}" ${GitPath}/debian/control

    
    sed --in-place \
    --expression="/Depends: \${misc:Depends}/ \
    a @X , \${python3:Depends}" \
    ${GitPath}/debian/control

    sed --in-place --expression="s/@X/\n/g" ${GitPath}/debian/control
}

whiptail --title "python plugin found" \
--msgbox "build-gbp-python-plugin.sh was loaded." 15 60

echo "build-gbp-python-plugin.sh was loaded." >> ${log}


# This is the end, my friend
#generated on Sun, 04 May 2025 09:23:46 +0000
