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]*=//'` ;;
62 if test "$do_help" = "yes"; then
66 if test "$DEBIAN_DIST" -o "$UBUNTU_DIST"; then
73 ID_DEB_BUILD=`cd $D0; pwd`
74 PBUILDROOT=${ID_DEB_BUILD}/id-pbuild-root.sh
75 if test ! -x $PBUILDROOT; then
76 echo "$PBUILDROOT not found"
80 MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh
81 if test ! -x $MKDEBSRC; then
82 echo "$MKDEBSRC not found"
90 if test "${SUDO_USER}"; then
91 if test ! -d deb-src; then
95 if test -d deb-src; then
97 if test $? -ne 0; then
98 echo "deb-src could not be removed. Remove deb-src manually"
113 if test -f "$f"; then
117 if test -z "$PKG"; then
118 echo "Specify .dsc file"
121 if test ! -e "$PKG"; then
122 echo "${PKG} does not exist"
125 if grep "Architecture: all" $PKG >/dev/null; then
132 if test -z "$PRODUCT"; then
135 if test -z "$PRODUCT"; then
137 PRODUCT=`echo *.dsc|sed 's/_.*//g'`
139 PRODUCT=`cd ..;rpm -q --specfile *.spec --queryformat "%{NAME};" | cut -d ";" -f1`
142 echo "Dsc $PKG . Product $PRODUCT"
143 echo "Ubuntu distros: $UBUNTU_DIST"
144 echo "Debian distros: $DEBIAN_DIST"
145 echo "Centos distros: $CENTOS_DIST"
148 if test "${SUDO_USER}"; then
149 echo "Running as sudo."
150 echo "Tip: You can avoid it by adding the following in /etc/sudoers"
151 echo "${SUDO_USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
152 HOME_EXPORT=/home/${SUDO_USER}
157 if test ! -f ${HOME_EXPORT}/.pbuilderrc; then
158 echo "${HOME_EXPORT}/.pbuilderrc missing"
164 for dist in ${CENTOS_DIST}; do
166 prodver=${PRODUCT}-${VERSION}
167 if scp ${ID_DEB_BUILD}/../id-rpm-build/upload-rpms.sh ${dist}:rpmbuild/SOURCES/${prodver}/; then
170 echo "Copy of upload-rpms.sh to $dist failed"
173 if ssh $dist "cd rpmbuild/SOURCES/${prodver} && chmod +x upload-rpms.sh && ./upload-rpms.sh ${PRODUCT}.spec"; then
176 echo "Upload failed for $dist"
180 for dist in ${UBUNTU_DIST}; do
181 scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}
183 for dist in ${DEBIAN_DIST}; do
184 scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}
187 echo "===================================================="
188 echo "Remember to update APT/YUM on ftp.indexdata.dk !!!"
190 echo "ssh ftp.indexdata.dk"
191 echo "cd ~/proj/git-tools/update-archive"
193 echo "./update-archive.sh"
194 if test "${CENTOS_DIST}"; then
195 echo "./update-yum-archive.sh"
197 echo "===================================================="
203 # copy tars to centos build hosts
204 for dist in ${CENTOS_DIST}; do
206 prodver=${PRODUCT}-${VERSION}
207 tarname=${prodver}.tar.gz
208 if test ! -f ../${tarname}; then
209 echo "$tarname: missing"
213 if ssh $dist "test -f .rpmmacros && test -d rpmbuild/SOURCES && test -d rpmbuild/RPMS && test -d rpmbuild/SRPMS"; then
216 echo "Host $dist does not seem to be prepared with rpmbuild directories"
220 if scp ../${tarname} $dist:rpmbuild/SOURCES/ ; then
223 echo "Could not copy $tarname to $dist"
226 if ssh $dist "cd rpmbuild/SOURCES && rm -fr $prodver && tar zxf $tarname && cd ${prodver} && rpmbuild -ba ${PRODUCT}.spec" >${dist}-${arch}.log 2>&1; then
229 echo "FAILED: See ${dist}-${arch}.log"
234 # call our privileged wrapper to clean the directories, no --dsc option
235 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
236 for arch in ${USE_ARCHS}; do
237 sudo -n $PBUILDROOT --home=${HOME_EXPORT} --dist=$dist --arch=$arch
238 if test $? -ne 0; then
240 echo "Run id-pbuild.sh using sudo or add yourself to /etc/sudoers:"
241 echo "${USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
247 # call our privileged wrapper to do the real work, with --dsc option
250 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
251 for arch in ${USE_ARCHS}; do
252 sudo -n $PBUILDROOT --home=${HOME_EXPORT} \
253 --dist=$dist --arch=$arch --dsc=$PKG >${dist}-${arch}.log 2>&1 &
255 if test $i -eq $concurrency; then
258 if test -f ${dist}-${arch}/*.dsc; then
261 echo "FAILED: No .dsc file for ${dist}-${arch}"
268 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
269 for arch in ${USE_ARCHS}; do
270 if test -f ${dist}-${arch}/*.dsc; then
273 echo "FAILED: No .dsc file for ${dist}-${arch}"