2 # This script builds Debian packages for one or more distributions
3 # in i386/amd64 architectures. It uses pbuilder. pbuilder requires root
4 # privilege and so this script should be invoked with sudo.
9 Usage: id-pbuild.sh [OPTIONS]
21 # things that might be set by options
27 if test -f IDMETA; then
30 while test $# -gt 0; do
32 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
61 if test -n $DEBIAN_DIST_A -o -n $UBUNTU_DIST_A -o -n $CENTOS_DIST_A; then
62 DEBIAN_DIST=$DEBIAN_DIST_A
63 UBUNTU_DIST=$UBUNTU_DIST_A
64 CENTOS_DIST=$CENTOS_DIST_A
67 if test "$do_help" = "yes"; then
71 if test "$DEBIAN_DIST" -o "$UBUNTU_DIST"; then
78 ID_DEB_BUILD=`cd $D0; pwd`
79 PBUILDROOT=${ID_DEB_BUILD}/id-pbuild-root.sh
80 if test ! -x $PBUILDROOT; then
81 echo "$PBUILDROOT not found"
85 MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh
86 if test ! -x $MKDEBSRC; then
87 echo "$MKDEBSRC not found"
95 if test "${SUDO_USER}"; then
96 if test ! -d deb-src; then
100 if test -d deb-src; then
102 if test $? -ne 0; then
103 echo "deb-src could not be removed. Remove deb-src manually"
118 if test -f "$f"; then
122 if test -z "$PKG"; then
123 echo "Specify .dsc file"
126 if test ! -e "$PKG"; then
127 echo "${PKG} does not exist"
130 if grep "Architecture: all" $PKG >/dev/null; then
137 if test -z "$PRODUCT"; then
140 if test -z "$PRODUCT"; then
142 PRODUCT=`echo *.dsc|sed 's/_.*//g'`
144 PRODUCT=`cd ..;rpm -q --specfile *.spec --queryformat "%{NAME};" | cut -d ";" -f1`
147 echo "Dsc $PKG . Product $PRODUCT"
148 echo "Ubuntu distros: $UBUNTU_DIST"
149 echo "Debian distros: $DEBIAN_DIST"
150 echo "Centos distros: $CENTOS_DIST"
153 if test "${SUDO_USER}"; then
154 echo "Running as sudo."
155 echo "Tip: You can avoid it by adding the following in /etc/sudoers"
156 echo "${SUDO_USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
157 HOME_EXPORT=/home/${SUDO_USER}
162 if test ! -f ${HOME_EXPORT}/.pbuilderrc; then
163 echo "${HOME_EXPORT}/.pbuilderrc missing"
169 for dist in ${CENTOS_DIST}; do
171 prodver=${PRODUCT}-${VERSION}
172 if scp ${ID_DEB_BUILD}/../id-rpm-build/upload-rpms.sh ${dist}:rpmbuild/SOURCES/${prodver}/; then
175 echo "Copy of upload-rpms.sh to $dist failed"
178 if ssh $dist "cd rpmbuild/SOURCES/${prodver} && chmod +x upload-rpms.sh && ./upload-rpms.sh ${PRODUCT}.spec"; then
181 echo "Upload failed for $dist"
185 for dist in ${UBUNTU_DIST}; do
186 scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}
188 for dist in ${DEBIAN_DIST}; do
189 scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}
192 echo "===================================================="
193 echo "APT/YUM should be updated via cron every 15 minutes "
194 echo " from July 11 2013 and later."
195 echo "No need to call update archive on kebab"
196 echo "===================================================="
202 # copy tars to centos build hosts
203 for dist in ${CENTOS_DIST}; do
205 prodver=${PRODUCT}-${VERSION}
206 tarname=${prodver}.tar.gz
207 if test ! -f ../${tarname}; then
208 echo "$tarname: missing"
212 if ssh $dist "test -f .rpmmacros && test -d rpmbuild/SOURCES && test -d rpmbuild/RPMS && test -d rpmbuild/SRPMS"; then
215 echo "Host $dist does not seem to be prepared with rpmbuild directories"
219 if scp ../${tarname} $dist:rpmbuild/SOURCES/ ; then
222 echo "Could not copy $tarname to $dist"
225 if ssh $dist "cd rpmbuild/SOURCES && rm -fr $prodver && tar zxf $tarname && cd ${prodver} && rpmbuild -ba ${PRODUCT}.spec" >${dist}-${arch}.log 2>&1; then
228 echo "FAILED: See ${dist}-${arch}.log"
233 # call our privileged wrapper to clean the directories, no --dsc option
234 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
235 for arch in ${USE_ARCHS}; do
236 sudo -n $PBUILDROOT --home=${HOME_EXPORT} --dist=$dist --arch=$arch
237 if test $? -ne 0; then
239 echo "Run id-pbuild.sh using sudo or add yourself to /etc/sudoers:"
240 echo "${USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
246 # call our privileged wrapper to do the real work, with --dsc option
249 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
250 for arch in ${USE_ARCHS}; do
251 sudo -n $PBUILDROOT --home=${HOME_EXPORT} \
252 --dist=$dist --arch=$arch --dsc=$PKG >${dist}-${arch}.log 2>&1 &
254 if test $i -eq $concurrency; then
257 if test -f ${dist}-${arch}/*.dsc; then
260 echo "FAILED: No .dsc file for ${dist}-${arch}"
267 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
268 for arch in ${USE_ARCHS}; do
269 if test -f ${dist}-${arch}/*.dsc; then
272 echo "FAILED: No .dsc file for ${dist}-${arch}"