blob: 1f5a5b0398595b7b564058a9b8fa79de48fab8cb (
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
|
#!/bin/sh
LANG=C
PACKAGE=$(cat /tmp/build-package)
USER_NAME=$(cat /tmp/build-user)
VERSION=$(cat /tmp/build-version)
DEPENDED_PACKAGES=$(cat /tmp/depended-packages)
BUILD_SCRIPT=/tmp/build-deb-in-chroot.sh
run()
{
"$@"
if test $? -ne 0; then
echo "Failed $@"
exit 1
fi
}
if [ ! -x /usr/bin/lsb_release ]; then
run apt-get update
run apt-get install -y lsb-release
fi
distribution=$(lsb_release --id --short)
code_name=$(lsb_release --codename --short)
security_list=/etc/apt/sources.list.d/security.list
if [ ! -f "${security_list}" ]; then
case ${distribution} in
Debian)
if [ "${code_name}" = "sid" ]; then
touch "${security_list}"
else
cat <<EOF > "${security_list}"
deb http://security.debian.org/ ${code_name}/updates main
deb-src http://security.debian.org/ ${code_name}/updates main
EOF
fi
;;
Ubuntu)
cat <<EOF > "${security_list}"
deb http://security.ubuntu.com/ubuntu ${code_name}-security main restricted
deb-src http://security.ubuntu.com/ubuntu ${code_name}-security main restricted
EOF
;;
esac
fi
sources_list=/etc/apt/sources.list
if [ "$distribution" = "Ubuntu" ] && \
! (grep '^deb' $sources_list | grep -q universe); then
run sed -i'' -e 's/main$/main universe/g' $sources_list
fi
if [ ! -x /usr/bin/aptitude ]; then
run apt-get update
run apt-get install -y aptitude
fi
run aptitude update -V -D
run aptitude safe-upgrade -V -D -y
run aptitude install -V -D -y ruby
if aptitude show libmsgpack-dev > /dev/null 2>&1; then
DEPENDED_PACKAGES="${DEPENDED_PACKAGES} libmsgpack-dev"
else
ruby -i'' -ne 'print $_ unless /libmsgpack/' /tmp/${PACKAGE}-debian/control
fi
case $(lsb_release -s -c) in
jessie|sid)
DEPENDED_PACKAGES="${DEPENDED_PACKAGES} libzmq3-dev"
;;
*)
DEPENDED_PACKAGES="${DEPENDED_PACKAGES} libzmq-dev"
;;
esac
if aptitude show libevent-dev > /dev/null 2>&1; then
DEPENDED_PACKAGES="${DEPENDED_PACKAGES} libevent-dev"
else
ruby -i'' -ne 'print $_ unless /libevent/' /tmp/${PACKAGE}-debian/control
fi
if aptitude show liblzo2-dev > /dev/null 2>&1; then
DEPENDED_PACKAGES="${DEPENDED_PACKAGES} liblzo2-dev"
else
ruby -i'' -ne 'print $_ unless /liblzo2-dev/' /tmp/${PACKAGE}-debian/control
fi
run aptitude install -V -D -y devscripts ${DEPENDED_PACKAGES}
run aptitude clean
if ! id $USER_NAME >/dev/null 2>&1; then
run useradd -m $USER_NAME
fi
cat <<EOF > $BUILD_SCRIPT
#!/bin/sh
rm -rf build
mkdir -p build
cp /tmp/${PACKAGE}-${VERSION}.tar.gz build/${PACKAGE}_${VERSION}.orig.tar.gz
cd build
tar xfz ${PACKAGE}_${VERSION}.orig.tar.gz
cd ${PACKAGE}-${VERSION}/
cp -rp /tmp/${PACKAGE}-debian debian
# export DEB_BUILD_OPTIONS=noopt
debuild -us -uc
EOF
run chmod +x $BUILD_SCRIPT
run su - $USER_NAME $BUILD_SCRIPT
|