mirror of
https://github.com/actraiser/dustlayer.git
synced 2025-06-18 17:05:47 -04:00
308 lines
12 KiB
JavaScript
308 lines
12 KiB
JavaScript
#!/usr/bin/env node
|
|
var dust = require('../../../bin/dust');
|
|
var savePWD = process.env['HOME'];
|
|
|
|
dust.setup.clone = {
|
|
"mac": function(){
|
|
cloneMac();
|
|
}
|
|
}
|
|
|
|
|
|
dust.setup.install = {
|
|
"mac": {
|
|
"options": function(){
|
|
showOptionsMac();
|
|
},
|
|
"run": function(){
|
|
runInstallMac();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/* installation start */
|
|
function runInstallMac(configKey){
|
|
var start = new Date().getTime();
|
|
|
|
// github location of a package of software prebundled for this mod
|
|
preBundleUrl = dust.config.mod.setup.mac.preBundleUrl;
|
|
// list of software prebundled
|
|
preBundleList = dust.config.mod.setup.mac.preBundleList;
|
|
// list of software downloaded from external sites
|
|
externalsList = dust.config.mod.setup.mac.externals;
|
|
|
|
// selected installation configuration (includes prebundled and external software)
|
|
selectedInstallOptions = dust.config.mod.setup.mac.installOptions[configKey].list;
|
|
|
|
// Create Temp Directory to work in
|
|
dust.shell.exec('mkdir "$HOME/temp_dust_compile"', {silent:dust.silent});
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile", {silent:dust.silent});
|
|
regex = /.*\/(.*).git$/
|
|
preBundleDirectory = regex.exec(preBundleUrl)[1];
|
|
|
|
// rm existing clone
|
|
dust.shell.rm('-rf', preBundleDirectory);
|
|
// clone repository
|
|
dust.shell.exec('git clone --progress ' + preBundleUrl);
|
|
|
|
if (dust.shell.test('-d', dust.shell.env['HOME'] + "/temp_dust_compile/" + preBundleDirectory) === false){
|
|
dust.test.fail("git clone failed - did you enter your password correctly?");
|
|
console.log("");
|
|
dust.shell.exit(1);
|
|
}
|
|
|
|
dust.shell.cd(preBundleDirectory);
|
|
dust.shell.rm('-rf', '.git');
|
|
|
|
dust.color.bold();
|
|
console.log("");
|
|
console.log("Enter Sudo password if required to create system directories and copy binaries.");
|
|
console.log("");
|
|
dust.color.reset();
|
|
|
|
|
|
// all binaries go to /usr/local/bin - create if it does not exist
|
|
dust.shell.exec('sudo mkdir -p "/usr/local/bin"', {silent:dust.silent});
|
|
|
|
// install prebundled Software
|
|
for (var key in selectedInstallOptions){
|
|
if (selectedInstallOptions[key] === true){
|
|
// check if this is a prebundled or external software
|
|
if (dust.config.mod.setup.mac.preBundleList[key] != undefined){
|
|
eval(preBundleList[key]['installer'] + "('" + preBundleList[key]['directory'] + "','" + preBundleDirectory + "');");
|
|
}
|
|
else if (dust.config.mod.setup.mac.externals[key] != undefined){
|
|
eval(externalsList[key]['installer'] + "('" + externalsList[key]['filename'] + "');");
|
|
if (externalsList[key]['postinstaller'] != undefined) {
|
|
eval(externalsList[key]['postinstaller'] + "('" + externalsList[key]['directory'] + "','" + preBundleDirectory + "');");
|
|
}
|
|
}
|
|
else{
|
|
dust.test.fail("Error: " + key + " not found in the configuration file.");
|
|
}
|
|
}
|
|
else {
|
|
console.log('skipping ' + key + ' installation');
|
|
}
|
|
}
|
|
|
|
dust.setup.removeTemporaryDirectory();
|
|
|
|
dust.text.displayOutroText();
|
|
var end = new Date().getTime();
|
|
var time = end - start;
|
|
console.log("");
|
|
dust.color.bold();
|
|
console.log('Execution time: ' + parseInt(time/1000) + ' seconds');
|
|
dust.color.reset();
|
|
console.log("");
|
|
dust.shell.exit(0)
|
|
}
|
|
|
|
|
|
function showOptionsMac(){
|
|
combinations = eval("dust.config.mod.setup." + dust.env.operatingSystem.toLowerCase() + ".installOptions");
|
|
options = [];
|
|
i=1;
|
|
dust.color.bold();
|
|
for (var key in combinations) {
|
|
options[i] = [];
|
|
options[i]['key'] = key;
|
|
options[i]['description'] = combinations[key]['description'];
|
|
console.log(i+". " + options[i]['description']);
|
|
i++;
|
|
}
|
|
|
|
dust.cmd.prompt('Choice: ', function(choice){
|
|
choice = parseInt(choice);
|
|
|
|
if (choice>i || choice < 1 || isNaN(choice) ){
|
|
dust.test.fail('Choice out of range - please retry');
|
|
console.log("");
|
|
showOptionsMac();
|
|
return;
|
|
}
|
|
console.log('You have chosen option #%d "%s"', choice, options[choice]['description']);
|
|
dust.color.reset();
|
|
runInstallMac(options[choice]['key']);
|
|
});
|
|
|
|
}
|
|
|
|
function installAcme(workdir,bundledir){
|
|
process.stdout.write('installing acme ');
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile/" + bundledir, {silent:dust.silent});
|
|
dust.shell.cd(workdir);
|
|
dust.shell.exec('make', {silent:dust.silent});
|
|
dust.shell.exec('sudo make install', {silent:dust.silent});
|
|
dust.setup.installStatus(true);
|
|
}
|
|
|
|
function installExomizer(workdir,bundledir){
|
|
process.stdout.write('installing Exomizer ');
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile/" + bundledir, {silent:dust.silent});
|
|
dust.shell.cd(workdir);
|
|
dust.shell.exec('make', {silent:dust.silent});
|
|
dust.shell.exec('sudo cp "exobasic" "/usr/local/bin"', {silent:dust.silent});
|
|
dust.shell.exec('sudo cp "exomizer" "/usr/local/bin"', {silent:dust.silent});
|
|
dust.setup.installStatus(true);
|
|
}
|
|
|
|
function installPuCrunch(workdir,bundledir){
|
|
process.stdout.write('installing PuCrunch ');
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile/" + bundledir, {silent:dust.silent});
|
|
dust.shell.cd(workdir);
|
|
dust.shell.exec('make', {silent:dust.silent});
|
|
dust.shell.exec('sudo cp "pucrunch" "/usr/local/bin"', {silent:dust.silent});
|
|
dust.setup.installStatus(true);
|
|
}
|
|
|
|
function installSidreloc(workdir,bundledir){
|
|
process.stdout.write('installing Sidreloc ');
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile/" + bundledir, {silent:dust.silent});
|
|
dust.shell.cd(workdir);
|
|
dust.shell.exec('make', {silent:dust.silent});
|
|
dust.shell.exec('sudo make install', {silent:dust.silent});
|
|
dust.setup.installStatus(true);
|
|
}
|
|
|
|
function installCompileScripts(workdir,bundledir){
|
|
process.stdout.write('installing Sidreloc ');
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile/" + bundledir, {silent:dust.silent});
|
|
dust.shell.cd(workdir);
|
|
process.stdout.write('installing build scripts for 6502 and BASIC ');
|
|
dust.shell.exec('sudo cp -v "$PWD/scripts/assemble_6502" "/usr/local/bin"', {silent:dust.silent});
|
|
dust.shell.exec('sudo cp -v "$PWD/scripts/tokenize_basic" "/usr/local/bin"', {silent:dust.silent});
|
|
dust.setup.installStatus(true);
|
|
}
|
|
|
|
function installSublimeText(filename){
|
|
process.stdout.write('installing Sublime Text 2 ');
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile/", {silent:dust.silent});
|
|
dust.externals.download('mac', dust.config.mod.setup.mac.externals.sublime.downloads[0], filename,true);
|
|
process.stdout.write('installing ');
|
|
|
|
dust.shell.exec('hdiutil attach "$HOME/temp_dust_compile/' + filename +'"', {silent:dust.silent});
|
|
dust.shell.exec('cp -R -v "/Volumes/Sublime Text 2/Sublime Text 2.app" "/Volumes/Sublime Text 2/Applications"', {silent:dust.silent});
|
|
dust.shell.exec('hdiutil detach "/Volumes/Sublime Text 2"', {silent:dust.silent});
|
|
dust.setup.installStatus(true);
|
|
}
|
|
|
|
function postInstallSublimeText(workdir,bundledir){
|
|
process.stdout.write("Copying Sublime Text 2 Configuration ");
|
|
if (dust.shell.test("-d", "/Applications/Sublime Text 2.app")){
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile/" + bundledir, {silent:dust.silent});
|
|
dust.shell.cd(workdir);
|
|
dust.shell.exec('sudo mv -v "Sublime Text 2/sublime" "/usr/local/bin"', {silent:dust.silent});
|
|
dust.shell.exec('mkdir -p "$HOME/Library/Application Support/Sublime Text 2/Packages"', {silent:dust.silent});
|
|
dust.shell.exec('cp -R -v "Sublime Text 2/" "$HOME/Library/Application Support/Sublime Text 2/Packages"', {silent:dust.silent});
|
|
dust.setup.installStatus(true);
|
|
}
|
|
else {
|
|
dust.color.yellow();
|
|
console.log("sublime not available - no build systems were configured");
|
|
dust.color.reset();
|
|
}
|
|
}
|
|
|
|
function installVice(filename){
|
|
process.stdout.write('installing Vice ');
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile/", {silent:dust.silent});
|
|
|
|
dust.externals.download('mac', dust.config.mod.setup.mac.externals.vice.downloads[0], filename,true);
|
|
process.stdout.write('installing ');
|
|
|
|
dust.shell.exec('mkdir /Applications/Vice64', {silent:dust.silent});
|
|
dust.shell.exec('hdiutil attach "$HOME/temp_dust_compile/vice-macosx-cocoa-i386+x86_64-10.6-gcc42-2.4.dmg"', {silent:dust.silent});
|
|
dust.shell.exec('cp -R -v "/Volumes/vice-macosx-cocoa-i386+x86_64-10.6-gcc42-2.4/" "/Applications/Vice64"', {silent:dust.silent});
|
|
dust.shell.exec('hdiutil detach "/Volumes/vice-macosx-cocoa-i386+x86_64-10.6-gcc42-2.4"', {silent:dust.silent});
|
|
dust.shell.exec('sudo cp -v "/Applications/Vice64/tools/petcat" "/usr/local/bin"', {silent:dust.silent});
|
|
|
|
dust.setup.installStatus(true);
|
|
}
|
|
|
|
function installWineBottler(filename){
|
|
process.stdout.write('installing Winebottler ');
|
|
dust.externals.download('mac', dust.config.mod.setup.mac.externals.winebottler.downloads[0], filename,true);
|
|
process.stdout.write('installing ');
|
|
|
|
dust.shell.exec('hdiutil attach -nobrowse "$HOME/temp_dust_compile/WineBottlerCombo_1.2.5.dmg"', {silent:dust.silent});
|
|
dust.shell.exec('cp -R -v "/Volumes/WineBottler Combo/Wine.app" "/Volumes/WineBottler Combo/Applications"', {silent:dust.silent});
|
|
dust.shell.exec('cp -R -v "/Volumes/WineBottler Combo/WineBottler.app" "/Volumes/WineBottler Combo/Applications"', {silent:dust.silent});
|
|
dust.shell.exec('hdiutil detach "/Volumes/WineBottler Combo"', {silent:dust.silent});
|
|
dust.setup.installStatus(true);
|
|
}
|
|
|
|
|
|
function sleeper(seconds){
|
|
dust.shell.exec('sleep ' + seconds);
|
|
process.stdout.write(".");
|
|
}
|
|
|
|
|
|
function postInstallWineBottler(workdir,bundledir){
|
|
|
|
if (dust.shell.test("-d", dust.shell.env['HOME'] + "/Wine Files/drive_c/Program Files") === false){
|
|
dust.color.bold();
|
|
dust.color.red();
|
|
console.log("");
|
|
console.log("We will need to open a Win32 App briefly to auto-configure wine.");
|
|
console.log("You can close the application when it finished loading.");
|
|
console.log("'dust' setup will finish automatically.");
|
|
dust.color.reset();
|
|
|
|
dust.shell.cd(dust.shell.env['HOME'] + "/temp_dust_compile/" + bundledir, {silent:dust.silent});
|
|
dust.shell.cd(workdir);
|
|
dust.shell.exec("open 'SpritePad 1.8/SpritePad.exe'");
|
|
|
|
waitForDirectory();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
function waitForDirectory(){
|
|
if (dust.shell.test("-d", dust.shell.env['HOME'] + "/Wine Files/drive_c/Program Files") === true){
|
|
console.log("Wine has created required directories")
|
|
//dust.shell.exec("sudo kill $(ps aux | grep 'X11' | awk '{print $2}')")
|
|
process.stdout.write("Copying Win32 programs ");
|
|
dust.shell.exec('cp -R -v "." "$HOME/Wine Files/drive_c/Program Files"', {silent:dust.silent});
|
|
dust.shell.exec('ln -s "$HOME/Wine Files/drive_c/Program Files" "$HOME/Desktop/Win32 Apps"', {silent:dust.silent});
|
|
dust.setup.installStatus(true);
|
|
}
|
|
else{
|
|
sleeper(1);
|
|
waitForDirectory();
|
|
|
|
}
|
|
}
|
|
|
|
function cloneMac(){
|
|
console.log ("");
|
|
console.log("Cloning Repository - this may take a while.");
|
|
console.log ("");
|
|
|
|
if (dust.shell.exec('which git').code !== 0){
|
|
dust.color.red();
|
|
dust.color.bold();
|
|
console.log('git command not found - have you installed git?');
|
|
console.log('download it at http://git-scm.com/downloads')
|
|
console.log("More information on setup requirements with 'dust setup requirements")
|
|
dust.color.reset();
|
|
dust.shell.exit(0);
|
|
}
|
|
|
|
|
|
if (dust.shell.exec('git clone --verbose https://github.com/actraiser/dust-setup-osx.git').code === 0) {
|
|
dust.color.green();
|
|
console.log('Cloning Repository succeeded');
|
|
console.log("Change to 'dust-setup-osx' directory and run 'dust setup'");
|
|
dust.color.reset();
|
|
dust.shell.exit(1);
|
|
} else {
|
|
console.log("there was a problem cloning the repository - please try to clone again!");
|
|
dust.shell.exit(1);
|
|
}
|
|
}
|