#!/bin/sh

#-----------------------------------------------------------------------
# $1=mediaconch Package version,
# $2=libmediainfo Package version,
# $3=libzen Package version,
# $4=,
# $5=,
# $6=Distro extension from OBS,
# $7=Platform, $8=CPU, $9=CPU target
Download_Packages()
{
#-----------------------------------------------------------------------
# Downloading
wget "http://download.opensuse.org/repositories/home:/MediaArea_net/$7/$8/mediaconch$dash$mediainfov-$1$6$9.$type"
mv mediaconch$dash$mediainfov-$1$6$9.$type \
 download/binary/mediaconch/$mediainfov/mediaconch$dash$mediainfov-$destversion$9.$7.$type

wget "http://download.opensuse.org/repositories/home:/MediaArea_net/$7/$8/mediaconch-gui$dash$mediainfov-$1$6$9.$type"
mv mediaconch-gui$dash$mediainfov-$1$6$9.$type \
 download/binary/mediaconch-gui/$mediainfov/mediaconch-gui$dash$mediainfov-$destversion$9.$7.$type
}

#-----------------------------------------------------------------------
# ${1}=Platform
# ${3}=CPU
# ${3}=CPU target
Download_deb_Packages()
{
#-----------------------------------------------------------------------
# Downloading
wget "http://downloadcontent.opensuse.org/repositories/home:/MediaArea_net/${1}/${2}/mediaconch${dash}${mediainfov}${3}.$type"
mv mediaconch${dash}${mediainfov}${3}.$type \
 download/binary/mediaconch/${mediainfov}/mediaconch${dash}${mediainfov}-${destversion}${3}.${1}.$type

wget "http://downloadcontent.opensuse.org/repositories/home:/MediaArea_net/${1}/${2}/mediaconch-gui${dash}${mediainfov}${3}.$type"
mv mediaconch-gui${dash}${mediainfov}${3}.$type \
 download/binary/mediaconch-gui/${mediainfov}/mediaconch-gui${dash}${mediainfov}-${destversion}${3}.${1}.$type
}

#-----------------------------------------------------------------------
# $1=Wx Package version,
# $7=Platform, $8=CPU, $9=CPU target
Download_Wx()
{
wget "http://download.opensuse.org/repositories/home:/MediaArea_net/$7/$8/wxGTK-2.8.12-$1$6$9.$type"
mv wxGTK-2.8.12-$1$6$9.$type \
 download/binary/wxGTK/2.8.12/wxGTK-2.8.12-1$9.$7.$type

wget "http://download.opensuse.org/repositories/home:/MediaArea_net/$7/$8/wxGTK-devel-2.8.12-$1$6$9.$type"
mv wxGTK-devel-2.8.12-$1$6$9.$type \
 download/binary/wxGTK/2.8.12/wxGTK-devel-2.8.12-1$9.$7.$type
}

#-----------------------------------------------------------------------
# $1=MI version, $2=ZL version, $3=Package version
Download_Global()
{
#-----------------------------------------------------------------------
# Clean up
#rm download/binary/mediaconch/$mediainfov/*.rpm -f
#rm download/binary/mediaconch/$mediainfov/*.deb -f
#rm download/binary/mediaconch-gui/$mediainfov/*.rpm -f
#rm download/binary/mediaconch-gui/$mediainfov/*.deb -f
#rm download/binary/libmediainfo0/$libmediainfov/*.rpm -f
#rm download/binary/libmediainfo0/$libmediainfov/*.deb -f
#rm download/binary/libzen0/$libzen/*.rpm -f
#rm download/binary/libzen0/$libzen/*.deb -f
mkdir download/binary/mediaconch/$mediainfov
mkdir download/binary/mediaconch-gui/$mediainfov

#-----------------------------------------------------------------------
# Downloading
type="deb"
devext="dev"
dash="_"
Download_deb_Packages    Debian_7.0    i386   _i386
Download_deb_Packages    Debian_7.0    amd64  _amd64
Download_deb_Packages    Debian_8.0    i386   _i386
Download_deb_Packages    Debian_8.0    amd64  _amd64
Download_deb_Packages    xUbuntu_12.04  i386   _i386
Download_deb_Packages    xUbuntu_12.04  amd64  _amd64
Download_deb_Packages    xUbuntu_14.04  i386   _i386
Download_deb_Packages    xUbuntu_14.04  amd64  _amd64
Download_deb_Packages    xUbuntu_14.10  i386   _i386
Download_deb_Packages    xUbuntu_14.10  amd64  _amd64
Download_deb_Packages    xUbuntu_15.04  i386   _i386
Download_deb_Packages    xUbuntu_15.04  amd64  _amd64

type="rpm"
devext="devel"
dash="-"
Download_Packages $1 $2 $3  x x ""           CentOS_6        i686   .i686
Download_Packages $1 $2 $3  x x ""           CentOS_6        x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           CentOS_7        x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           Fedora_20       i686   .i686
Download_Packages $1 $2 $3  x x ""           Fedora_20       x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           Fedora_21       i686   .i686
Download_Packages $1 $2 $3  x x ""           Fedora_21       x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           Fedora_22       i686   .i686
Download_Packages $1 $2 $3  x x ""           Fedora_22       x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           RHEL_6          i686   .i686
Download_Packages $1 $2 $3  x x ""           RHEL_6          x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           RHEL_7          x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           RHEL_7          ppc64  .ppc64
Download_Packages $1 $2 $3  x x ""           SLE_11          i586   .i586
Download_Packages $1 $2 $3  x x ""           SLE_11          x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           SLE_11_SP1      i586   .i586
Download_Packages $1 $2 $3  x x ""           SLE_11_SP1      x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           SLE_11_SP2      i586   .i586
Download_Packages $1 $2 $3  x x ""           SLE_11_SP2      x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           SLE_11_SP2      ppc64  .ppc64
Download_Packages $1 $2 $3  x x ""           SLE_11_SP3      i586   .i586
Download_Packages $1 $2 $3  x x ""           SLE_11_SP3      x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           SLE_12          x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           openSUSE_11.4   i586   .i586
Download_Packages $1 $2 $3  x x ""           openSUSE_11.4   x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           openSUSE_13.1   i586   .i586
Download_Packages $1 $2 $3  x x ""           openSUSE_13.1   x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           openSUSE_13.2   i586   .i586
Download_Packages $1 $2 $3  x x ""           openSUSE_13.2   x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           openSUSE_Factory i586   .i586
Download_Packages $1 $2 $3  x x ""           openSUSE_Factory x86_64 .x86_64
Download_Packages $1 $2 $3  x x ""           openSUSE_Tumbleweed i586   .i586
Download_Packages $1 $2 $3  x x ""           openSUSE_Tumbleweed x86_64 .x86_64
}

mediainfov="15.06"
destversion="1"

Download_Global 51.1 12.1 2.1 #MediaConch, MediaInfoLib, ZenLib

#mkdir download/binary/wxGTK/2.8.12/
#Download_Wx 6.1 x x  x x ""           CentOS_5        i386   .i386
#Download_Wx 6.1 x x  x x ""           CentOS_5        x86_64 .x86_64
#Download_Wx 6.1 x x  x x ""           CentOS_6        i386   .i386
#Download_Wx 6.1 x x  x x ""           CentOS_6        x86_64 .x86_64
#Download_Wx 6.1 x x  x x ""           CentOS_7        x86_64 .x86_64
#Download_Wx 6.1 x x  x x ""           RHEL_5          i386   .i386
#Download_Wx 6.1 x x  x x ""           RHEL_5          x86_64 .x86_64
#Download_Wx 6.1 x x  x x ""           RHEL_6          i386   .i386
#Download_Wx 6.1 x x  x x ""           RHEL_6          x86_64 .x86_64
#Download_Wx 6.1 x x  x x ""           RHEL_7          x86_64 .x86_64
#Download_Wx 6.1 x x  x x ""           RHEL_7          ppc64  .ppc64
