blob: a0f1f1ced032099db292d1e78608ff7fd4b5d7d4 (
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
|
#!/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
mysql_server_package=mysql-server
run()
{
"$@"
if test $? -ne 0; then
echo "Failed $@"
exit 1
fi
}
grep '^deb ' /etc/apt/sources.list | \
sed -e 's/^deb /deb-src /' > /etc/apt/sources.list.d/base-source.list
run apt-get update
run apt-get install -V -y lsb-release
distribution=$(lsb_release --id --short)
code_name=$(lsb_release --codename --short)
groonga_list=/etc/apt/sources.list.d/groonga.list
if [ ! -f "${groonga_list}" ]; then
case ${distribution} in
Debian)
component=main
if [ "$code_name" = "sid" ]; then
code_name=unstable
fi
;;
Ubuntu)
component=universe
;;
esac
downcased_distribtion=$(echo ${distribution} | tr A-Z a-z)
run cat <<EOF | run tee ${groonga_list}
deb http://packages.groonga.org/${downcased_distribtion}/ ${code_name} ${component}
deb-src http://packages.groonga.org/${downcased_distribtion}/ ${code_name} ${component}
EOF
apt-get update
run apt-get -V -y --allow-unauthenticated install groonga-keyring
fi
run apt-get update
run apt-get upgrade -V -y
security_list=/etc/apt/sources.list.d/security.list
if [ ! -f "${security_list}" ]; then
run apt-get install -V -y lsb-release
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
run apt-get update
run apt-get upgrade -V -y
fi
universe_list=/etc/apt/sources.list.d/universe.list
if [ ! -f "$universe_list}" ]; then
case ${distribution} in
Ubuntu)
sed -e 's/main/universe/' /etc/apt/sources.list > ${universe_list}
run apt-get update
;;
esac
fi
run apt-get install -V -y devscripts ${DEPENDED_PACKAGES}
run apt-get build-dep -y ${mysql_server_package}
run apt-get 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 nostrip"
MYSQL_PACKAGE_INFO=\$(apt-cache show mysql-server | grep Version | sort | tail -1)
MYSQL_PACKAGE_VERSION=\${MYSQL_PACKAGE_INFO##Version: }
sed -i "s/MYSQL_VERSION/\$MYSQL_PACKAGE_VERSION/" debian/control
debuild -us -uc
EOF
run chmod +x $BUILD_SCRIPT
run su - $USER_NAME $BUILD_SCRIPT
|