Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
#
# Script to build all qooxdoo contrib demos in the contrib catalog that are
# compliant with the contribution skeleton, i.e. they are located in demo/default
# and have a config.json there. The demos are built in all published versions
# with all indicated qooxdoo versions. The aim is to be able to easily test
# which contrib version works with which qooxdoo version.
#
# requires subversion and the jq binary (http://stedolan.github.io/jq/) in the
# PATH
#
# Author: Christian Boulanger (info AT bibliograph DOT org)
# This script is in the public domain.
# directory to which the built demos should be deployed
deploydir=/var/www/qooxdoo-contrib/
# clone the contrib catalog
if [ ! -d "contrib-catalog" ]; then
git clone https://github.com/qooxdoo/contrib-catalog.git
fi
# iterate over manifest files
shopt -s nullglob
for f in ./contrib-catalog/contributions/*/*/Manifest.json
do
# get contrib info
contribname=$(cat $f | jq -r '.info["name"]')
# skip if error
if [ $? -ne 0 ]; then
echo " - ! Couldn't parse $f - skipping "
continue
fi
contribversion=$(cat $f | jq -r '.info["version"]')
contribdownloadurl=$(cat $f | jq -r '.info["download"]')
qxversions=$(cat $f | jq -r '.info["qooxdoo-versions"][]')
echo "$contribname ($contribversion):"
# iterate over qooxdoo versions
for v in $qxversions
do
v=$(echo $v | sed 's/\-pre//g')
case "$v" in
0.7) v="0.7.4";;
0.8) v="0.8.3";;
1.0) v="1.0.2";;
1.0-beta1) v="1.0.2";;
1.1) v="1.1.2";;
1.2) v="1.2.2";;
1.3) v="1.3.1";;
1.4) v="1.4.2";;
1.5) v="1.5.1";;
1.6) v="1.6.1";;
2.0) v="2.0.4";;
2.1) v="2.1.2";;
3.0) v="3.0.2";;
3.6) v="3.5";; # unreleased
trunk)
# bad idea to use "trunk" as version, version should always refert to specific release
echo " - Skipping 'trunk' because of unknown qooxdoo version"
continue ;;
*);;
esac
release=$(echo $v | sed 's/\./_/g' )
qxzipurl="https://github.com/qooxdoo/qooxdoo/archive/release_$release.zip"
qxdirname="qooxdoo/qooxdoo-release_$release"
qxtmpname="qooxdoo/$release.zip"
mkdir -p "qooxdoo"
# download qooxdoo release
if [ ! -d $qxdirname ]; then
echo " - Downloading release $release ..."
wget -qO- -O $qxtmpname $qxzipurl
unzip -qq -d "qooxdoo" $qxtmpname
rm $qxtmpname
fi
contribdir="demos/$contribname/$contribversion"
# download demo from github
if [[ $contribdownloadurl == *github.com* ]]; then
contribdownloadurl=$(echo $contribdownloadurl | sed 's/tar.gz/zip/g')
contribtmpname="$contribname.zip"
if [ ! -d $contribdir ]; then
mkdir -p $contribdir
echo " - Downloading $contribname ($contribversion) from github ..."
wget -qO- -O $contribtmpname $contribdownloadurl
unzip -qq -d $contribdir $contribtmpname
rm $contribtmpname
containerdir=$contribdir/qx-contrib-$contribname-$contribversion
if [ -d $containerdir/$contribname ]; then
mv $containerdir/$contribname/* $contribdir
rm -rf $containerdir/$contribname
fi
mv $containerdir/* $contribdir
rm -rf $containerdir
# in the latest contrib skeleton, the path is prefixed by
# contribname/trunk, remove this prefix
if [ -d $contribdir/$contribversion ]; then
mv $contribdir/$contribversion/* $contribdir
rm -rf $contribdir/$contribversion
fi
if [ -d $contribdir/trunk ]; then
mv $contribdir/trunk/* $contribdir
rm -rf $contribdir/trunk
fi
fi
fi
# download demo from sourceforge
if [[ $contribdownloadurl == *svn.code.sf.net* ]]; then
if [ ! -d $contribdir ]; then
mkdir -p $contribdir
echo " - Downloading $contribname ($contribversion) from sourceforge ..."
svn -q checkout $contribdownloadurl $contribdir
fi
fi
# determine path to demo source
demopath=$contribdir/demo/default
# if demo exists, adapt config file and build demo
# you have to manually strip comments (illegal according to spec) from
# the json files first!
configfile=$demopath/config.json
if [ -f $configfile ]; then
releasebuilddir=$demopath/build-$release
# build if not already built
if [ ! -f $releasebuilddir/index.html ]; then
if [ -d $qxdirname/qooxdoo ]; then
qxdirname=$qxdirname/qooxdoo
fi
qxpath=$(readlink -f $qxdirname)
cat $configfile | jq ".let.QOOXDOO_PATH = \"$qxpath\"" > $configfile.new
if [ $? -ne 0 ]; then
echo " - ! Couldn't parse $configfile - skipping "
continue
fi
mv $configfile $configfile.old
mv $configfile.new $configfile
echo " - Building demo for qooxdoo $release ..."
python $demopath/generate.py build &> $demopath/buildlog.txt
if [ $? -ne 0 ]; then
echo " - ! Coulnd't build demo - check buildlog.txt"
continue
fi
mv $demopath/build $releasebuilddir
mv $demopath/buildlog.txt $releasebuilddir/
fi
#deploy if not already deployed
thisdemodir=$deploydir/$contribname/$contribversion/$release
if [ ! -d $thisdemodir ]; then
echo " - Copying build to deployment dir ..."
mkdir -p $thisdemodir
cp -af $releasebuilddir/* $thisdemodir/
fi
fi
done
done
exit 0
@tobiasoberrauch

This comment has been minimized.

Copy link

commented Apr 25, 2014

Great. Thanks a lot for your effort :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.