Allow overriding vars
[git-tools-moved-to-github.git] / id-rpm-build / upload-rpms.sh
1 BUILD_DIR=${BUILD_DIR:=/usr/src/redhat/}
2 PWD=`pwd`
3 UPLOAD_PATH=${UPLOAD_PATH:=/home/ftp/pub}
4 UPLOAD_HOST=${UPLOAD_HOST:=flurry}
5 UPLOAD_DIR=${UPLOAD_DIR:=`basename $PWD`}
6 UPLOAD_URI=${UPLOAD_HOST}:${UPLOAD_PATH}/${UPLOAD_DIR}
7 DISTRO=${DISTRO:="centos/5.5"}
8 project=`basename $PWD`
9 if test ! -f ${project}.spec; then
10         echo "Missing ${project}.spec file. Are you in the project directory?"
11         exit 1
12 fi
13 if test ! -x /bin/rpm; then
14         echo "$0: /bin/rpm missing. Install rpm"
15         exit 1
16 fi
17 pkg_names=`rpm -q --specfile ${project}.spec`
18 inc_src=true
19 if test ! -d ${BUILD_DIR}/SRPMS; then 
20         echo "No SRPMS dir under ${BUILD_DIR}"
21         inc_src=false
22 fi
23 inc_bin=true
24 if test ! -d ${BUILD_DIR}/RPMS; then 
25         echo "No RPMS dir under ${BUILD_DIR}"
26         inc_bin=false
27 fi
28
29 for pkg in ${pkg_names}; do
30         if $inc_src; then
31                 if test ! -f ${BUILD_DIR}/SRPMS/${pkg}.src.rpm; then
32                         echo "No SRPM for ${pkg}"
33                 else
34                         scp ${BUILD_DIR}/SRPMS/${pkg}.src.rpm ${UPLOAD_URI}/redhat/${DISTRO}/SRPMS/
35                 fi      
36         fi  
37         if $inc_bin; then
38                 for dir in ${BUILD_DIR}/RPMS/*; do
39                         arch=`basename ${dir}`
40                         if test -f ${dir}/${pkg}.${arch}.rpm; then
41                                 scp ${dir}/${pkg}.${arch}.rpm ${UPLOAD_URI}/redhat/${DISTRO}/RPMS/${arch}/
42                         else
43                                 echo "No ${pkg} in arch ${arch}"
44                         fi
45                 done
46         fi
47 done