#!/bin/bash

VERSION=$1

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

echo "Downloading lurk-$VERSION..."

wget --content-disposition "https://github.com/JakWai01/lurk/archive/refs/tags/v$VERSION.tar.gz"

tar xf lurk-$VERSION.tar.gz

tar cf lurk-$VERSION.tar lurk-$VERSION

cd lurk-$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-lurk-$VERSION
cd ..

tar cf cargo-lurk-$VERSION.tar cargo-lurk-$VERSION

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

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