Last active
September 28, 2016 04:05
-
-
Save dockimbel/22d3c007fffab0e3388d to your computer and use it in GitHub Desktop.
Red-Updater-Script: This Script updates your Red Installation with the latest master-branch binaries.
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
Rebol [ | |
Title: "Red-Updater-Script" | |
File: %red-updater.r | |
Author: "Neelesh Chandola, @nc-x" | |
Description: { | |
This Script updates your Red Installation with the latest master-branch binaries. | |
} | |
Instructions: { | |
Please update the variable `path-to-red-executable` with appropriate | |
location of the Red executable on your system before running the script. | |
Then, | |
In Rebol 2 console type `do %red-updater.r` | |
OR | |
In System Console (Command Prompt on Windows, xyz terminal on Linux and OSX) type, `rebol2-executable-name red-updater.r` | |
} | |
] | |
; @PeterWAWood, http://www.rebol.org/view-script.r?script=environ.r | |
; ========================================================================= | |
environ: make object! [ | |
os?: func [{returns the operating system in the form of a string: | |
"win32", "mac", "linux", 'bsd", "netbsd", "openbsd", "solaris", | |
"hp-ux", "wince", "aix", "other"} | |
][ | |
switch/default system/version/4 | |
[ | |
2 [either 4 = system/version/5 | |
["mac"] | |
["other"] | |
] | |
3 [either 1 = system/version/5 | |
["win32"] | |
["other"] | |
] | |
4 ["linux"] | |
6 ["bsd"] | |
7 ["freebsd"] | |
8 ["netbsd"] | |
9 ["openbsd"] | |
10 ["solaris"] | |
12 ["hp-ux"] | |
15 [either find [1 2 3 5 6] system/version/5 | |
["wince"] | |
["other"] | |
] | |
17 ["aix"] | |
][ | |
"other" | |
] | |
] | |
linux?: func [{returns true when run under a Linux os}][ | |
os? = "linux" | |
] | |
osx?: func [{returns true when run under a OSX}][ | |
os? = "mac" | |
] | |
win?: func [{returns true when run under a Windows os}][ | |
to-logic find ["win32" "wince"] os? | |
] | |
] | |
; ========================================================================= | |
print [ | |
"Red Updater Script^/" | |
"==================^/" | |
"This Script updates your Red Installation with the latest master-branch binaries.^/^/" | |
] | |
site: http://static.red-lang.org/download.html | |
path-to-red-executable: %/c/red/red-latest ; %/path/to/folder/filename-without-extension | |
if environ/win? [append path-to-red-executable ".exe"] | |
update-required?: does [ | |
(modified? site) > modified? path-to-red-executable | |
] | |
get-download-links: does [ | |
site-contents: read site | |
download-link: http://static.red-lang.org/dl/auto | |
required-list-of-links: make block! 10 | |
parse site-contents [some [thru {<td class="midcol"><a href="dl/auto} copy temp-link to {">} | |
( append required-list-of-links temp-link ) | |
]] | |
get-appropriate-link-based-on-os | |
] | |
get-appropriate-link-based-on-os: does [ | |
prin "Detected Operating System: " | |
if environ/win? [ | |
print "Windows" | |
download-link: join download-link required-list-of-links/1 | |
] | |
if environ/linux? [ | |
print "Linux" | |
download-link: join download-link required-list-of-links/2 | |
] | |
if environ/osx? [ | |
print "OSX" | |
download-link: join download-link required-list-of-links/3 | |
] | |
] | |
either exists? path-to-red-executable [ | |
either update-required? [ | |
print "Update Required. Downloading Now..." | |
get-download-links | |
write/binary path-to-red-executable read/binary download-link | |
print "Updated." | |
] [ | |
print "No update required." | |
] | |
] [ | |
print "Red Executable Not Found. Downloading latest master-branch binaries." | |
get-download-links | |
write/binary path-to-red-executable read/binary download-link | |
print "Installed to the specified location." | |
print "If this is the first time you have installed Red Programming Language, please check http://www.red-lang.org/ for instructions on how to use it." | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment