source: soft/build_system/build_system/upload/robot/trunk/cvcp @ 1

Last change on this file since 1 was 1, checked in by fasma, 12 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 4.9 KB
Line 
1#!/bin/sh
2#---------------------------------------------------------------
3# Project         : Mandrake Linux
4# Module          : robot
5# File            : cvcp
6# Version         : $Id: cvcp 873 2004-07-27 02:21:33Z mandrake $
7# Author          : Frederic Lepied
8# Created On      : Thu Dec  9 10:21:00 1999
9#---------------------------------------------------------------
10
11CVS_RSH=ssh
12export CVS_RSH
13
14# parse options
15
16usage() {
17    echo "usage: `basename $0` [-dnc] [-u <updatetag>] <srpm files>"
18    echo "-d Delete logfile"
19    echo "-n Nocommit"
20    echo "-c Contrib"
21    echo "-C clean spec dir before action"
22    echo "-u <updatetag> commit in a branch named <updatetag> and create the branch if it doesn't exist"
23}
24   
25while [ -n "$*" ]; do
26    case $1 in
27# -d Delete logfile
28    -d) dellog=1;;
29# -n Nocommit
30    -n) doit=echo;;
31# -c Contrib
32    -c) contrib=1;;
33# -C remove spec dir before any action
34    -C) remove=1;;
35# -u create a branch
36    -u) shift; update=$1; LOG="`dirname $LOG`/$update-`basename $LOG`";;
37# invalid option
38    -*) echo "invalid option $o"; usage $0; exit 1;;
39# last option usually the file :)
40    *) break;;
41    esac
42    shift
43done
44
45if [ $# = 0 -o ! -r "$1" ]; then
46    echo "I need one srpm"
47    exit 1
48fi
49
50case `/bin/hostname` in
51    vador*|kenobi*|ken*)
52        if [ -n "$contrib" ]; then
53            CVS='/C/contrib-SPECS/'
54            LOG=$HOME/cvcp-contrib.log
55        else
56            CVS='/C/SPECS/'
57            LOG=$HOME/cvcp.log
58        fi
59        ;;
60    *.netpirate.org)
61        if [ -n "$contrib" ]; then
62            CVS='/C/mandrake/contrib-SPECS/'
63        else
64            CVS='/C/mandrake/SPECS/'
65        fi
66        LOG='/home/stoned/buildlog/cvcp.log'
67        ;;
68    *)
69        if [ -n "$contrib" ]; then
70            CVS=$HOME/contrib-SPECS/
71            LOG=$HOME/cvcp-contrib.log
72        else
73            CVS=$HOME/SPECS/
74            LOG=$HOME/cvcp.log
75        fi
76        ;;
77esac
78
79orig=`pwd`
80
81if [ ! -d $CVS/CVS ]; then
82    echo "you must have a copy of the current SPECS tree"
83    echo "with a command like: (cd $CVS/..; cvs -d $CVSROOT co SPECS)"
84    exit 1
85fi
86
87exec >> $LOG 2>&1
88
89for f in $*; do
90    cd $CVS
91
92    case $f in
93        /*) file=$f;;
94        *) file=$orig/$f;;
95    esac
96
97    echo "processing $f"
98   
99    name=`rpm -q --queryformat '%{NAME}\n' -p $file`
100    tag=r`rpm -q --queryformat '%{VERSION}-%{RELEASE}\n' -p $file|tr . _`
101    host=`hostname`
102
103    # new kernel naming trick
104    case $name in
105        kernel-2.6*)
106            tag=r`echo $name | sed 's/kernel-//' | tr . _`
107            name=kernel-2.6
108            sources=`rpm -qpl $file | grep -v linux-[0-9.]*.tar.`
109            ;;
110        kernel-2.4*)
111            tag=r`echo $name | sed 's/kernel-//' | tr . _`
112            name=kernel
113            sources=`rpm -qpl $file | grep -v linux-[0-9.]*.tar.`
114            ;;
115        *)
116            sources=`rpm -qpl $file | fgrep -v .tar.`
117            ;;
118    esac
119
120    if [ "$remove" == 1 ]; then
121        rm -rf $name
122    fi
123   
124    if [ -n "$update" ]; then
125        upopt="-r $update"
126    else
127        upopt=-A
128    fi
129   
130    # first step try to extract the module
131    cvs update -d $upopt $name
132   
133    # update tag doesn't exist, we need to create the branch
134    if [ -n "$update" ] && ! grep -q "T$update\$" $name/CVS/Tag; then
135        set -x
136        branchtag=`echo $tag | sed 's/_[0-9]*_[0-9]*mdk/mdk/'`
137        cvs rtag -b -r $branchtag $update SPECS/$name
138        # try again with the assumption that the release is in the form 2.x instead of 2.x.y
139        if [ $? != 0 ]; then
140            branchtag=`echo $tag | sed 's/_[0-9]*mdk/mdk/'`
141            cvs rtag -b -r $branchtag $update SPECS/$name
142            # if it fails, put the branch tag on HEAD
143            if [ $? != 0 ]; then
144                cvs rtag -b -r HEAD $update SPECS/$name
145            fi
146        fi
147        cvs update -d $upopt $name
148        if ! grep -q "T$update\$" $name/CVS/Tag; then
149            echo "unable to create branch"
150            exit 1
151        fi
152        set +x
153    fi
154
155    # if the module doesn't exist, add it to the repository
156    if [ ! -d $name/CVS ]; then
157        mkdir $name
158        cvs add $name
159    fi
160   
161    # clean up the directory
162    cd $name || exit 1
163    rm -f `ls | fgrep -v CVS`
164   
165    # add the new files
166    rpm2cpio $file | cpio -id $sources
167   
168    # uncompress the files to avoid binaries in the repository
169    bunzip2 *.bz2
170    gunzip *z
171   
172    # special care of kernel package
173    if [ "$name" = kernel ]; then
174        tar xvf linux-*-q*.tar
175        mv -f */patches/* .
176        rm -rf */patches
177        mv -f 2.4*-q*/* .
178        rm -rf 2.4*-q*
179    fi
180   
181    # special care of kernel package
182    if [ "$name" = kernel-2.6 ]; then
183        tar xvf linux-*-q*.tar
184        mv -f */patches/* .
185        rm -rf */patches
186        mv -f 2.6*-q*/* .
187        rm -rf 2.6*-q*
188    fi
189
190    # remove binary files
191    rm -f *.tar *.gif *.jpg *.pdf *.ps *.zip *.png
192
193    # catch the status of the files to take appropriate action
194    cvs -n update | while read state report; do
195        case $state in
196            \?) $doit cvs add -ko $report;;
197            U) $doit cvs remove $report;;
198        esac
199    done
200
201    # archive the changes
202    $doit cvs commit -m "cvcp commit from $host"
203
204    # associate a name on this version
205    echo "tagging with $tag"
206    $doit cvs tag -F $tag
207
208    echo "done"
209done
210
211# cleanup if requested
212if [ -n "$dellog" ]; then
213    rm -f $LOG
214fi
215
216if [ -n "$autodelete" ]; then
217    rm -rf $CVS/$name
218fi
219
220# cvcp ends here
Note: See TracBrowser for help on using the repository browser.