Skip to content

cleanup and add launcher script to get a signed vm #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
189 changes: 189 additions & 0 deletions generated/signedVm90
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
#!/usr/bin/env bash
#<html><head><!--
# The line above makes a fake HTML document out of this bash script

#This zero conf script was generated from the sources found in:
# https://github.com/pharo-project/pharo-zeroconf

# stop the script if a single command fails
set -e

# define an echo that only outputs to stderr
echoerr() { echo "$@" 1>&2; }
# try to use curl if possible
if [[ `which curl 2> /dev/null` ]]; then
DOWNLOAD="curl --silent --location --compressed ";
DOWNLOAD_TO="$DOWNLOAD --output ";
elif [[ `which wget 2> /dev/null` ]]; then
DOWNLOAD_TO="wget --quiet --output-document=";
DOWNLOAD="$DOWNLOAD_TO-";
else
echo "Please install curl or wget on your machine";
exit 1
fi




# ARGUMENT HANDLING =============================================================
if { [ "$1" = "-h" ] || [ "$1" = "--help" ]; }; then
echo "This script downloads the stable Pharosigned VM for 90.
The following artifacts are created:
pharo Script to run the downloaded VM in headless mode
pharo-ui Script to run the downloaded VM in UI mode
pharo-vm/ Directory containing the VM
"
exit 0;
elif [ $# -gt 0 ]; then
echo "--help is the only argument allowed"
exit 1;
fi


# RELEASE VERSION ===============================================================
VERSION="90"
FILES_URL="http://files.pharo.org/get-files/${VERSION}"


# VM PROPERTIES =================================================================
VM_TYPE="pharo"
VM_BINARY_NAME="Pharo"
VM_BINARY_NAME_LINUX="pharo"
VM_BINARY_NAME_WINDOWS="PharoConsole"
VM_STATUS="stable"


# DETECT SYSTEM PROPERTIES ======================================================
ARCH=`uname -m`
VM_ARCH=${ARCH}
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) OSNAME=Linux;;
Darwin*) OSNAME=Darwin;;
CYGWIN*) OSNAME=Windows;;
MINGW*) OSNAME=Windows;;
*) OSNAME="UNKNOWN:${unameOut}"
esac


# DOWNLOAD signed (if available) 90 VM ==========================================
if [ "$OS" == "win" ]; then
VM_URL="${FILES_URL}/${VM_TYPE}-vm-${OSNAME}-${VM_ARCH}-${VM_STATUS}-signed.zip"
else
VM_URL="${FILES_URL}/${VM_TYPE}-vm-${OSNAME}-${VM_ARCH}-${VM_STATUS}.zip"
fi
VM_DIR="pharo-vm"

echoerr "Downloading ${VM_TYPE}VM:"
echoerr " $VM_URL"

mkdir -p $VM_DIR
$DOWNLOAD_TO$VM_DIR/vm.zip $VM_URL

unzip -q $VM_DIR/vm.zip -d $VM_DIR
rm -rf $VM_DIR/vm.zip

if [ "$OS" == "win" ]; then
PHARO_VM=`find $VM_DIR -name ${VM_BINARY_NAME_WINDOWS}.exe`
elif [ "$OS" == "mac" ]; then
PHARO_VM=`find $VM_DIR -name ${VM_BINARY_NAME}`
elif [ "$OS" == "linux" ]; then
PHARO_VM=`ls $VM_DIR/${VM_BINARY_NAME_LINUX}`
fi

echo $PHARO_VM




# CREATE THE VM LAUNCHER SCRIPTS ================================================
create_vm_script() {
VM_SCRIPT=$1

echo "#!/usr/bin/env bash" > $VM_SCRIPT
echo '# some magic to find out the real location of this script dealing with symlinks
DIR=`readlink "$0"` || DIR="$0";
DIR=`dirname "$DIR"`;
cd "$DIR"
DIR=`pwd`
cd - > /dev/null
# disable parameter expansion to forward all arguments unprocessed to the VM
set -f
# run the VM and pass along all arguments as is' >> $VM_SCRIPT

# make sure we only substite $PHARO_VM but put "$DIR" in the script
echo -n \"\$DIR\"/\"$PHARO_VM\" >> $VM_SCRIPT

# only output the headless option if the VM_SCRIPT name does not include "ui"
if [[ "{$VM_SCRIPT}" != *ui* ]]; then
# output the headless option, which varies under each platform
if [ "$OS" == "linux" ]; then
echo -n " --nodisplay " >> $VM_SCRIPT
else
echo -n " --headless" >> $VM_SCRIPT
fi
fi

# forward all arguments unprocessed using $@
echo " \"\$@\"" >> $VM_SCRIPT

# make the script executable
chmod +x $VM_SCRIPT
}

echoerr "Creating starter scripts pharo and pharo-ui"
create_vm_script "pharo"
create_vm_script "pharo-ui"


# TEST VM REQUIREMENTS UNDER LINUX ==============================================
if [ "$OS" == "linux" ]; then
$PHARO_VM --help --vm-display-null &> /dev/null 2>&1 || (\
echo "On a 64-bit system? You must enable and install the 32-bit libraries"; \
echo " Please see http://pharo.org/gnu-linux-installation for detailed instructions" )
fi


# HTML HELP =====================================================================
HTML_HELP=<<HTML_HELP
-->
<title>Pharo Zeroconf Script</title>
<style>
BODY, TABLE {
font-family: Arial;
line-height: 1.5em;
}
BODY {
background-color: white;
margin-top: -1.5em;
}
TD {
vertical-align: top;
padding: 0 1ex 0 0;
}
PRE, CODE {
background-color: #EEE;
padding: 0.5ex 0.8ex;
border-radius: 0.5ex;
}
A {
color: black;
}
</style>
<body>
<h1>Pharo Zeroconf Script</h1>
<p>This script downloads the stable Pharosigned VM for 90.</p>
<h2>Usage</h2>
<code>curl <a href="https://get.pharo.org/signedVm90">https://get.pharo.org/signedVm90</a> | bash </code>
<br/>
or if <code>curl</code> is not available: </br>
<code>wget -O- <a href="https://get.pharo.org/signedVm90">https://get.pharo.org/signedVm90</a> | bash </code>

<h2>Artifacts</h2>
<table><tr><td>pharo</td><td>Script to run the downloaded VM in headless mode</td></tr>
<tr><td>pharo-ui</td><td>Script to run the downloaded VM in UI mode</td></tr>
<tr><td>pharo-vm/</td><td>Directory containing the VM</td></tr></table>

<!--
HTML_HELP
# --!></body></html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ generateBody
generateDetectSystemProperties; cr; cr;
generateDownloadVm; cr; cr;
generateDownloadSources; cr; cr;
generateVmScriptCreator; cr; cr;
generateLinuxScriptTest
generateVmScriptCreator
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@ generateDownloadVm
VM_DIR="' << self vmDirectoryPathString << '"

echoerr "Downloading the latest ${VM_TYPE}VM:"
echoerr " $VM_URL"
echoerr " $VM_URL"'; cr.

mkdir -p $VM_DIR
$DOWNLOAD_TO$VM_DIR/vm.zip $VM_URL

unzip -oq $VM_DIR/vm.zip -d $VM_DIR
rm -rf $VM_DIR/vm.zip

if [ "$OSNAME" == "Windows" ]; then
PHARO_VM=`find $VM_DIR -name ${VM_BINARY_NAME_WINDOWS}.exe`
elif [ "$OSNAME" == "Darwin" ]; then
PHARO_VM=`find $VM_DIR -name ${VM_BINARY_NAME}`
elif [ "$OSNAME" == "Linux" ]; then
PHARO_VM=`ls $VM_DIR/${VM_BINARY_NAME_LINUX}`
fi

echo $PHARO_VM'; cr
self generateDownloadVmInstructions
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
as yet unclassified
generateDownloadVmInstructions
self
<< '
mkdir -p $VM_DIR
$DOWNLOAD_TO$VM_DIR/vm.zip $VM_URL

unzip -q $VM_DIR/vm.zip -d $VM_DIR
rm -rf $VM_DIR/vm.zip

if [ "$OSNAME" == "Windows" ]; then
PHARO_VM=`find $VM_DIR -name ${VM_BINARY_NAME_WINDOWS}.exe`
elif [ "$OSNAME" == "Darwin" ]; then
PHARO_VM=`find $VM_DIR -name ${VM_BINARY_NAME}`
elif [ "$OSNAME" == "Linux" ]; then
PHARO_VM=`ls $VM_DIR/${VM_BINARY_NAME_LINUX}`
fi

echo $PHARO_VM'; cr

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ set -f

# only output the headless option if the VM_SCRIPT name does not include "ui"
if [[ "\{$VM_SCRIPT}" != *ui* ]]; then
# output the headless option, which varies under each platform
if [ "$OS" == "linux" ]; then
echo -n " {1}nodisplay " >> $VM_SCRIPT
else
echo -n " {1}headless" >> $VM_SCRIPT
fi
echo -n " {1}headless" >> $VM_SCRIPT
fi

# forward all arguments unprocessed using $@
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
I'm there temporary to be able to fetch a signed VM on Windows (used by Pharo Launcher).
for example:
get-files/{version}/pharo-stable.zip
get-files/{version}/pharo-stable-signed.zip

Generate bash scripts:
dir := FileLocator temp asFileReference.
ZeroConfVMVersionPharoLauncherScript pharoLauncher61
directory: dir;
be64bits;
generate.
ZeroConfVMVersionPharoLauncherScript pharoLauncher61
directory: dir;
generate.
dir
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
private
basenameVM
^ 'signedVm'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
pharoLauncher61
^ self type: 'pharo' release: '61' status: #stable
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
pharoLauncher70
^ self type: 'pharo' release: '70' status: #stable
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
pharoLauncher80
^ self type: 'pharo' release: '80' status: #stable
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
instance creation
pharoLauncher90
^ self stablePharo: '90'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
testing
worksWithVersion: version
^ { 61 . 70 . 80 } includes: version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
description
^ 'This script downloads the ', self status, ' ', self type capitalized, 'signed VM for ', self release, '.'
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
script generation
generateDownloadVm
self
<<== ('DOWNLOAD signed (if available) {2} VM' format: { self type asUppercase. self release })
<< 'if [ "$OSNAME" == "Windows" ]; then'; cr;
<< (' VM_URL="{1}"' format: { self winVmUrl }); cr;
<< 'else'; cr;
<< (' VM_URL="{1}"' format: { self vmUrl }); cr;
<< 'fi'; cr;
<< ('VM_DIR="{1}"' format: { self vmDirectoryPathString }); cr;
<< '
echoerr "Downloading ${VM_TYPE}VM:"
echoerr " $VM_URL"'; cr.

self generateDownloadVmInstructions
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
winVmUrl
^'${FILES_URL}/${VM_TYPE}-vm-${OSNAME}-${VM_ARCH}-${VM_STATUS}-signed.zip'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"commentStamp" : "ChristopheDemarey 12/17/2018 21:12",
"super" : "ZeroConfVMVersionScript",
"category" : "ZeroConf-Unity",
"classinstvars" : [ ],
"pools" : [ ],
"classvars" : [ ],
"instvars" : [ ],
"name" : "ZeroConfVMVersionPharoLauncherScript",
"type" : "normal"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@ generateDownloadVm
<< ('VM_DIR="{1}"' format: { self vmDirectoryPathString }); cr;
<< '
echoerr "Downloading the latest ${VM_TYPE}VM:"
echoerr " $VM_URL"
echoerr " $VM_URL"'; cr.

mkdir -p $VM_DIR
$DOWNLOAD_TO$VM_DIR/vm.zip $VM_URL

unzip -q $VM_DIR/vm.zip -d $VM_DIR
rm -rf $VM_DIR/vm.zip

if [ "$OSNAME" == "Windows" ]; then
PHARO_VM=`find $VM_DIR -name ${VM_BINARY_NAME_WINDOWS}.exe`
elif [ "$OSNAME" == "Darwin" ]; then
PHARO_VM=`find $VM_DIR -name ${VM_BINARY_NAME}`
elif [ "$OSNAME" == "Linux" ]; then
PHARO_VM=`ls $VM_DIR/${VM_BINARY_NAME_LINUX}`
fi

echo $PHARO_VM'; cr
self generateDownloadVmInstructions