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
67 ID_DEB_BUILD=`cd $D0; pwd`
68 PBUILDROOT=${ID_DEB_BUILD}/id-pbuild-root.sh
69 if test ! -x $PBUILDROOT; then
70 echo "$PBUILDROOT not found"
74 MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh
75 if test ! -x $MKDEBSRC; then
76 echo "$MKDEBSRC not found"
83 if test "${SUDO_USER}"; then
84 if test ! -d deb-src; then
88 if test -d deb-src; then
90 if test $? -ne 0; then
91 echo "deb-src could not be removed. Remove deb-src manually"
101 if test -f "$f"; then
105 if test -z "$PKG"; then
106 echo "Specify .dsc file"
109 if test ! -e "$PKG"; then
110 echo "${PKG} does not exist"
113 if test -z "$PRODUCT"; then
114 PRODUCT=`echo *.dsc|sed 's/_.*//g'`
116 if grep "Architecture: all" $PKG >/dev/null; then
121 echo "Dsc $PKG . Product $PRODUCT"
122 echo "Ubuntu distros: $UBUNTU_DIST"
123 echo "Debian distros: $DEBIAN_DIST"
124 echo "Centos distros: $CENTOS_DIST"
125 if test "${SUDO_USER}"; then
126 echo "Running as sudo."
127 echo "Tip: You can avoid it by adding the following in /etc/sudoers"
128 echo "${SUDO_USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
129 HOME_EXPORT=/home/${SUDO_USER}
134 if test ! -f ${HOME_EXPORT}/.pbuilderrc; then
135 echo "${HOME_EXPORT}/.pbuilderrc missing"
140 for dist in ${CENTOS_DIST}; do
142 prodver=${PRODUCT}-${VERSION}
143 if ssh $dist "cd rpmbuild/SOURCES/${prodver} && ../../../proj/git-tools/id-rpm-build/upload-rpms.sh ${PRODUCT}.spec"; then
146 echo "Upload failed for $dist"
150 for dist in ${UBUNTU_DIST}; do
151 scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}
153 for dist in ${DEBIAN_DIST}; do
154 scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}
157 echo "===================================================="
158 echo "Remember to update APT/YUM on ftp.indexdata.dk !!!"
160 echo "ssh ftp.indexdata.dk"
161 echo "cd ~/proj/git-tools/update-archive"
163 echo "./update-archive.sh"
164 if test "${CENTOS_DIST}"; then
165 echo "./update-yum-archive.sh"
167 echo "===================================================="
173 # copy tars to centos build hosts
174 for dist in ${CENTOS_DIST}; do
176 prodver=${PRODUCT}-${VERSION}
177 tarname=${prodver}.tar.gz
178 if test ! -f ../${tarname}; then
179 echo "$tarname: missing"
183 if ssh $dist "test -f .rpmmacros && test -d rpmbuild/SOURCES && test -d rpmbuild/RPMS && test -d rpmbuild/SRPMS && test -x proj/git-tools/id-rpm-build/upload-rpms.sh"; then
186 echo "Host $dist does not seem to be prepared with git-tools and rpmbuild directories"
190 if scp ../${tarname} $dist:rpmbuild/SOURCES/ ; then
193 echo "Could not copy $tarname to $dist"
196 if ssh $dist "cd rpmbuild/SOURCES && rm -fr $prodver && tar zxf $tarname && cd ${prodver} && rpmbuild -ba ${PRODUCT}.spec" >${dist}-${arch}.log 2>&1; then
199 echo "FAILED: See ${dist}-${arch}.log"
204 # call our privileged wrapper to clean the directories, no --dsc option
205 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
206 for arch in ${USE_ARCHS}; do
207 sudo -n $PBUILDROOT --home=${HOME_EXPORT} --dist=$dist --arch=$arch
208 if test $? -ne 0; then
210 echo "Run id-pbuild.sh using sudo or add yourself to /etc/sudoers:"
211 echo "${USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
217 # call our privileged wrapper to do the real work, with --dsc option
220 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
221 for arch in ${USE_ARCHS}; do
222 sudo -n $PBUILDROOT --home=${HOME_EXPORT} \
223 --dist=$dist --arch=$arch --dsc=$PKG >${dist}-${arch}.log 2>&1 &
225 if test $i -eq $concurrency; then
228 if test -f ${dist}-${arch}/*.dsc; then
231 echo "FAILED: No .dsc file for ${dist}-${arch}"
238 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
239 for arch in ${USE_ARCHS}; do
240 if test -f ${dist}-${arch}/*.dsc; then
243 echo "FAILED: No .dsc file for ${dist}-${arch}"