#!/bin/sh
#
#    Copyright (C) 2024  Luis Guzmán <ark@switnet.org>
#
#    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
#

# Placeholder helper, remove or update according latest removal policy on new distro.
VERSION=0
BUILD_UNTIL=12.0

. ./config

# Lower version and remove trisquel suffix to prevent update issues on further actions.
export FULLVERSION="$(sed "s|trisquel$VERSION||" <<< $FULLVERSION)"
new_build=$(( ${FULLVERSION: -1} - 1 ))
export FULLVERSION=("${FULLVERSION%?}$new_build")

# Deprecated helper

# Custom changelog.
changelog(){
head -n 1 debian/changelog | grep -q $UPSTREAM-security && REPO=$CODENAME-security || REPO=$CODENAME
[ "$SECURITY" = true ] && REPO=${CODENAME}-security
[ "$BACKPORT" = true ] || [ "$BACKPORTS" = true ] && REPO=${CODENAME}-backports
echo | dch -b -D $REPO -v $FULLVERSION "$1"
# Make sure the changelog file is identical between archs
/bin/sed "/-- Trisquel/s/.*/ -- Trisquel GNU\/Linux developers <trisquel-devel@listas.trisquel.info>  $DATE/" -i debian/changelog
}

changelog "Set lower version on placeholder package."

package
