Skip to content

Instantly share code, notes, and snippets.

@tung
Created December 25, 2011 07:31
Show Gist options
  • Save tung/1518852 to your computer and use it in GitHub Desktop.
Save tung/1518852 to your computer and use it in GitHub Desktop.
Automated update script(s) for byuu's phoenix GUI meta-toolkit on Linux
#!/usr/bin/env python
# Print phoenix download URL if not already downloaded.
import urllib2
from BeautifulSoup import BeautifulSoup
import re
import glob
protocol = 'http'
domain = 'byuu.org'
linkre = re.compile('^phoenix .* ([0-9]{4})-([0-9]{2})-([0-9]{2})$')
page = urllib2.urlopen(protocol + '://' + domain + '/phoenix/')
soup = BeautifulSoup(page)
link = soup.find('a', text=linkre)
if link:
date = ''.join(linkre.match(link).group(1, 2, 3))
if len(glob.glob('phoenix_' + date + '.tar.bz2')) == 0:
print(protocol + '://' + domain + '/' + link.parent['href'])
#!/bin/bash
# Download, install and compile phoenix GUI meta-toolkit on Linux.
# Requires python-beautifulsoup for checker script.
# Requires GCC 4.6+ and libgtk2.0-dev to be built.
#
# http://byuu.org/phoenix/
PROGNAME=$(basename $0)
#err "$LINENO: An example error message"
function err
{
echo "${PROGNAME}: ${1:-"unknown error"}" 1>&2
exit 1
}
# check for update
echo Checking for update ...
newest=$(./check.py) || err "$LINENO: check.py failed"
if [ -z "$newest" ]; then
echo "phoenix up-to-date"
exit 0
fi
# download phoenix
wget "$newest" || err "$LINENO: could not download phoenix ($newest)"
file=`expr "$newest" : '.*/\([^/]*\)'`
# extract
rm -r phoenix > /dev/null 2>&1
bunzip2 --stdout "$file" | tar -x || err "$LINENO: could not extract phoenix"
# fix permissions
chmod -R go-w phoenix
chmod -x phoenix/windows/phoenix.{Manifest,rc}
find phoenix -path 'phoenix/**.[ch]pp' -type f -exec chmod -x '{}' \+
# replace previous install headers
echo Replacing /usr/local/include/{nall,phoenix} ...
sudo rm -r /usr/local/include/{nall,phoenix} > /dev/null 2>&1
sudo cp -R phoenix /usr/local/include/ || err "$LINENO: could not copy phoenix headers"
sudo ln -s /usr/local/include/phoenix/nall /usr/local/include/nall || err "$LINENO: could not copy nall headers"
# build phoenix.o
echo Building phoenix ...
cd phoenix && g++ -std=gnu++0x -I.. -O3 -fomit-frame-pointer -c phoenix.cpp -DPHOENIX_GTK `pkg-config --cflags gtk+-2.0` && cd - || err "$LINENO: could not compile phoenix.o"
# copy in /usr/local/include/phoenix/phoenix.o
echo Copying phoenix.o to /usr/local/include/phoenix/ ...
sudo cp phoenix/phoenix.o /usr/local/include/phoenix || err "$LINENO: could not install phoenix.o"
echo Done! Linkable object at /usr/local/include/phoenix/phoenix.o
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment