#!/bin/bash
PKGNAM=sqlite

# First, convert the .zip file if needed:
if ls *.zip 1> /dev/null 2> /dev/null ; then
  unzip *.zip
  tar cf $(basename *.zip .zip).tar $(basename *.zip .zip)
  touch -r *.zip *.tar
  xz -9 *.tar
  rm -r $(basename *.zip .zip)
  rm *.zip
fi

VERSION=${VERSION:-$(echo $PKGNAM-autoconf-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
#OLD_STYLE=$(printf %d $(echo $VERSION | cut -b 1)).$(printf %d $(echo $VERSION | cut -b 2,3)).$(printf %d $(echo $VERSION | cut -b 4,5))
OLD_STYLE=$(printf "%1.f" $(echo $VERSION | cut -b 1)).$(printf "%1.f" $(echo $VERSION | cut -b 2,3)).$(printf "%1.f" $(echo $VERSION | cut -b 4,5))
PATCHLEVEL=$(printf "%1.f" $(echo $VERSION | cut -b 6,7))
if [ ! "$PATCHLEVEL" = "0" ]; then
  OLD_STYLE=${OLD_STYLE}.${PATCHLEVEL}
fi

echo $VERSION
echo $PATCHLEVEL
echo $OLD_STYLE
