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]*=//'` ;;
60 if test $DEBIAN_DIST_A -o $UBUNTU_DIST_A -o $CENTOS_DIST_A; then
61 DEBIAN_DIST=$DEBIAN_DIST_A
62 UBUNTU_DIST=$UBUNTU_DIST_A
63 CENTOS_DIST=$CENTOS_DIST_A
66 if test "$do_help" = "yes"; then
70 if test "$DEBIAN_DIST" -o "$UBUNTU_DIST"; then
77 ID_DEB_BUILD=`cd $D0; pwd`
78 PBUILDROOT=${ID_DEB_BUILD}/id-pbuild-root.sh
79 if test ! -x $PBUILDROOT; then
80 echo "$PBUILDROOT not found"
84 MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh
85 if test ! -x $MKDEBSRC; then
86 echo "$MKDEBSRC not found"
94 if test "${SUDO_USER}"; then
95 if test ! -d deb-src; then
99 if test -d deb-src; then
101 if test $? -ne 0; then
102 echo "deb-src could not be removed. Remove deb-src manually"
117 if test -f "$f"; then
121 if test -z "$PKG"; then
122 echo "Specify .dsc file"
125 if test ! -e "$PKG"; then
126 echo "${PKG} does not exist"
129 if grep "Architecture: all" $PKG >/dev/null; then
136 if test -z "$PRODUCT"; then
139 if test -z "$PRODUCT"; then
141 PRODUCT=`echo *.dsc|sed 's/_.*//g'`
143 PRODUCT=`cd ..;rpm -q --specfile *.spec --queryformat "%{NAME};" | cut -d ";" -f1`
146 echo "Dsc $PKG . Product $PRODUCT"
147 echo "Ubuntu distros: $UBUNTU_DIST"
148 echo "Debian distros: $DEBIAN_DIST"
149 echo "Centos distros: $CENTOS_DIST"
152 if test "${SUDO_USER}"; then
153 echo "Running as sudo."
154 echo "Tip: You can avoid it by adding the following in /etc/sudoers"
155 echo "${SUDO_USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
156 HOME_EXPORT=/home/${SUDO_USER}
161 if test ! -f ${HOME_EXPORT}/.pbuilderrc; then
162 echo "${HOME_EXPORT}/.pbuilderrc missing"
168 for dist in ${CENTOS_DIST}; do
170 prodver=${PRODUCT}-${VERSION}
171 if scp ${ID_DEB_BUILD}/../id-rpm-build/upload-rpms.sh ${dist}:rpmbuild/SOURCES/${prodver}/; then
174 echo "Copy of upload-rpms.sh to $dist failed"
177 if ssh $dist "cd rpmbuild/SOURCES/${prodver} && chmod +x upload-rpms.sh && ./upload-rpms.sh ${PRODUCT}.spec"; then
180 echo "Upload failed for $dist"
184 for dist in ${UBUNTU_DIST}; do
185 scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}
187 for dist in ${DEBIAN_DIST}; do
188 scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}
191 echo "===================================================="
192 echo "APT/YUM should be updated via cron every 15 minutes "
193 echo " from July 11 2013 and later."
194 echo "No need to call update archive on kebab"
195 echo "===================================================="
201 # copy tars to centos build hosts
202 for dist in ${CENTOS_DIST}; do
204 prodver=${PRODUCT}-${VERSION}
205 tarname=${prodver}.tar.gz
206 if test ! -f ../${tarname}; then
207 echo "$tarname: missing"
211 if ssh $dist "test -f .rpmmacros && test -d rpmbuild/SOURCES && test -d rpmbuild/RPMS && test -d rpmbuild/SRPMS"; then
214 echo "Host $dist does not seem to be prepared with rpmbuild directories"
218 if scp ../${tarname} $dist:rpmbuild/SOURCES/ ; then
221 echo "Could not copy $tarname to $dist"
224 if ssh $dist "cd rpmbuild/SOURCES && rm -fr $prodver && tar zxf $tarname && cd ${prodver} && rpmbuild -ba ${PRODUCT}.spec" >${dist}-${arch}.log 2>&1; then
227 echo "FAILED: See ${dist}-${arch}.log"
232 # call our privileged wrapper to clean the directories, no --dsc option
233 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
234 for arch in ${USE_ARCHS}; do
235 sudo -n $PBUILDROOT --home=${HOME_EXPORT} --dist=$dist --arch=$arch
236 if test $? -ne 0; then
238 echo "Run id-pbuild.sh using sudo or add yourself to /etc/sudoers:"
239 echo "${USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
245 # call our privileged wrapper to do the real work, with --dsc option
248 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
249 for arch in ${USE_ARCHS}; do
250 sudo -n $PBUILDROOT --home=${HOME_EXPORT} \
251 --dist=$dist --arch=$arch --dsc=$PKG >${dist}-${arch}.log 2>&1 &
253 if test $i -eq $concurrency; then
256 if test -f ${dist}-${arch}/*.dsc; then
259 echo "FAILED: No .dsc file for ${dist}-${arch}"
266 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
267 for arch in ${USE_ARCHS}; do
268 if test -f ${dist}-${arch}/*.dsc; then
271 echo "FAILED: No .dsc file for ${dist}-${arch}"