Add RPM upload script
authorJakub Skoczen <jakub@indexdata.dk>
Wed, 7 Jul 2010 09:38:16 +0000 (05:38 -0400)
committerJakub Skoczen <jakub@indexdata.dk>
Wed, 7 Jul 2010 09:38:16 +0000 (05:38 -0400)
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..471d249
--- /dev/null
@@ -0,0 +1,47 @@
+BUILD_DIR=/usr/src/redhat/
+PWD=`pwd`
+UPLOAD_PATH=/home/ftp/pub
+UPLOAD_HOST=flurry
+UPLOAD_DIR=`basename $PWD`
+UPLOAD_URI=${UPLOAD_HOST}:${UPLOAD_PATH}/${UPLOAD_DIR}
+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