#!/bin/bash

# package preload helper for fdroid build.

set -eux

if [[ $# < 3 ]]
then
  exit 1
fi

packagebase=${HOME}'/.local/share/python-for-android/packages'

packagedir=${packagebase}/$1
packageurl=$2
packagename=$3
packagemark='.mark-'${packagename}

if [[ $# == 4 ]]
then
  packagemark='.mark'$4
fi

mkdir -p ${packagedir}
cd ${packagedir}
if [ ! -f ${packagemark} ]
then
  wget -nv ${packageurl}/${packagename}
  touch ${packagemark}
fi
