Consolidated windows getFNA scripts and fixed possible bug in shell script

This commit is contained in:
Caleb Cornett 2018-10-09 14:27:50 -04:00
parent 8edae2cf04
commit 81ed7b6044
4 changed files with 121 additions and 71 deletions

View File

@ -46,7 +46,7 @@ function getLibs()
{
# Downloading
echo "Downloading latest fnalibs..."
curl http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 > fnalibs.tar.bz2
curl http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 > $MYDIR/fnalibs.tar.bz2
if [ $? -eq 0 ]; then
echo "Finished downloading!"
else
@ -57,10 +57,10 @@ function getLibs()
# Decompressing
echo "Decompressing fnalibs..."
mkdir -p $MY_DIR/fnalibs
tar xjC $MY_DIR/fnalibs -f fnalibs.tar.bz2
tar xjC $MY_DIR/fnalibs -f $MY_DIR/fnalibs.tar.bz2
if [ $? -eq 0 ]; then
echo "Finished decompressing!"
rm fnalibs.tar.bz2
rm $MY_DIR/fnalibs.tar.bz2
else
>&2 echo "ERROR: Unable to decompress successfully."
exit 1

View File

@ -1,34 +0,0 @@
# getFNA_Win
# Clones/pulls the latest FNA from Github for use as a project reference.
# Usage: ./getFNA_Win.bat
git --version > $null
if ( -Not $? ) {
Write-Error "ERROR: Git is required to pull FNA from the command line."
Write-Output "Either install git or download and unzip FNA manually."
exit 1
}
# Downloading
if ( -Not (Test-Path -Path "FNA") ) {
Write-Output "Cloning FNA..."
git clone https://github.com/FNA-XNA/FNA.git --recursive
if ($?) {
Write-Output "Finished cloning!"
}
else {
Write-Error "ERROR: Unable to clone successfully. Maybe try again later?"
exit 1
}
}
else {
Write-Output "Pulling the latest git version of FNA..."
git -C FNA pull --recurse-submodules
if ($?) {
Write-Output "Finished updating!"
}
else {
Write-Error "ERROR: Unable to update."
exit 1
}
}

View File

@ -1,34 +0,0 @@
# getLibs_Win
# Downloads and untars the latest archive of pre-compiled native libraries for FNA.
# Note: This requires 7-Zip to be installed.
# Usage: ./getLibs
# Downloading
Write-Output "Downloading latest fnalibs..."
Invoke-WebRequest -Uri http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 -OutFile fnalibs.tar.bz2
if ($?) {
Write-Output "Finished downloading!"
}
else {
Write-Error "ERROR: Unable to download successfully. Maybe try again later?"
exit 1
}
# Is 7Zip installed?
# Edit this to be Program Files (x86) if you installed the 32-bit version.
$7zip = 'C:\Program Files\7-Zip\7z.exe'
& $7zip >$null
if (-Not $?)
{
Write-Error "7Zip is required to decompress fnalibs."
exit 1
}
# Decompress
& $7zip x -y fnalibs.tar.bz2 >$null
& $7zip x -y fnalibs.tar -o* >$null
Remove-Item fnalibs.tar.bz2
Remove-Item fnalibs.tar
Write-Output "fnalibs extracted!"

118
win_getFNA.ps1 Normal file
View File

@ -0,0 +1,118 @@
# Program: win_getFNA
# Author: Caleb Cornett
# Usage: ./win_getFNA.ps1
# Description: Quick and easy way to install a local copy of FNA and its native libraries.
# NOTE: 7-Zip must be installed to decompress fnalibs.
# Checks if git is installed
function checkGit()
{
git --version > $null 2>&1
if ( -Not $? ) {
Write-Error "ERROR: Git is required to pull FNA from the command line."
Write-Output "Either install git or download and unzip FNA manually."
exit 1
}
}
# Clones FNA from the git master branch
function downloadFNA()
{
checkGit
Write-Output "Downloading FNA..."
git -C $PSScriptRoot clone https://github.com/FNA-XNA/FNA.git --recursive
if ($?) {
Write-Output "Finished downloading!"
}
else {
Write-Error "ERROR: Unable to download successfully. Maybe try again later?"
}
}
# Pulls FNA from the git master branch
function updateFNA()
{
checkGit
Write-Output "Updating to the latest git version of FNA..."
git -C $PSScriptRoot/FNA pull --recurse-submodules
if ($?) {
Write-Output "Finished updating!"
}
else {
Write-Error "ERROR: Unable to update."
}
}
function getLibs()
{
# Downloading
Write-Output "Downloading latest fnalibs..."
Invoke-WebRequest -Uri http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 -OutFile $PSScriptRoot/fnalibs.tar.bz2
if ($?) {
Write-Output "Finished downloading!"
}
else {
Write-Error "ERROR: Unable to download successfully. Maybe try again later?"
exit 1
}
# Is 7Zip installed?
# Edit this to be Program Files (x86) if you installed the 32-bit version.
$7zip = 'C:\Program Files\7-Zip\7z.exe'
& $7zip >$null
if (-Not $?)
{
Write-Error "7Zip is required to decompress fnalibs."
exit 1
}
# Decompress
& $7zip x -y $PSScriptRoot/fnalibs.tar.bz2 -o"$PSScriptRoot"
& $7zip x -y $PSScriptRoot/fnalibs.tar -o"$PSScriptRoot/fnalibs" >$null
if ($?)
{
Write-Output "Finished decompressing!"
Remove-Item $PSScriptRoot/fnalibs.tar.bz2
Remove-Item $PSScriptRoot/fnalibs.tar
}
else
{
Write-Error "ERROR: Unable to decompress successfully."
}
}
# FNA
if ( -Not (Test-Path -Path "$PSScriptRoot/FNA") )
{
$shouldDownload = Read-Host "Download FNA (y/n)? "
if ($shouldDownload -match "^[Yy]$")
{
downloadFNA
}
}
else
{
$shouldUpdate = Read-Host "Update FNA (y/n)? "
if ($shouldUpdate -match "^[Yy]$")
{
updateFNA
}
}
# FNALIBS
$shouldDownloadLibs = ""
if ( -Not (Test-Path -Path "$PSScriptRoot/fnalibs") )
{
$shouldDownloadLibs = Read-Host "Download fnalibs (y/n)? "
}
else
{
$shouldDownloadLibs = Read-Host "Redownload fnalibs (y/n)? "
}
if ($shouldDownloadLibs -match "^[Yy]$")
{
getLibs
}