#!/bin/bash

DEB_DATE=`LC_TIME=en_US.UTF-8 date "+%a, %d %b %Y %H:%M:%S %z"`
RPM_DATE=`LC_TIME=en_US.UTF-8 date "+%a %b %d %Y"`

XMOUNT_VERSION=`cat CMakeLists.txt | grep XMOUNT_VERSION | grep -oP '(?<=\").*?(?=\")'`

echo "Updating package files for version $XMOUNT_VERSION"

# DEB-based
cat debian/changelog.in | sed "s/@@XMOUNT_VERSION@@/$XMOUNT_VERSION/g" | sed "s/@@DEB_DATE@@/$DEB_DATE/g" >debian/changelog

# RPM-based
cat xmount.spec.in | sed "s/@@XMOUNT_VERSION@@/$XMOUNT_VERSION/g" | sed "s/@@RPM_DATE@@/$RPM_DATE/g" >xmount.spec
cat xmount_static.spec.in | sed "s/@@XMOUNT_VERSION@@/$XMOUNT_VERSION/g" | sed "s/@@RPM_DATE@@/$RPM_DATE/g" >xmount_static.spec
