diff --git a/dev_tools/fabric/fab_release_test.py b/dev_tools/fabric/fab_release_test.py index cbe37e0ca..417aa564d 100644 --- a/dev_tools/fabric/fab_release_test.py +++ b/dev_tools/fabric/fab_release_test.py @@ -19,18 +19,45 @@ env.user = 'martin' env.password = 'test' env.hosts = [] env.host_string +env.warn_only = True 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 do_sudo(command): + result = sudo(command) + if result.return_code != 0: + print "Error running command: %s" %command + shutdown() + sys.exit(1) + else: + return result + +def do_run(command): + result = run(command) + if result.return_code != 0: + print "Error running command: %s" %command + shutdown() + sys.exit(1) + else: + return result + +def do_local(command, capture=True): + result = local(command, capture) + if result.return_code != 0: + print "Error running command: %s" %command + shutdown() + sys.exit(1) + else: + return result + def shutdown(): - sudo("shutdown -hP now") - time.sleep(30) + do_sudo("poweroff") + time.sleep(45) def test(): - x = sudo('airtime-check-system') + x = do_sudo('airtime-check-system') print x.failed print x.succeeded print x.return_code @@ -43,12 +70,14 @@ def download_if_needed(vdi_dir, xml_dir, vm_name, vm_vdi_file, vm_xml_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)) + tmpPath = do_local("mktemp", capture=True) + do_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))) + if os.path.exists(os.path.join(xml_dir, vm_xml_file)): + print "File %s already exists. No need to re-download" % os.path.join(xml_dir, vm_xml_file) + else: + do_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, lucid=False, debian=False): @@ -58,7 +87,7 @@ def create_fresh_os(vm_name, lucid=False, debian=False): then they will most likey have a different host key, and ssh will fail, warning about a possible man in the middle attack. """ - local("rm -f ~/.ssh/known_hosts") + do_local("rm -f ~/.ssh/known_hosts") vm_vdi_file = '%s.vdi'%vm_name vm_xml_file = '%s.xml'%vm_name @@ -70,28 +99,28 @@ def create_fresh_os(vm_name, lucid=False, debian=False): 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) + do_local("VBoxManage registervm %s"%os.path.join(xml_dir, vm_xml_file), capture=True) + do_local('VBoxManage storagectl "%s" --name "SATA Controller" --add sata'%vm_name) + do_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))) + do_local("VBoxManage modifyvm %s --snapshotfolder %s"%(vm_name, vdi_snapshot_dir)) + do_local("VBoxManage snapshot %s take fresh_install"%vm_name) + do_local("touch %s/vm_registered"%vdi_dir) - local('VBoxManage snapshot %s restore fresh_install'%vm_name) + do_local('VBoxManage snapshot %s restore fresh_install'%vm_name) - local('VBoxManage modifyvm "%s" --bridgeadapter1 wlan0'%vm_name) - local('VBoxManage startvm %s'%vm_name) + do_local('VBoxManage modifyvm "%s" --bridgeadapter1 wlan0'%vm_name) + do_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) + ret = do_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 @@ -104,15 +133,15 @@ def create_fresh_os(vm_name, lucid=False, debian=False): if lucid: print "Lucid detected - updating python virtualenv" - sudo('apt-get update') - sudo('apt-get install -y python-setuptools') - sudo('wget http://apt.sourcefabric.org/pool/main/p/python-virtualenv/python-virtualenv_1.4.9-3_all.deb') + do_sudo('apt-get update') + do_sudo('apt-get install -y python-setuptools') + do_sudo('wget http://apt.sourcefabric.org/pool/main/p/python-virtualenv/python-virtualenv_1.4.9-3_all.deb') - sudo('dpkg -i python-virtualenv_1.4.9-3_all.deb') + do_sudo('dpkg -i python-virtualenv_1.4.9-3_all.deb') #supress rabbitmq bug that makes an upgrade warning pop-up even though it hasn't been #installed before. - sudo('echo "rabbitmq-server rabbitmq-server/upgrade_previous note" | debconf-set-selections') + do_sudo('echo "rabbitmq-server rabbitmq-server/upgrade_previous note" | debconf-set-selections') if debian: append('/etc/apt/sources.list', "deb http://www.debian-multimedia.org squeeze main non-free", use_sudo=True) @@ -158,73 +187,109 @@ def debian_squeeze_64(fresh_os=True): create_fresh_os('Debian_Squeeze_64', debian=True) def airtime_182_tar(): - sudo('apt-get update') - sudo('apt-get install -y tar gzip unzip apache2 php5-pgsql libapache2-mod-php5 ' + \ + do_sudo('apt-get update') + do_sudo('apt-get install -y tar gzip unzip apache2 php5-pgsql libapache2-mod-php5 ' + \ 'php-pear php5-gd postgresql odbc-postgresql python python-configobj poc-streamer ' + \ - 'lame daemontools daemontools-run python-mutagen libsoundtouch-ocaml sudo ' + \ + 'lame daemontools daemontools-run python-mutagen libsoundtouch-ocaml do_sudo ' + \ 'libtaglib-ocaml libao-ocaml libmad-ocaml libesd0 icecast2 oggvideotools ' + \ 'libportaudio2 libsamplerate0 libcamomile-ocaml-dev ecasound php5-curl mpg123 ' + \ 'python-setuptools python-pip rabbitmq-server libvorbis-ocaml-dev libmp3lame-dev flac') - sudo('pip install kombu') - sudo('pip install poster') + do_sudo('pip install kombu') + do_sudo('pip install poster') - sudo('mkdir -p /tmp/pear/cache') - sudo('pear channel-discover pear.phing.info || true') - sudo('pear install phing/phing-2.4.2 || true') + do_sudo('mkdir -p /tmp/pear/cache') + do_sudo('pear channel-discover pear.phing.info || true') + do_sudo('pear install phing/phing-2.4.2 || true') - sudo('ln -sf /etc/apache2/mods-available/php5.* /etc/apache2/mods-enabled') - sudo('ln -sf /etc/apache2/mods-available/rewrite.* /etc/apache2/mods-enabled') + do_sudo('ln -sf /etc/apache2/mods-available/php5.* /etc/apache2/mods-enabled') + do_sudo('ln -sf /etc/apache2/mods-available/rewrite.* /etc/apache2/mods-enabled') sed('/etc/php5/apache2/php.ini', ";upload_vdi_dir =", "upload_vdi_dir = /tmp", use_sudo=True) sed('/etc/php5/apache2/php.ini', ";date.timezone =", 'date.timezone = "America/Toronto"', use_sudo=True) put('airtime.vhost', '/etc/apache2/sites-available/airtime', use_sudo=True) - sudo('a2dissite default') - sudo('ln -sf /etc/apache2/sites-available/airtime /etc/apache2/sites-enabled/airtime') - sudo('a2enmod rewrite') - sudo('service apache2 restart') + do_sudo('a2dissite default') + do_sudo('ln -sf /etc/apache2/sites-available/airtime /etc/apache2/sites-enabled/airtime') + do_sudo('a2enmod rewrite') + do_sudo('service apache2 restart') sed('/etc/default/icecast2', 'ENABLE=false', 'ENABLE=true', use_sudo=True) - sudo('service icecast2 start') + do_sudo('service icecast2 start') - run('wget http://downloads.sourceforge.net/project/airtime/1.8.2/airtime-1.8.2.tar.gz') - run('tar xfz airtime-1.8.2.tar.gz') - sudo('cd ~/airtime-1.8.2/install && php airtime-install.php') + do_run('wget http://downloads.sourceforge.net/project/airtime/1.8.2/airtime-1.8.2.tar.gz') + do_run('tar xfz airtime-1.8.2.tar.gz') + do_sudo('cd ~/airtime-1.8.2/install && php airtime-install.php') #need to reboot because of daemon-tools. reboot(45) - sudo('airtime-check-system') + do_sudo('airtime-check-system') + +def airtime_190_tar(): + #1.9.0 doesn't do apt-get update during install, and therefore the package index + #files are not resynchronized. Need to do this here. + do_sudo('apt-get update') + + do_run('wget http://downloads.sourceforge.net/project/airtime/1.9.0/airtime-1.9.0.tar.gz') + do_run('tar xfz airtime-1.9.0.tar.gz') + do_sudo('cd /home/martin/airtime-1.9.0/install_full/ubuntu && ./airtime-full-install') + +def airtime_191_tar(): + #1.9.0 doesn't do apt-get update during install, and therefore the package index + #files are not resynchronized. Need to do this here. + do_sudo('apt-get update') + + do_run('wget http://downloads.sourceforge.net/project/airtime/1.9.1/airtime-1.9.1.tar.gz') + do_run('tar xfz airtime-1.9.1.tar.gz') + do_sudo('cd /home/martin/airtime-1.9.1/install_full/ubuntu && ./airtime-full-install') + +def airtime_192_tar(): + #1.9.2 doesn't do apt-get update during install, and therefore the package index + #files are not resynchronized. Need to do this here. + do_sudo('apt-get update') + + do_run('wget http://downloads.sourceforge.net/project/airtime/1.9.2/airtime-1.9.2.tar.gz') + do_run('tar xfz airtime-1.9.2.tar.gz') + do_sudo('cd /home/martin/airtime-1.9.2/install_full/ubuntu && ./airtime-full-install') + +def airtime_193_tar(): + #1.9.3 doesn't do apt-get update during install, and therefore the package index + #files are not resynchronized. Need to do this here. + do_sudo('apt-get update') + + do_run('wget http://downloads.sourceforge.net/project/airtime/1.9.3/airtime-1.9.3.tar.gz') + do_run('tar xfz airtime-1.9.3.tar.gz') + do_sudo('cd /home/martin/airtime-1.9.3/install_full/ubuntu && ./airtime-full-install') def airtime_194_tar(): #1.9.4 doesn't do apt-get update during install, and therefore the package index #files are not resynchronized. Need to do this here. - sudo('apt-get update') + do_sudo('apt-get update') - run('wget http://downloads.sourceforge.net/project/airtime/1.9.4/airtime-1.9.4.tar.gz') - run('tar xfz airtime-1.9.4.tar.gz') - sudo('cd /home/martin/airtime-1.9.4/install_full/ubuntu && ./airtime-full-install') + do_run('wget http://downloads.sourceforge.net/project/airtime/1.9.4/airtime-1.9.4.tar.gz') + do_run('tar xfz airtime-1.9.4.tar.gz') + do_sudo('cd /home/martin/airtime-1.9.4/install_full/ubuntu && ./airtime-full-install') def airtime_195_tar(): - run('wget http://downloads.sourceforge.net/project/airtime/1.9.5-RC5/airtime-1.9.5-RC5.tar.gz') - run('tar xfz airtime-1.9.5-RC5.tar.gz') - sudo('cd /home/martin/airtime-1.9.5/install_full/ubuntu && ./airtime-full-install') + do_run('wget http://downloads.sourceforge.net/project/airtime/1.9.5/airtime-1.9.5.tar.gz') + do_run('tar xfz airtime-1.9.5.tar.gz') + do_sudo('cd /home/martin/airtime-1.9.5/install_full/ubuntu && ./airtime-full-install') def airtime_latest_deb(): append('/etc/apt/sources.list', "deb http://apt.sourcefabric.org/ lucid main", use_sudo=True) append('/etc/apt/sources.list', "deb http://archive.ubuntu.com/ubuntu/ lucid multiverse", use_sudo=True) - sudo('apt-get update') - sudo('apt-get install -y --force-yes sourcefabric-keyring') - sudo('apt-get install -y postgresql') - sudo('apt-get install -y icecast2') - sudo('apt-get purge -y pulseaudio') - sudo('apt-get install -y --force-yes airtime') + do_sudo('apt-get update') + do_sudo('apt-get install -y --force-yes sourcefabric-keyring') + do_sudo('apt-get install -y postgresql') + do_sudo('apt-get install -y icecast2') + do_sudo('apt-get purge -y pulseaudio') + do_sudo('apt-get install -y --force-yes airtime') def airtime_git_branch(branch="devel"): - sudo('apt-get update') - sudo('apt-get install -y git-core') - run('git clone https://github.com/sourcefabric/Airtime.git ~/airtime') - sudo('cd /home/martin/airtime && git checkout %s && install_full/ubuntu/airtime-full-install || true' % branch) + do_sudo('apt-get update') + do_sudo('apt-get install -y git-core') + do_run('git clone https://github.com/sourcefabric/Airtime.git ~/airtime') + do_sudo('cd /home/martin/airtime && git checkout %s && install_full/ubuntu/airtime-full-install || true' % branch) def airtime_200(): diff --git a/dev_tools/fabric/run.sh b/dev_tools/fabric/run.sh index a54a4a58d..5f259b66b 100755 --- a/dev_tools/fabric/run.sh +++ b/dev_tools/fabric/run.sh @@ -3,9 +3,10 @@ exec 2>&1 target="airtime_git_branch" -airtime_versions=("" "airtime_182_tar" "airtime_195_tar") +#airtime_versions=("" "airtime_182_tar" "airtime_190_tar" "airtime_191_tar" "airtime_192_tar" "airtime_192_tar" "airtime_194_tar" "airtime_195_tar") +airtime_versions=("airtime_191_tar" "airtime_192_tar" "airtime_192_tar" "airtime_194_tar" "airtime_195_tar") #airtime_versions=("") -ubuntu_versions=("ubuntu_lucid_32" "ubuntu_lucid_64" "ubuntu_maverick_32" "ubuntu_maverick_64" "ubuntu_natty_32" "ubuntu_natty_64" "debian_squeeze_32" "debian_squeeze_64") +ubuntu_versions=("ubuntu_natty_64") #ubuntu_versions=("ubuntu_lucid_32" "ubuntu_lucid_64" "ubuntu_maverick_32" "ubuntu_maverick_64" "ubuntu_natty_32" "ubuntu_natty_64" "ubuntu_oneiric_32" "ubuntu_oneiric_64" "debian_squeeze_32" "debian_squeeze_64") num1=${#ubuntu_versions[@]}