source: caixamagica/scripts/cmbuild/svn2rpm.sh @ 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: 5.2 KB
Line 
1#!/bin/sh
2
3
4# Author: Flávio Moringa <flavio.moringa@caixamagica.pt>
5# Caixa Mágica Software - 2007
6#
7# Name: svn2rpm
8# Purpose: Retrieve the latest source code from the software repository,
9#          and create the source tarballs to put in the packages repository
10#          so that when the given package gets build it will be built using
11#          the latest source code available.
12#
13# Help Files: config/svn_fonts -> Indicates which software repositories we should
14#                             checkout to be able to create the tarball for the
15#                             package;
16#             config/tarball_files -> Indicates for each package, the files needed to be
17#                              added to the tarball.
18#         
19#
20
21
22DIR="`pwd`"
23#DIR="/caixamagica/Dist12/install/cmbuild"
24
25FTP_REPO="isildur.adetti.intranet:/data/ftp-teste/antibes/i586/media/main/release/"
26
27SVN_SERV="http://contribsoft.caixamagica.pt/repo"
28
29SVN_FONT="$DIR/config/svn_fonts"
30SVN_TARBALL="$DIR/config/tarball_files"
31
32#Should be dynamic according to the makefile
33VERSION="0.12"
34
35# Read all of the command-line arguments as a single string.
36CMD_LINE=$*
37
38
39if test ! -f $SVN_FONT; then
40        echo "The file $SVN_FONT doesn't exist. Exiting..."
41        exit
42fi
43
44if test ! -f $SVN_TARBALL; then
45        echo "The file $SVN_TARBALL doesn't exist. Exiting..."
46        exit 1
47fi
48
49
50usage ()
51{
52        echo
53        echo "Usage:$0 <package_name> [--initial] [--commit] [--tarball] [--cm|--mdv]"
54        echo
55        echo "package_name -> Name of the package whose source RPM we want to use."
56        echo
57        echo "Options:"
58        echo "  --initial  -> First download of the package. Default option;"
59        echo "  --commit   -> Commits the SOURCE and SPEC files to the packages SVN;"
60        echo "  --cm       -> It will use the Caixa Magica repository. This is the default repository;"
61        echo "  --mdv      -> It will use the Mandriva repository.;"
62        echo "  --tarball  -> Creates a new tarball for the package, using the latest source code."
63        echo "  --all      -> The same as \"--initial --commit --tarball\"."
64        echo
65        exit 1
66
67}
68
69# The first argument is the package to check out
70if test -z $1; then
71        echo "Please indicate a package to check out. Exiting..."
72        exit 1
73elif test "$1" = "-h" || test "$1" = "--help"; then
74        usage
75elif test `echo $1 | grep -c ^--` -gt 0;then
76        echo "Please indicate as first argument a package to check out. Exiting..."
77        exit 1
78else
79        PACKAGE="$1"
80fi
81
82# If the only argument is the package then it defaults to the initial checkout
83if test -z $2; then
84        INITIAL="yes"
85fi
86
87# Look at the command-line arguments one at a time.
88for OPTIONS in $CMD_LINE; do
89
90        # Check to see if the argument fits one of the following and act on it.
91        case $OPTIONS in
92
93                --initial)
94                        INITIAL="yes"
95                ;;
96
97                --cm)
98                        SVN_SERV="http://contribsoft.caixamagica.pt/repo"
99                ;;
100
101                --mdv)
102                        SVN_SERV="http://svn.mandriva.com/svn"
103                ;;
104
105                --tarball)
106                        TARBALL="yes"
107                ;;
108
109                --commit)
110                        COMMIT="yes"
111                ;;
112                --all)
113                        INITIAL="yes"
114                        TARBALL="yes"
115                        COMMIT="yes"
116                ;;
117
118                --help|-h)
119                        usage
120                ;;
121        esac
122done
123
124
125#Make sure we are in the right place
126cd $DIR
127
128if test "$INITIAL" = "yes"; then
129       
130        if test ! -d "PACKAGES"; then
131                mkdir PACKAGES;
132        fi
133
134        cd PACKAGES
135       
136        echo "Downloading RPM source files for $PACKAGE to $DIR/PACKAGES/$PACKAGE"
137        svn co $SVN_SERV/packages/cooker/$PACKAGE/current $PACKAGE
138
139        cd ..
140
141
142        if test ! -d "SOURCES"; then
143                mkdir SOURCES;
144        fi
145
146        cd SOURCES
147
148        echo "Downloading source code necessary for $PACKAGE to $DIR/SOURCES/:"
149       
150        # read configuration file to know which repositories to checkout
151        for ITEM in `grep ^$PACKAGE $SVN_FONT | tail -n 1| awk 'BEGIN {FS="->"}{print $2}'`
152        do
153                echo "Downloading the source code of $ITEM to $DIR/SOURCES/$ITEM"
154                svn co $SVN_SERV/soft/$ITEM/trunk $ITEM
155        done
156
157        cd ..
158
159        echo
160
161fi
162
163if test "$TARBALL" = "yes"; then
164       
165        cd $DIR/SOURCES/
166
167        #create the directory if necessary
168        if test ! -d tmp/$PACKAGE-$VERSION; then
169                mkdir -p tmp/$PACKAGE-$VERSION
170        fi
171
172        #Cleaning the directory
173        rm -rf tmp/$PACKAGE-$VERSION/*
174
175        # Read configuration file to know which files to add do the tarball and where
176        # Usualy is just a tarball of the svn directory without the .svn directories
177        while read ITEM; do
178                if [ "`echo \"$ITEM\" | grep ^$PACKAGE`" ]; then
179                        ORI="`echo $ITEM  | awk 'BEGIN {FS="->"}{print $2}'| awk '{print $1}'`"
180                        DEST="`echo $ITEM  | awk 'BEGIN {FS="->"}{print $2}'| awk '{print $2}'`"
181
182                        if test ! -d $DIR/SOURCES/tmp/$PACKAGE-$VERSION/$DEST/; then
183                                mkdir -p $DIR/SOURCES/tmp/$PACKAGE-$VERSION/$DEST
184                        fi
185
186                        echo "Copying \"$DIR/SOURCES/$ORI\" to \"$DIR/SOURCES/tmp/$PACKAGE-$VERSION/$DEST\""
187                        cp -a $DIR/SOURCES/$ORI $DIR/SOURCES/tmp/$PACKAGE-$VERSION/$DEST
188               fi             
189        done < $SVN_TARBALL 
190
191        cd  tmp/
192        rm -rf $PACKAGE-$VERSION.tar.bz2
193        tar -cjvf $PACKAGE-$VERSION.tar.bz2 --exclude=*.svn* $PACKAGE-$VERSION/
194        echo
195        echo "Copying the tarball to the right place:"
196        cp -f $PACKAGE-$VERSION.tar.bz2  $DIR/PACKAGES/$PACKAGE/SOURCES/
197fi
198
199
200if test "$COMMIT" = "yes"; then
201       
202        cd $DIR/PACKAGES/$PACKAGE
203        svn ci -m "Package $PACKAGE updated"
204
205fi
Note: See TracBrowser for help on using the repository browser.