#!/bin/bash
+CUR=$PWD
+FROM=.
REPO=/opt/msys2/repositories/saetta/
-if [ ! -e PKGBUILD ]; then exit 0; fi
+while getopts ":f:t:" opt; do
+ case $opt in
+ f)
+ FROM=$OPTARG
+ ;;
+ t)
+ REPO=$OPTARG
+ ;;
+ \?)
+ echo "Invalid option: -$OPTARG" >&2
+ exit 1
+ ;;
+ :)
+ echo "Option -$OPTARG requires an argument." >&2
+ exit 1
+ ;;
+ esac
+done
+
+echo "From: "$FROM
+echo "Repo: "$REPO
+
+if [ ! -d $FROM ]; then echo $FROM" isn't a directory" && exit 0; fi
+if [ ! -d $REPO ]; then echo $REPO" isn't a directory" && exit 0; fi
+
+cd $FROM
+if [ ! -e PKGBUILD ]; then "No PKGBUILD file found in "$FROM && exit 0; fi
_realname=`cat PKGBUILD | grep _realname=`
_pkgver=`cat PKGBUILD | grep pkgver=`
pkgver=${_pkgver:7}
pkgrel=${_pkgrel:7}
-echo $realname
-echo $pkgver
-echo $pkgrel
+echo "realname: "$realname
+echo "pkgver: "$pkgver
+echo "pkgrel: "$pkgrel
pkgfilename32="mingw-w64-i686-"$realname"-"$pkgver"-"$pkgrel"-any.pkg.tar.xz"
pkgfilename64="mingw-w64-x86_64-"$realname"-"$pkgver"-"$pkgrel"-any.pkg.tar.xz"
cd $REPO
./repo-add saetta.db.tar.gz $pkgfilename32 $pkgfilename64
+
+cd $CUR