blob: eda907c5cb712c97985f20d4497260df4b0c4396 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
#! /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_internal () {
# Use this function to fulfill the dependency (almost)
local ARCH=$(dpkg --print-architecture)
echo " -> Attempting to parse the build-deps by myself"
for INSTALLPKGMULTI in $(grep "^Build-Depends\(-Indep\|\): " "$BUILDPLACE/"tmp/buildd/*/debian/control | \
sed 's/^[^:]*: \(.*\)$/\1/' | \
tr " " "/" | \
awk 'BEGIN{RS=","} {print}'); do
#echo " -> Considering $INSTALLPKGMULTI"
SATISFIED="no"
for INSTALLPKG in $(echo "$INSTALLPKGMULTI" | \
awk 'BEGIN{RS="|"} {print}'); do
#echo " -> Trying to install $INSTALLPKG"
if echo "$INSTALLPKG" | grep '\[' > /dev/null ; then
# this package has arch-deps.
if echo "$INSTALLPKG" | sed 's/.*\(\[.*\]\)/\1/' | grep "[[/]!$ARCH[]/]" > /dev/null; then
# don't install this on this arch -- satisfied? maybe. FIXME
SATISFIED="yes"
continue;
fi
if ! echo "$INSTALLPKG" | sed 's/.*\(\[.*\]\)/\1/' | grep "[[/]$ARCH[]/]" > /dev/null; then
# this arch is not listed. -- satisfied? maybe. FIXME
SATISFIED="yes"
continue;
fi
fi
#echo " -> Installing $INSTALLPKG"
$CHROOTEXEC usr/bin/apt-get -y install $(echo "$INSTALLPKG" | tr "/" " " | awk '{print $1}') && \
SATISFIED="yes"
done;
if [ "$SATISFIED" = "no" ]; then
echo Could not satisfy build-dependency.
abortingfunction
exit 1
fi
done;
for INSTALLPKG in $(grep "^Build-Conflicts\(-Indep\|\): " "$BUILDPLACE/"tmp/buildd/*/debian/control | \
sed 's/^[^:]*: \(.*\)$/\1/' | \
tr " " "/" | \
awk 'BEGIN{RS=","} {print}'); do
#echo " -> Considering $INSTALLPKG"
if echo "$INSTALLPKG" | grep '\[' > /dev/null ; then
# this package has arch-conflicts.
if echo "$INSTALLPKG" | sed 's/.*\(\[.*\]\)/\1/' | grep "[[/]!$ARCH[]/]" > /dev/null; then
# don't install this on this arch
continue;
fi
if ! echo "$INSTALLPKG" | sed 's/.*\(\[.*\]\)/\1/' | grep "[[/]$ARCH[]/]" > /dev/null; then
# this arch is not listed.
continue;
fi
fi
#echo " -> Removing $INSTALLPKG"
$CHROOTEXEC usr/bin/apt-get -y remove $(echo "$INSTALLPKG" | tr "/" " " | awk '{print $1}') || (
echo Could not satisfy build-conflicts
abortingfunction
exit 1
)
done
}
function checkbuilddep_using_dpkgcheckbuilddeps () {
# this function is not used currently... and is incomplete.
for INSTALLPKG in $($CHROOTEXEC bin/sh -c "(cd tmp/buildd/*/; dpkg-checkbuilddeps)" 2>&1 | \
grep "^dpkg-checkbuilddeps: Unmet build dependencies: " | \
sed 's/^[^:]*:[^:]*: \(.*\)$/\1/' | \
awk 'BEGIN{RS=", "} {print $1}'); do
echo " -> Installing $INSTALLPKG"
$CHROOTEXEC usr/bin/apt-get -y install "$INSTALLPKG"
done
for REMOVEPKG in $($CHROOTEXEC bin/sh -c "(cd tmp/buildd/*/; dpkg-checkbuilddeps)" 2>&1 | \
grep "^dpkg-checkbuilddeps: Build conflicts: " | \
sed 's/^[^:]*:[^:]*: \(.*\)$/\1/' | \
awk 'BEGIN{RS=", "} {print $1}'); do
echo " -> Removing $REMOVEPKG"
$CHROOTEXEC usr/bin/apt-get -y remove "$REMOVEPKG"
done
}
function checkbuilddep () {
checkbuilddep_internal;
}
. /usr/lib/pbuilder/pbuilder-checkparams
PACKAGENAME="$1"
CHROOTEXEC="chroot $BUILDPLACE "
if [ ! -f "$PACKAGENAME" ]; then
echo "Command line parameter [$PACKAGENAME] is not a valid .dsc file name" >&2
exit 1;
fi;
extractbuildplace
echo Copying source file
copydsc "$PACKAGENAME" "$BUILDPLACE/tmp/buildd"
echo Extracting source
$CHROOTEXEC /bin/bash -c "( cd tmp/buildd; /usr/bin/dpkg-source -x $(basename $PACKAGENAME) )" || (
echo pbuilder: Failed extracting the source >&2
abortingfunction
exit 1;
)
echo Installing the build-deps
checkbuilddep
echo Building the package
$CHROOTEXEC /bin/bash -c "(cd tmp/buildd/*/; dpkg-buildpackage)" || (
echo pbuilder: Failed autobuilding of package >&2
abortingfunction
exit 1;
)
umountproc
test -n "$BUILDRESULT" && (
mkdir -p "$BUILDRESULT"
if [ -d "$BUILDRESULT" ]; then
cp "$BUILDPLACE"/tmp/buildd/* "$BUILDRESULT"
else
echo "Error: BUILDRESULT=[$BUILDRESULT] and is not a directory." >&2
fi
)
cleanbuildplace
|