usage()
{
cat <<EOF
-Usage: id-pbuild-all.sh [OPTIONS]
+Usage: id-pbuild.sh [OPTIONS]
Options:
[--debian=distros]
[--ubuntu=distros]
+ [--centos=distros]
[--upload]
[--concurrency=N]
[--product=X]
upload=false
do_help=false
concurrency=4
+ARCHS="i386 amd64"
if test -f IDMETA; then
. ./IDMETA
--ubuntu=*)
UBUNTU_DIST=$optarg
;;
+ --centos=*)
+ CENTOS_DIST=$optarg
+ ;;
--upload)
upload=true
;;
--product=*)
PRODUCT=$optarg
;;
- --remote=*)
- REMOTE=$optarg
- ;;
-*)
do_help=yes
;;
usage 1 1>&2
fi
-if test "$REMOTE"; then
- if test ! -d deb-src; then
- echo "deb-src not in current directory"
- exit 1
- fi
- cd deb-src
- PRODUCT=`echo *.dsc|sed 's/_.*//g'`
- cd ..
- ssh $REMOTE "mkdir -p $PRODUCT/deb-src"
- scp IDMETA $REMOTE:$PRODUCT
- scp deb-src/*.gz deb-src/*.dsc $REMOTE:$PRODUCT/deb-src
- if $upload; then
- ssh $REMOTE "cd $PRODUCT; \$HOME/proj/git-tools/id-deb-build/id-pbuild.sh --upload"
+D0=`dirname $0`
+ID_DEB_BUILD=`cd $D0; pwd`
+PBUILDROOT=${ID_DEB_BUILD}/id-pbuild-root.sh
+if test ! -x $PBUILDROOT; then
+ echo "$PBUILDROOT not found"
+ exit 1
+fi
+
+MKDEBSRC=${ID_DEB_BUILD}/id-mk-deb-src.sh
+if test ! -x $MKDEBSRC; then
+ echo "$MKDEBSRC not found"
+ exit 1
+fi
+
+if $upload; then
+ :
+else
+ if test "${SUDO_USER}"; then
+ if test ! -d deb-src; then
+ $MKDEBSRC
+ fi
else
- ssh $REMOTE "cd $PRODUCT; sudo \$HOME/proj/git-tools/id-deb-build/id-pbuild.sh"
+ if test -d deb-src; then
+ rm -f deb-src/*.gz
+ if test $? -ne 0; then
+ echo "deb-src could not be removed. Remove deb-src manually"
+ exit 1
+ fi
+ fi
+ $MKDEBSRC
fi
- exit 0
-fi
-if test -d deb-src; then
- cd deb-src
fi
+cd deb-src
+
for f in *.dsc; do
if test -f "$f"; then
PKG=$f
echo "${PKG} does not exist"
exit 1
fi
-PBUILDER=/usr/sbin/pbuilder
if test -z "$PRODUCT"; then
- PRODUCT=`echo *.dsc|sed 's/_.*//g'`
+ PRODUCT=`echo *.dsc|sed 's/_.*//g'`
fi
-ARCHS="i386 amd64"
if grep "Architecture: all" $PKG >/dev/null; then
USE_ARCHS=i386
else
echo "Dsc $PKG . Product $PRODUCT"
echo "Ubuntu distros: $UBUNTU_DIST"
echo "Debian distros: $DEBIAN_DIST"
+echo "Centos distros: $CENTOS_DIST"
+if test "${SUDO_USER}"; then
+ echo "Running as sudo."
+ echo "Tip: You can avoid it by adding the following in /etc/sudoers"
+ echo "${SUDO_USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
+ HOME_EXPORT=/home/${SUDO_USER}
+else
+ sudo -k
+ HOME_EXPORT=$HOME
+fi
+if test ! -f ${HOME_EXPORT}/.pbuilderrc; then
+ echo "${HOME_EXPORT}/.pbuilderrc missing"
+ exit 1
+fi
+
if $upload; then
+ for dist in ${CENTOS_DIST}; do
+ arch=amd64
+ prodver=${PRODUCT}-${VERSION}
+ if ssh $dist "cd rpmbuild/SOURCES/${prodver} && ../../../proj/git-tools/id-rpm-build/upload-rpms.sh ${PRODUCT}.spec"; then
+ :
+ else
+ echo "Upload failed for $dist"
+ exit 1
+ fi
+ done
for dist in ${UBUNTU_DIST}; do
scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}
done
done
echo ""
echo "===================================================="
- echo "Remember to update APT on ftp.indexdata.dk !!!"
+ echo "Remember to update APT/YUM on ftp.indexdata.dk !!!"
echo ""
echo "ssh ftp.indexdata.dk"
echo "cd ~/proj/git-tools/update-archive"
echo "sudo su"
echo "./update-archive.sh"
+ if test ${CENTOS_DIST}; then
+ echo "./update-yum-archive.sh"
+ fi
echo "===================================================="
exit 0
fi
-# remove existing package directories
-for f in [a-z]*; do
- if test -d $f; then
- rm -fr $f
+
+rm -f *.log
+
+# copy tars to centos build hosts
+for dist in ${CENTOS_DIST}; do
+ arch=amd64
+ prodver=${PRODUCT}-${VERSION}
+ tarname=${prodver}.tar.gz
+ if test ! -f ../${tarname}; then
+ echo "$tarname: missing"
+ exit 1
+ fi
+
+ 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
+ :
+ else
+ echo "Host $dist does not seem to be prepared with git-tools and rpmbuild directories"
+ exit 1
+ fi
+
+ if scp ../${tarname} $dist:rpmbuild/SOURCES/ ; then
+ :
+ else
+ echo "Could not copy $tarname to $dist"
+ exit 1
+ fi
+ if ssh $dist "cd rpmbuild/SOURCES && rm -fr $prodver && tar zxf $tarname && cd ${prodver} && rpmbuild -ba ${PRODUCT}.spec" >${dist}-${arch}.log 2>&1; then
+ :
+ else
+ echo "FAILED: See ${dist}-${arch}.log"
+ exit 1
fi
done
-rm -f *.log
+# call our privileged wrapper to clean the directories, no --dsc option
+for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
+ for arch in ${USE_ARCHS}; do
+ sudo -n $PBUILDROOT --home=${HOME_EXPORT} --dist=$dist --arch=$arch
+ if test $? -ne 0; then
+ echo "FAILED"
+ echo "Run id-pbuild.sh using sudo or add yourself to /etc/sudoers:"
+ echo "${USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
+ exit 1
+ fi
+ done
+done
+
+# call our privileged wrapper to do the real work, with --dsc option
i=0
date
-
for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
for arch in ${USE_ARCHS}; do
- rm -fr ${dist}-${arch}
- (
- if test ! -f /var/cache/pbuilder/${dist}-${arch}-base.tgz; then
- DIST=$dist ARCH=$arch $PBUILDER create
- fi
- DIST=$dist ARCH=$arch $PBUILDER update --override-config
- DIST=$dist ARCH=$arch $PBUILDER --build $PKG
- ) >${dist}-${arch}.log 2>&1 &
+ sudo -n $PBUILDROOT --home=${HOME_EXPORT} \
+ --dist=$dist --arch=$arch --dsc=$PKG >${dist}-${arch}.log 2>&1 &
i=`expr $i + 1`
if test $i -eq $concurrency; then
i=0
wait
+ if test -f ${dist}-${arch}/*.dsc; then
+ :
+ else
+ echo "FAILED: No .dsc file for ${dist}-${arch}"
+ exit 1
+ fi
fi
done
done
if test -f ${dist}-${arch}/*.dsc; then
:
else
- echo "No .dsc file for ${dist}-${arch}"
+ echo "FAILED: No .dsc file for ${dist}-${arch}"
exit 1
fi
done
done
+
date
echo "Done"
# Local Variables: