#!/bin/bash

VERSION=$1

rm -rf regress-*.tar.?z cargo-regress*

echo "Downloading regress-$VERSION..."

wget "https://pypi.io/packages/source/r/regress/regress-$VERSION.tar.gz"

tar xf regress-$VERSION.tar.gz

tar cf regress-$VERSION.tar regress-$VERSION

cd regress-$VERSION/

# Configure cargo-vendor-filterer
  cat << EOF >> Cargo.toml
[package.metadata.vendor-filter]
platforms = ["x86_64-unknown-linux-gnu", "i686-unknown-linux-gnu"]
all-features = true
EOF


  if ! [ -f /usr/bin/cargo-vendor-filterer ]; then
    echo "WARNING: Creating unfiltered vendor libs tarball!"
    cargo vendor
  else
    cargo vendor-filterer
  fi

  mv vendor ../cargo-regress-$VERSION
cd ../

tar cf cargo-regress-$VERSION.tar cargo-regress-$VERSION

plzip -9 cargo-regress-$VERSION.tar
plzip -9 regress-$VERSION.tar

rm -rf regress-$VERSION
rm -rf cargo-regress-$VERSION
rm -f regress-$VERSION.tar.gz
