Add 2009 to copyright and fix its format
[skype-call-recorder.git] / utils / makedeb
bloba416b64e570d9313cc074d597b0bf3d57ce773ca
1 #!/bin/sh
3 target=none
4 version=''
6 while test $# != 0; do
7 case "$1" in
8 -e) target=eee ;;
9 -u) target=ubuntu ;;
10 -d) target=debian ;;
11 -*) echo "Unknown option $1" && exit 1 ;;
12 *) version="$1" ;;
13 esac
14 shift
15 done
17 if test -z "$version" -o $target = none; then
18 echo "Usage: $0 { -d | -e | -u } <version>"
19 exit 1
22 if git tag -l | grep -q "^$version\$" > /dev/null 2> /dev/null; then
24 else
25 echo "I don't know version $version, here's what I know:"
26 git tag -l | sed -e 's/^/ /'
27 exit 1
30 export BASE=$(pwd)
32 if test $target = eee; then
33 controlflags=eee
34 cmake="$BASE/utils/cmake-static"
35 elif test $target = ubuntu; then
36 controlflags=ubuntu
37 cmake=cmake
38 elif test $target = debian; then
39 controlflags=debian
40 cmake=cmake
41 else
42 echo "Unknown target: $target"
43 exit 1
46 uname_m=$(uname -m)
47 case "$uname_m" in
48 i[3456]86) arch=i386 ;;
49 x86_64) arch=amd64 ;;
51 echo "Unrecognized output of 'uname -m': $uname_m"
52 exit 1
54 esac
56 tmp=tmp-deb-build
57 rm -rf "$tmp"
58 mkdir "$tmp"
60 $BASE/utils/snapshot $version "$tmp/tarball.tar.gz" || exit 1
61 tar -xzf "$tmp/tarball.tar.gz" -C "$tmp" || exit 1
64 cd "$tmp/skype-call-recorder-$version" && \
65 $cmake . && \
66 make && \
67 make DESTDIR=../root install
68 ) || exit 1
70 echo -n "Package size: "
71 size=`du -sk "$tmp/root" | cut -f1`
72 echo "$size KB"
74 echo -n "Generate control file: "
76 mkdir "$tmp/root/DEBIAN" && \
77 cp "$tmp/skype-call-recorder-$version/skype-call-recorder.control" "$tmp/root/DEBIAN/control" || exit 1
79 for flag in $controlflags; do
80 sed -i -e "s/^@@$flag\s\+//" "$tmp/root/DEBIAN/control" || exit 1
81 done
83 sed -i \
84 -e "/^#/d" \
85 -e "/^@@\w\+\s/d" \
86 -e "s/@version@/$version/g" \
87 -e "s/@size@/$size/g" \
88 -e "s/@arch@/$arch/g" \
89 "$tmp/root/DEBIAN/control" || exit 1
91 echo Done
93 dpkg-deb -b -Zbzip2 -z9 "$tmp/root" "skype-call-recorder-${target}_${version}_$arch.deb"
95 rm -rf "$tmp"