summaryrefslogtreecommitdiff
path: root/release.sh
blob: c2c5b6231ddd8661eead38c3bdc9b2881b003b8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash

fail ()
{
    echo ERROR: $1
    exit $2
}

replace_by ()
{
    echo ">>> ** Replace $1 by $2"

    sed -i -e "s#^\($1\s*=\s*\).*#\1$2#" portato/constants.py \
        || fail "Failure replacing $1" 1
}

ver=$(git describe --tags)
name=portato-$ver

echo ">>> Cloning..."
git clone . $name || fail "Cloning" 1

pushd $name > /dev/null

echo ">>> Compiling Cython sources"
find -name '*.pyx' | xargs cython || fail "Cython" 1

echo ">>> Patching constants.py"
replace_by VERSION "'$ver'"
replace_by ROOT_DIR "'/'"
replace_by TEMPLATE_DIR "pjoin(ROOT_DIR, '/usr/share/locale')"
replace_by DATA_DIR "'/usr/share/portato/'"

echo ">>> Patching setup.py."
sed -i -e "s/^.*#!REMOVE\$//" setup.py || fail "Failure removing lines" 1
sed -i -e "s/^\(\s*\)#!INSERT \(.*\)/\1\2/" setup.py || fail "Failure inserting lines" 1

popd > /dev/null

echo ">>> Packing"
tar -zcvf ${name}.tar.gz $name --exclude ".git*" || fail "Packing" 1

echo ">>> Removing temp dir"
rm -rf $name || fail "Removing" 1