aboutsummaryrefslogtreecommitdiff
path: root/pbuilder-buildpackage.sh
blob: 7f0a5c0fd30f94a9a4fb03314ac8bb150fe7a94c (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
45
46
47
48
49
50
#! /bin/bash
export LANG=C
export LC_ALL=C

function copydsc () {
    local DSCFILE=$1
    local TARGET=$2
    for FILE in 
      "$DSCFILE" \
      $(echo "$DSCFILE" | sed 's/^\(.*\)\.dsc$/\1/' ).diff.gz \
      $(echo "$DSCFILE" | sed 's/^\(.*\)\.dsc$/\1/').tar.gz \
      $(echo "$DSCFILE" | sed 's/\(.*\)-[^-.]*\.dsc$/\1/').orig.tar.gz ; do
        cp $FILE $TARGET ;
    done

}

function checkbuilddep () {
    (
    cd $BUILDPLACE/tmp/buildd/*/
    $CHROOTEXEC usr/bin/apt-get -y install $(dpkg-checkbuilddeps 2>&1 | sed 's/^.*: \(.*\)$/\1/' | awk 'BEGIN{RS=", "} /^([^([]*)/{print $1}')
    )
}

PACKAGENAME=$1
. /etc/pbuilderrc
CHROOTEXEC="chroot $BUILDPLACE "

echo cleaning the build env
rm -rf $BUILDPLACE

echo building the build env
mkdir -p $BUILDPLACE
(
 cd $BUILDPLACE
 tar xfzp $BASETGZ
 mkdir -p $BUILDPLACE/tmp/buildd
)
echo Copying source file
copydsc "$PACKAGENAME" "$BUILDPLACE/tmp/buildd"
echo Extracting source
$CHROOTEXEC /usr/bin/dpkg-source -x $(basename $PACKAGENAME)
echo Installing the build-deps 
checkbuilddep
echo Building the package
$CHROOTEXEC /bin/sh -c "(cd tmp/buildd/*/; dpkg-buildpackage)"
echo Installing $BUILDPLACE/tmp/buildd/* to archive
mkdir -p $MYREPOSITORYEXTRAPATH
cp $BUILDPLACE/tmp/buildd/* $MYREPOSITORYEXTRAPATH