callirhoe/make_pkg
2014-11-02 15:27:18 +00:00

62 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -e
make_archive() {
base="$1"
tempdir="$2"
curdir=`pwd`
for i in `find $tempdir -type f -name "*.py" | grep -v "__init__"`; do
python2.7 -m py_compile $i
rm $i
done
# if copied with tar, this is not needed anyway:
# find $tempdir -type d -name ".svn" -exec rm -rf '{}' ';'
# or
# rm -rf `find $tempdir -type d -name ".svn"`
for i in `find $tempdir -type d -name ".svn"`; do
rm -rf $i
done
cd $tempdir
zip -q -r $curdir/$base.zip *
cd $curdir
rm -rf $tempdir
echo '#!/usr/bin/env python2.7' | cat - $base.zip > $base
chmod 755 $base
rm -f $base.zip
}
# Create Callirhoe package
DIR=`mktemp -d -t callirhoe.XXX`
# consider this command to actually copy only *.py, without any .svn/ or other crap
# tar also preserves timestamps by default, dunno if we really need them
#tar c {geom,lang,layouts,lib,style}/*.py | tar x -C "$DIR"
cp -R geom lang layouts lib style "$DIR"
cp callirhoe.py "$DIR/__main__.py"
./make_resources_list > "$DIR/lib/resources.py"
make_archive callirhoe "$DIR"
# Create Calmagick package
DIR=`mktemp -d -t callirhoe.XXX`
#tar c lib/{__init__,geom}.py | tar x -C "$DIR"
# we also avoid using mkdir this way! ;)
mkdir "$DIR/lib"
cp lib/__init__.py lib/geom.py "$DIR/lib"
cp calmagick.py "$DIR/__main__.py"
make_archive calmagick "$DIR"
# Create Makefile
cat << END > Makefile
prefix=/usr
install:
install -Dm755 callirhoe \$(DESTDIR)/bin/callirhoe
install -Dm755 calmagick \$(DESTDIR)/bin/calmagick
END
find holidays/* -printf "\tinstall -Dm644 %p \$(DESTDIR)/share/callirhoe/%p\n" >> Makefile