Sage Virtual Appliance buildscript / build-sage.sh

#!/bin/sh


# Start and install virtualbox guest additions
VBoxManage startvm $UUID --type $INTERFACE
if [ $? -ne 0 ]; then
   echo "Failed to start virtual machine!"
   exit 1
fi
STATUS="booting"
while [ "$STATUS" != "ready" ]; do
    echo "Waiting for VM to start."
    sleep 10
    STATUS=`ssh -oNoHostAuthenticationForLocalhost=yes -p2222 root@localhost echo "ready"`
done


scp -oNoHostAuthenticationForLocalhost=yes -P2222 \
    "$SRCDIR/sage-$VERSION.tar" root@localhost:/home/sage/sage-source.tar

scp -oNoHostAuthenticationForLocalhost=yes -P2222 \
    "$SCRIPTSDIR"/systemd-run-sage.service root@localhost:/lib/systemd/system/sage@.service

scp -oNoHostAuthenticationForLocalhost=yes -P2222 \
    "$SCRIPTSDIR"/sage-bash-profile root@localhost:/home/sage/.bash_profile

scp -oNoHostAuthenticationForLocalhost=yes -P2222 \
    "$SCRIPTSDIR"/sage-xinitrc root@localhost:/home/sage/.xinitrc

ssh -oNoHostAuthenticationForLocalhost=yes -p2222 root@localhost -T <<EOF | tee  "$DATADIR"/install.log
  cd /etc/systemd/system/getty.target.wants
  ln -sf /lib/systemd/system/sage@.service getty@tty8.service
  chown -R sage.sage /home/sage/

  su sage
  cd
  tar xf sage-source.tar
  rm -f sage-source.tar
  ln -s sage* sage
  cd sage
  # export SAGE_PARALLEL_SPKG_BUILD=yes
  # export SAGE_ATLAS_ARCH=fast
  export SAGE_ATLAS_LIB=/usr/lib/atlas
  export SAGE_FAT_BINARY="yes"
  export MAKE='make -j2'
  make
  make test
  ./sage <<EOFSAGE
    from sage.misc.misc import DOT_SAGE
    directory = DOT_SAGE+'sage_notebook'
    nb = sagenb.notebook.notebook.load_notebook(directory)
    nb.user_manager().add_user('admin', 'sage', '', force=True)
    nb.save()
    quit
EOFSAGE
EOF

RC=`grep "Error building Sage" "$DATADIR"/install.log` 
if [ "$RC" != "" ]; then
   echo "Error building Sage!"
   VBoxManage unregistervm $UUID --delete
   exit 1
fi

sleep 5
ssh -oNoHostAuthenticationForLocalhost=yes -p2222 root@localhost -T <<EOF
  dd if=/dev/zero of=/zerofile ; rm -f /zerofile
  shutdown -h now
EOF


echo "Waiting for the guest addition installation to finish..."
STATUS="State:           running"
while [ "$STATUS" != "" ]; do
    STATUS=`VBoxManage showvminfo $UUID | grep 'State:.*running'`
    date
    sleep 20
done
if [ $? -ne 0 ]; then
   echo "Failed to wait for installation to finish!"
   exit 1
fi
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.