From 6f78f1d82d58690fca12f42f108c30a5c15714cb Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 10 Nov 2011 23:58:06 -0500 Subject: [PATCH] CC-2952: Put in final Liquidsoap 1.0 binaries -auto-compile script --- dev_tools/fabric/fab_liquidsoap_compile.py | 127 +++++++++++++++++++++ dev_tools/fabric/run2.sh | 16 +++ 2 files changed, 143 insertions(+) create mode 100644 dev_tools/fabric/fab_liquidsoap_compile.py create mode 100755 dev_tools/fabric/run2.sh diff --git a/dev_tools/fabric/fab_liquidsoap_compile.py b/dev_tools/fabric/fab_liquidsoap_compile.py new file mode 100644 index 000000000..8ae202f54 --- /dev/null +++ b/dev_tools/fabric/fab_liquidsoap_compile.py @@ -0,0 +1,127 @@ +#Airtime Liquidsoap compile infrastructure +#author martin.konecny@sourcefabric.org + +#Documentation for this page: + + +import os +import time +import sys +from fabric.api import * +from fabric.contrib.files import comment, sed, append + +from xml.dom.minidom import parse +from xml.dom.minidom import Node +from xml.dom.minidom import Element + +env.user = 'martin' +env.password = 'test' +env.hosts = [] +env.host_string + +env.vm_download_url = "http://host.sourcefabric.org/vms/VirtualBox" + +#fab -f fab_setup.py ubuntu_lucid_64 airtime_182_tar airtime_190_tar + + +def shutdown(): + sudo("shutdown -hP now") + time.sleep(30) + +def download_if_needed(vdi_dir, xml_dir, vm_name, vm_vdi_file, vm_xml_file): + if not os.path.exists(vdi_dir): + os.makedirs(vdi_dir) + + if os.path.exists(os.path.join(vdi_dir, vm_vdi_file)): + print "File %s already exists. No need to re-download" % os.path.join(vdi_dir, vm_vdi_file) + else: + print "File %s not found. Downloading" % vm_vdi_file + tmpPath = local("mktemp", capture=True) + local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_vdi_file, tmpPath)) + os.rename(tmpPath, os.path.join(vdi_dir, vm_vdi_file)) + + local("rm -f %s"%os.path.join(xml_dir, vm_xml_file)) + local("wget %s/%s/%s -O %s"%(env.vm_download_url, vm_name, vm_xml_file, os.path.join(xml_dir, vm_xml_file))) + + +def create_fresh_os(vm_name): + + vm_vdi_file = '%s.vdi'%vm_name + vm_xml_file = '%s.xml'%vm_name + vdi_dir = os.path.expanduser('~/tmp/vms/%s'%vm_name) + vdi_snapshot_dir = os.path.expanduser('~/tmp/vms/%s/Snapshots'%vm_name) + xml_dir = os.path.expanduser('~/.VirtualBox') + vm_xml_path = os.path.join(xml_dir, vm_xml_file) + + download_if_needed(vdi_dir, xml_dir, vm_name, vm_vdi_file, vm_xml_file) + + """ + if not os.path.exists("%s/vm_registered"%vdi_dir): + local("VBoxManage registervm %s"%os.path.join(xml_dir, vm_xml_file), capture=True) + local('VBoxManage storagectl "%s" --name "SATA Controller" --add sata'%vm_name) + local('VBoxManage storageattach "%s" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium %s'%(vm_name, os.path.join(vdi_dir, vm_vdi_file))) + local("VBoxManage modifyvm %s --snapshotfolder %s"%(vm_name, vdi_snapshot_dir)) + local("VBoxManage snapshot %s take fresh_install"%vm_name) + local("touch %s/vm_registered"%vdi_dir) + """ + + #local('VBoxManage snapshot %s restore fresh_install'%vm_name) + local('VBoxManage startvm %s'%vm_name) + print "Please wait while attempting to acquire IP address" + + time.sleep(15) + + try_again = True + while try_again: + ret = local('VBoxManage --nologo guestproperty get "%s" /VirtualBox/GuestInfo/Net/0/V4/IP'%vm_name, capture=True) + triple = ret.partition(':') + ip_addr = triple[2].strip(' \r\n') + print "Address found %s"%ip_addr + + try_again = (len(ip_addr) == 0) + time.sleep(1) + + env.hosts.append(ip_addr) + env.host_string = ip_addr + + + +def ubuntu_lucid_32(fresh_os=True): + if (fresh_os): + create_fresh_os('Ubuntu_10.04_32') + +def ubuntu_lucid_64(fresh_os=True): + if (fresh_os): + create_fresh_os('Ubuntu_10.04_64') + +def ubuntu_natty_32(fresh_os=True): + if (fresh_os): + create_fresh_os('Ubuntu_11.04_32') + +def ubuntu_natty_64(fresh_os=True): + if (fresh_os): + create_fresh_os('Ubuntu_11.04_64') + + +def compile_liquidsoap(filename="liquidsoap"): + + sudo('apt-get update') + sudo('apt-get upgrade -y') + sudo('sudo apt-get install -y libocamlcvs-ocaml-dev ocaml-findlib libao-ocaml-dev libportaudio-ocaml-dev ' + \ + 'libmad-ocaml-dev libtaglib-ocaml-dev libalsa-ocaml-dev libtaglib-ocaml-dev libvorbis-ocaml-dev ' + \ + 'libspeex-dev libspeexdsp-dev speex libladspa-ocaml-dev festival festival-dev ' + \ + 'libsamplerate-dev libxmlplaylist-ocaml-dev libxmlrpc-light-ocaml-dev libflac-dev ' + \ + 'libxml-dom-perl libxml-dom-xpath-perl icecast2 patch autoconf libmp3lame-dev ' + \ + 'libcamomile-ocaml-dev libcamlimages-ocaml-dev libtool libpulse-dev libjack-dev camlidl') + + root = '/home/martin/src' + run('mkdir -p %s' % root) + + tmpPath = local("mktemp", capture=True) + run('wget %s -O %s' % ('https://downloads.sourceforge.net/project/savonet/liquidsoap/1.0.0/liquidsoap-1.0.0-full.tar.bz2', tmpPath)) + run('mv %s %s/liquidsoap-1.0.0-full.tar.bz2' % (tmpPath, root)) + run('cd %s && bunzip2 liquidsoap-1.0.0-full.tar.bz2 && tar xf liquidsoap-1.0.0-full.tar' % root) + run('cd %s/liquidsoap-1.0.0-full && cp PACKAGES.minimal PACKAGES' % root) + run('cd %s/liquidsoap-1.0.0-full && ./configure' % root) + run('cd %s/liquidsoap-1.0.0-full && make' % root) + get('%s/liquidsoap-1.0.0-full/liquidsoap-1.0.0/src/liquidsoap' % root, filename) diff --git a/dev_tools/fabric/run2.sh b/dev_tools/fabric/run2.sh new file mode 100755 index 000000000..1f1cd3f56 --- /dev/null +++ b/dev_tools/fabric/run2.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +exec 2>&1 + +ubuntu_versions=("ubuntu_lucid_32" "ubuntu_lucid_64" "ubuntu_natty_32" "ubuntu_natty_64") + + +num1=${#ubuntu_versions[@]} + + +mkdir -p ./upgrade_logs2 + +for i in $(seq 0 $(($num1 -1))); +do + fab -f fab_liquidsoap_compile.py ${ubuntu_versions[$i]} compile_liquidsoap:${ubuntu_versions[$i]} shutdown 2>&1 | tee "./upgrade_logs2/${ubuntu_versions[$i]}.log" +done