Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/git-tools
authorJakub Skoczen <jakub@indexdata.dk>
Wed, 7 Jul 2010 14:38:50 +0000 (16:38 +0200)
committerJakub Skoczen <jakub@indexdata.dk>
Wed, 7 Jul 2010 14:38:50 +0000 (16:38 +0200)
id-rpm-build/upload-rpms.sh [new file with mode: 0755]

diff --git a/id-rpm-build/upload-rpms.sh b/id-rpm-build/upload-rpms.sh
new file mode 100755 (executable)
index 0000000..4f952f1
--- /dev/null
@@ -0,0 +1,47 @@
+BUILD_DIR=${BUILD_DIR:=/usr/src/redhat/}
+PWD=`pwd`
+UPLOAD_PATH=${UPLOAD_PATH:=/home/ftp/pub}
+UPLOAD_HOST=${UPLOAD_HOST:=flurry}
+UPLOAD_DIR=${UPLOAD_DIR:=`basename $PWD`}
+UPLOAD_URI=${UPLOAD_HOST}:${UPLOAD_PATH}/${UPLOAD_DIR}
+DISTRO=${DISTRO:="centos/5.5"}
+project=`basename $PWD`
+if test ! -f ${project}.spec; then
+       echo "Missing ${project}.spec file. Are you in the project directory?"
+       exit 1
+fi
+if test ! -x /bin/rpm; then
+        echo "$0: /bin/rpm missing. Install rpm"
+        exit 1
+fi
+pkg_names=`rpm -q --specfile ${project}.spec`
+inc_src=true
+if test ! -d ${BUILD_DIR}/SRPMS; then 
+       echo "No SRPMS dir under ${BUILD_DIR}"
+       inc_src=false
+fi
+inc_bin=true
+if test ! -d ${BUILD_DIR}/RPMS; then 
+       echo "No RPMS dir under ${BUILD_DIR}"
+       inc_bin=false
+fi
+
+for pkg in ${pkg_names}; do
+       if $inc_src; then
+               if test ! -f ${BUILD_DIR}/SRPMS/${pkg}.src.rpm; then
+                       echo "No SRPM for ${pkg}"
+               else
+                       scp ${BUILD_DIR}/SRPMS/${pkg}.src.rpm ${UPLOAD_URI}/redhat/${DISTRO}/SRPMS/
+               fi      
+       fi  
+       if $inc_bin; then
+               for dir in ${BUILD_DIR}/RPMS/*; do
+                       arch=`basename ${dir}`
+                       if test -f ${dir}/${pkg}.${arch}.rpm; then
+                               scp ${dir}/${pkg}.${arch}.rpm ${UPLOAD_URI}/redhat/${DISTRO}/RPMS/${arch}/
+                       else
+                               echo "No ${pkg} in arch ${arch}"
+                       fi
+               done
+       fi
+done