Last active
September 7, 2018 07:17
-
-
Save bgold-cosmos/8f8ad2ca73d37a856f9c1f293eabad0b to your computer and use it in GitHub Desktop.
Tidal install script for MacOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
# -------------------------------------------- | |
# install-tidal.pl | |
# created by Ben Gold at 09:35 Sat Oct 28 2017 | |
# -------------------------------------------- | |
use strict; | |
my($url,$exists); | |
my(%pageURL) = ( | |
atom => "https://github.com/atom/atom/releases/latest", | |
haskell => "https://www.haskell.org/platform/mac.html", | |
supercollider => "https://github.com/supercollider/supercollider/releases/latest", | |
sc3plugins => "https://github.com/supercollider/sc3-plugins/releases/latest" | |
); | |
# xcode utils, needed for some later steps | |
$exists = `xcode-select -p 2>&1` !~ /error/; | |
if (not $exists) { | |
system("xcode-select --install") == 0 | |
or die "ERROR: could not install developer tools\n"; | |
print "Opening Xcode installer, click \"Install\", and when XCode tools\n"; | |
print "have finished come back here and press return to continue\n"; | |
getc; | |
} | |
# supercollider | |
# glob function is only Linux/Mac, this directory is Mac-specific | |
my($scconfig) = glob('~/Library/Application\ Support/SuperCollider'); | |
my($modify_scconfig) = 0; | |
$exists = -d $scconfig; | |
if (not $exists) { | |
$url = findURLinHTML("OSX.zip", $pageURL{supercollider}); | |
$url = "https://github.com" . $url; | |
print "Installing SuperCollider\n"; | |
print "Downloading $url\n"; | |
system("curl -LO $url") == 0 or die "ERROR: download failed for $url\n"; | |
system("unzip -q SuperCollider*.zip -d /Applications") == 0 | |
or die "ERROR: unzipping SuperCollider failed\n"; | |
} else { | |
print "SuperCollider found, skipping...\n"; | |
} | |
# sc3-plugins | |
my($scextdir) = $scconfig . '/Extensions'; | |
$exists = -d ($scextdir . "/SC3plugins"); | |
if (not $exists) { | |
$url = findURLinHTML("OSX", $pageURL{sc3plugins}); | |
$url = "https://github.com" . $url; | |
print "Installing sc3-plugins for SuperCollider\n"; | |
print "Downloading $url\n"; | |
system("curl -LO $url") == 0 or die "ERROR: download failed for $url\n"; | |
system("mkdir -p '$scextdir'"); | |
system("unzip -q sc3-plugins*.zip -d '$scextdir'") == 0 | |
or die "ERROR: unzipping sc3-plugins failed\n"; | |
} else { | |
print "sc3-plugins found, skipping...\n"; | |
} | |
# SuperDirt | |
my($scconfigfile) = $scconfig . "/sclang_conf.yaml"; | |
$exists = (-e $scconfigfile) && (`grep SuperDirt '$scconfigfile'` =~ /SuperDirt/); | |
if (not $exists) { | |
print "Installing SuperDirt\n"; | |
system("mkdir -p '$scconfig/downloaded-quarks'"); | |
system("git clone https://github.com/musikinformatik/SuperDirt '$scconfig/downloaded-quarks/SuperDirt'"); | |
$modify_scconfig = 1; | |
} else { | |
print "SuperDirt already installed, skipping...\n"; | |
} | |
# SuperDirt samples | |
$exists = (-e $scconfigfile) && (-d "$scconfig/downloaded-quarks/Dirt-Samples"); | |
if (not $exists) { | |
print "Installing SuperDirt samples\n"; | |
system("mkdir -p '$scconfig/downloaded-quarks'"); | |
system("git clone https://github.com/tidalcycles/Dirt-Samples '$scconfig/downloaded-quarks/Dirt-Samples'"); | |
} else { | |
print "SuperDirt samples already installed, skipping...\n"; | |
} | |
# vowel quark | |
$exists = (-e $scconfigfile) && (`grep Vowel '$scconfigfile'` =~ /Vowel/); | |
if (not $exists) { | |
print "Installing Vowel quark for SuperCollider\n"; | |
system("mkdir -p '$scconfig/downloaded-quarks'"); | |
system("git clone https://github.com/supercollider-quarks/Vowel '$scconfig/downloaded-quarks/Vowel'"); | |
$modify_scconfig = 1; | |
} else { | |
printf "Vowel quark already installed, skipping...\n"; | |
} | |
# edit sclang_conf.yaml by hand | |
$exists = -e $scconfigfile; | |
if (not $exists) { | |
open(OUT, ">", $scconfigfile) or die "Can't create $scconfigfile\n"; | |
print OUT | |
qq{includePaths: | |
- $scconfig/downloaded-quarks/Vowel | |
- $scconfig/downloaded-quarks/SuperDirt | |
excludePaths: | |
[] | |
postInlineWarnings: false}; | |
close OUT; | |
} elsif ($modify_scconfig) { | |
print "Adding new quarks to your $scconfigfile\n"; | |
system("cp '$scconfigfile' '$scconfigfile.bak'") == 0 | |
or die "ERROR: unable to back up $scconfigfile, stopping now to be cautious\n"; | |
my(@lines) = `cat '$scconfigfile'`; | |
my($addvowel) = `grep Vowel '$scconfigfile'` !~ /Vowel/; | |
my($addsd) = `grep SuperDirt '$scconfigfile'` !~ /SuperDirt/; | |
my($i); | |
open(OUT, ">", $scconfigfile) or die "Can't edit $scconfigfile\n"; | |
print OUT $lines[0]; | |
print OUT " - $scconfig/downloaded-quarks/Vowel\n" if $addvowel; | |
print OUT " - $scconfig/downloaded-quarks/SuperDirt\n" if $addsd; | |
for $i (1..$#lines) { | |
print OUT $lines[$i]; | |
} | |
close OUT; | |
} | |
# atom | |
$exists = (`which atom` =~ /atom/) | |
|| (-d glob('~/Library/Application\ Support/Atom')); | |
if (not $exists) { | |
$url = findURLinHTML("atom-mac.zip", $pageURL{atom}); | |
$url = "https://github.com" . $url; | |
print "Installing Atom\n"; | |
print "Downloading $url\n"; | |
system("curl -LO $url") == 0 or die "ERROR: download failed for $url\n"; | |
system("unzip -q atom-mac.zip -d /Applications") == 0 | |
or die "ERROR: unzipping Atom failed\n"; | |
} else { | |
print "Atom already installed, skipping...\n"; | |
} | |
# atom-tidalcycles | |
# If you already have Atom installed but not in /Applications, this may | |
# fail and leave the atom tidalcycles package uninstalled. You can install | |
# it from within Atom using the interface there. | |
my($apm); | |
chomp($apm = `which apm`); | |
$apm = | |
"/Applications/Atom.app/Contents/Resources/app/apm/node_modules/.bin/apm" | |
unless $apm =~ /apm/; | |
print "Checking atom tidalcycles package\n"; | |
$exists = `$apm list` =~ /tidalcycles/; | |
`$apm install tidalcycles` unless $exists; | |
print "Atom tidalcycles package already installed\n" if $exists; | |
# haskell platform | |
$exists = `which ghci` =~ /ghci/; | |
if (not $exists) { | |
$url = findURLinHTML("Full", $pageURL{haskell}); | |
$url = "https:" . $url; | |
print "Installing Haskell Platform\n"; | |
print "Downloading $url\n"; | |
system("curl -LO $url") == 0 or die "ERROR: download failed for $url\n"; | |
print "Starting Haskell Platform installer\n"; | |
print "We'll continue the installation automatically when it is done\n"; | |
system("open -W Haskell*.pkg") == 0 | |
or die "ERROR: could not open Haskell package\n"; | |
} else { | |
print "GHCi found, skipping...\n"; | |
} | |
# cabal and tidal | |
$exists = `which cabal` =~ /cabal/; | |
if (not $exists) { | |
die "ERROR: ghci installed but cabal not found, I don't know how this could have happened\n"; | |
} else { | |
my($cfile) = "~/.cabal/packages/hackage.haskell.org/00-index.cache"; | |
if (-e glob($cfile) and (-M glob($cfile) < 7)) { | |
print "cabal package list is up-to-date\n"; | |
} else { | |
system("cabal update") == 0 or die "ERROR: cabal update failed\n"; | |
} | |
print "Installing Tidal\n"; | |
print "This will print a lot of output and may take a little while,\n"; | |
print "but thanks for being patient, we're almost done...\n"; | |
system("cabal install tidal") == 0 or die "ERROR: cabal could not install tidal\n"; | |
} | |
# clean up | |
print "Cleaning up...\n"; | |
system("rm -f *.zip *.pkg"); | |
print "Installation complete!\n"; | |
### END | |
sub findURLinHTML { | |
my($find, $page) = @_; | |
@_ = `curl -sL $page`; | |
foreach $_ (@_) { | |
if (/$find/) { | |
/href="(.*?)"/; | |
return $1; | |
} | |
} | |
die "ERROR: Could not find URL with $find in $page\n"; | |
return ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment