source: MondoRescue/branches/2.06/tools/mkrpm @ 318

Last change on this file since 318 was 318, checked in by bcornec, 15 years ago
  • spec files are now under distributions as well
  • rpm build process revised accordingly
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 4.4 KB
Line 
1#!/bin/bash
2#
3# Creates RPMs packages from SVN repository for local tests
4#
5# $Id: mkrpm 318 2006-01-14 09:45:10Z bcornec $
6#
7
8umask 022
9dname=`dirname $0`
10prem=`echo $dname |cut -c1`
11if [ ${prem} == "/" ]; then
12    export TOOLHOME=$dname
13else
14    export TOOLHOME=${PWD}/$dname
15fi
16
17. $TOOLHOME/rpm-env
18
19# To be safe for SVN commands
20cd $TOOLHOME/..
21rev=`$TOOLHOME/mksvnversion`
22
23echo "Generating SVN log file ..."
24svn log -v > /tmp/mondorescue-svn.log
25
26if [ "$1" = "" ]; then
27    c="mindi mondo"
28else
29    c=$1
30fi
31if [ "`echo $c | grep mindi-kernel`" != "" ]; then
32    cd ${BASE}/svn
33    echo "Management of mindi-kernel ${MINDI_VER}-$rev"
34    rm -fr mindi-kernel-${MINDI_VER}
35    cp -a ${VER}/mindi-kernel mindi-kernel-${MINDI_VER}
36    find mindi-kernel-${MINDI_VER} -type d -name .svn | xargs rm -rf
37    find mindi-kernel-${MINDI_VER} -type f -name '.*.swp' | xargs rm -rf
38    find mindi-kernel-${MINDI_VER} -type f -name '*~' | xargs rm -rf
39    mkdir -p ${TOPDIR}/SOURCES
40
41    echo "Creating mindi-kernel tar files"
42    tar cvfhz ${TOPDIR}/SOURCES/mindi-kernel-${MINDI_VER}.tgz mindi-kernel-${MINDI_VER}
43    tar cvfhj ${TOPDIR}/SOURCES/mindi-kernel-${MINDI_VER}.tar.bz2 mindi-kernel-${MINDI_VER}
44    sed "s/^%define mrel..*RRR/%define mrel ${rev}${suf}/" mindi-kernel-${MINDI_VER}/mindi-kernel.spec > ${TOPDIR}/SPECS/mindi-kernel.spec
45    rm -f ${TMP}/mindi-kernel*-root
46    pkg="$pkg ${TOPDIR}/RPMS/${ARCH}/mindi-kernel-${MINDI_VER}-${rev}${suf}.${ARCH}.rpm"
47fi
48if [ "`echo $c | grep -v kernel | grep mindi`" != "" ]; then
49    cd ${BASE}/svn
50    echo "Management of mindi ${MINDI_VER}-$rev"
51    rm -fr mindi-${MINDI_VER}
52    cp -a ${VER}/mindi mindi-${MINDI_VER}
53    cp -a /tmp/mondorescue-svn.log mindi-${MINDI_VER}/svn.log
54    find mindi-${MINDI_VER} -type d -name .svn | xargs rm -rf
55    find mindi-${MINDI_VER} -type f -name '.*.swp' | xargs rm -rf
56    find mindi-${MINDI_VER} -type f -name '*~' | xargs rm -rf
57    if [ -f mindi-${MINDI_VER}/distributions/${ddir}/mindi.spec ]; then
58        specfile=mindi-${MINDI_VER}/distributions/${ddir}/mindi.spec
59    else
60        specfile=mindi-${MINDI_VER}/distributions/common/mindi.spec
61    fi
62    sed -e "s/^%define mrel..*RRR/%define mrel  ${rev}${suf}/" -e "s/VVV/${MINDI_VER}/" $specfile > ${TOPDIR}/SPECS/mindi.spec
63    rm -rf mindi-${MINDI_VER}/distributions
64    rm -f mindi-${MINDI_VER}/parted2fdisk mindi-${MINDI_VER}/parted2fdisk.c mindi-${MINDI_VER}/rootfs/sbin/parted2fdisk-ia64
65    mkdir -p ${TOPDIR}/SOURCES
66
67    echo "Creating mindi tar files"
68    tar cfhz ${TOPDIR}/SOURCES/mindi-${MINDI_VER}.tgz mindi-${MINDI_VER}
69    tar cfhj ${TOPDIR}/SOURCES/mindi-${MINDI_VER}.tar.bz2 mindi-${MINDI_VER}
70    rm -f ${TMP}/mindi-*-root
71    pkg="$pkg ${TOPDIR}/RPMS/${ARCH}/mindi-${MINDI_VER}-${rev}${suf}.${ARCH}.rpm"
72    # ATTENTION: This could be dangerous for your setup
73    opt="rm -rf /usr/lib/mindi ;"
74fi
75if [ "`echo $c | grep  mondo`" != "" ]; then
76    cd ${BASE}/svn
77    echo "Management of mondo ${MONDO_VER}-$rev"
78    rm -rf mondo-${MONDO_VER}
79    cp -a ${VER}/mondo mondo-${MONDO_VER}
80    cp -a /tmp/mondorescue-svn.log mondo-${MONDO_VER}/svn.log
81    cd mondo-${MONDO_VER}
82    echo "Bootstraping mondo ... "
83    ./bootstrap
84    find . -type d -name .svn | xargs rm -rf
85    find . -type f -name '.*.swp' | xargs rm -rf
86    find . -type f -name '*~' | xargs rm -rf
87    cd ..
88    if [ -f mondo-${MONDO_VER}/distributions/${ddir}/mondo.spec ]; then
89        specfile=mondo-${MONDO_VER}/distributions/${ddir}/mondo.spec
90    else
91        specfile=mondo-${MONDO_VER}/distributions/common/mondo.spec
92    fi
93    sed -e "s/^%define mrel..*RRR/%define mrel  ${rev}${suf}/" -e "s/VVV/${MONDO_VER}/" $specfile > ${TOPDIR}/SPECS/mondo.spec
94    rm -rf mondo-${MONDO_VER}/distributions
95
96    echo "Creating mondo tar files"
97    tar cfhz ${TOPDIR}/SOURCES/mondo-${MONDO_VER}.tgz mondo-${MONDO_VER}
98    tar cfhj ${TOPDIR}/SOURCES/mondo-${MONDO_VER}.tar.bz2 mondo-${MONDO_VER}
99    rm -f ${TMP}/mondo-*-root
100    pkg="$pkg ${TOPDIR}/RPMS/${ARCH}/mondo-${MONDO_VER}-${rev}${suf}.${ARCH}.rpm"
101fi
102cd ${TOPDIR}/SPECS
103status=0
104if [ "`echo $c | grep kernel`" != "" ]; then
105    echo "Generating mindi-kernel RPMS"
106    log=/tmp/mindi-kernel-rpm.log
107    rpmbuild -ba mindi-kernel.spec 2> $log 1> $log
108    if [ $? != 0 ]; then 
109        cat $log
110        status=-1
111    fi
112fi
113if [ "`echo $c | grep -v kernel | grep mindi`" != "" ]; then
114    echo "Generating mindi RPMS"
115    log=/tmp/mindi-rpm.log
116    rpmbuild -ba mindi.spec 2> $log 1> $log
117    if [ $? != 0 ]; then
118        cat $log
119        status=-1
120    fi
121fi
122if [ "`echo $c | grep mondo`" != "" ]; then
123    echo "Generating mondo RPMS"
124    log=/tmp/mondo-rpm.log
125    rpmbuild -ba mondo.spec 2> $log 1> $log
126    if [ $? != 0 ]; then 
127        cat $log
128        status=-1
129    fi
130fi
131if [ $status = 0 ]; then
132    echo "Installing RPMS as root ($pkg)"
133    su - -c "$opt rpm -Uvh --force $pkg"
134fi
Note: See TracBrowser for help on using the repository browser.