~jontai/openvista-gtm-integration/bug358242

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh

# build Debian package(s) from the files in this directory
#
# specify the name of a package to build as the first argument, or no arguments
# to build all packages

dir1=`pwd`
dir2=`dirname "$0"`
dir=`cd "$dir1/$dir2"; pwd`

if [ -z "$1" ]; then
    packages=""
    for package in "$dir/packages/deb/"*; do
        package=`basename "$package"`
        packages="$packages $package"
    done
else
    if [ -d "$dir/packages/deb/$1" ]; then
        packages=$1
    else
        echo "debuild.sh: $1: No such package in '$dir/packages/deb'" >&2
        exit 3
    fi
fi

mkdir -p /tmp/ubuntu

for package in $packages; do
    version=`head -n1 "packages/deb/$package/debian/changelog" | awk '{ print $2 }' | sed 's/[()]//g' | sed 's/-[^\-]\+$//'`

    case $package in
        openvista-utils|openvista-libs*)
            # create source tarabll
            rm -rf "/tmp/ubuntu/${package}-$version"
            cp -Rp "$dir" "/tmp/ubuntu/${package}-$version"
            rm -rf "/tmp/ubuntu/${package}-$version/.bzr"
            rm -f "/tmp/ubuntu/${package}_${version}.orig.tar.gz"
            tar -c --gzip -f "/tmp/ubuntu/${package}_${version}.orig.tar.gz" -C /tmp/ubuntu "${package}-$version"
            cp -Rp "/tmp/ubuntu/${package}-$version/packages/deb/$package/debian" "/tmp/ubuntu/${package}-$version/"

            ( cd "/tmp/ubuntu/${package}-$version" && debuild )
            ;;
        fis-gtm*)
            # rename source tarball
            upstream_version=`echo "$version" | sed 's/\.//'`
            cp -f "/tmp/ubuntu/gtm_V${upstream_version}_linux_i686_src.tar.gz" "/tmp/ubuntu/${package}_${version}.orig.tar.gz"

            # unpack source tarball
            rm -rf "/tmp/ubuntu/${package}-${version}"
            mkdir "/tmp/ubuntu/${package}-${version}"
            ( cd "/tmp/ubuntu/${package}-${version}" && tar -xzf "/tmp/ubuntu/${package}_${version}.orig.tar.gz" )
            cp -Rp "$dir/packages/deb/${package}/debian" "/tmp/ubuntu/${package}-${version}/"

            ( cd "/tmp/ubuntu/${package}-$version" && debuild -r sudo )
            ;;
    esac
done