id-pbuild.sh builds for CentOS only
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 14 Mar 2013 10:38:01 +0000 (11:38 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 14 Mar 2013 10:38:01 +0000 (11:38 +0100)
if host system is not Debian/Ubuntu. Before, deb-src stuff
was required.

id-deb-build/id-pbuild.sh

index 004f892..ce96760 100755 (executable)
@@ -55,7 +55,7 @@ while test $# -gt 0; do
        -*)
            do_help=yes
            ;;
-    esac
+    esac 
     shift
 done
 
@@ -63,6 +63,12 @@ if test "$do_help" = "yes"; then
     usage 1 1>&2
 fi
 
+if test "$DEBIAN_DIST" -o "$UBUNTU_DIST"; then
+    debian=true
+else
+    debian=false
+fi
+
 D0=`dirname $0`
 ID_DEB_BUILD=`cd $D0; pwd`
 PBUILDROOT=${ID_DEB_BUILD}/id-pbuild-root.sh
@@ -80,60 +86,78 @@ fi
 if $upload; then
     :
 else
-    if test "${SUDO_USER}"; then
-       if test ! -d deb-src; then
+    if $debian; then
+       if test "${SUDO_USER}"; then
+           if test ! -d deb-src; then
+               $MKDEBSRC
+           fi
+       else
+           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
     else
-       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
+       mkdir -p deb-src
     fi
 fi
+
 cd deb-src
 
-for f in *.dsc; do
-    if test -f "$f"; then
-       PKG=$f
+if $debian; then
+    for f in *.dsc; do
+       if test -f "$f"; then
+           PKG=$f
+       fi
+    done
+    if test -z "$PKG"; then
+       echo "Specify .dsc file"
+       exit 1
+    fi
+    if test ! -e "$PKG"; then
+       echo "${PKG} does not exist"
+       exit 1
+    fi
+    if grep "Architecture: all" $PKG >/dev/null; then
+       USE_ARCHS=i386
+    else
+       USE_ARCHS=$ARCHS
     fi
-done
-if test -z "$PKG"; then
-    echo "Specify .dsc file"
-    exit 1
-fi
-if test ! -e "$PKG"; then
-    echo "${PKG} does not exist"
-    exit 1
 fi
+
 if test -z "$PRODUCT"; then
-    PRODUCT=`echo *.dsc|sed 's/_.*//g'`
+    PRODUCT=$NAME
 fi
-if grep "Architecture: all" $PKG >/dev/null; then
-    USE_ARCHS=i386
-else
-    USE_ARCHS=$ARCHS
+if test -z "$PRODUCT"; then
+    if $debian; then
+       PRODUCT=`echo *.dsc|sed 's/_.*//g'`
+    else
+       PRODUCT=`cd ..;rpm -q --specfile *.spec --queryformat "%{NAME};" | cut -d ";" -f1`
+    fi
 fi
 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
+
+if $debian; then
+    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
 fi
 
 if $upload; then