Code

Added property class to get_cfg_requests
[gosa.git] / gosa-core / redhat / make-gosa-package
1 #!/bin/sh
3 if [ $# -ne 2 ]; then
4         echo "Usage: $(basename $0) (RHEL|SLES|OpenSuse) svn-tag"
5         echo "        svn-tag can be 'trunk' or a version like '2.6.8'"
6         exit 1
7 fi
9 # Prepare Variables depending on build system
10 ##
11 release=$2
12 distribution=$1
13 NOT_RELEASED="heimdal dak dfs glpi opsi apache2 ssh uw-imap"
14 if [ "$release" != "trunk" ]
15 then
16         release="tags/$release"
17 fi
20 # Export the requested SVN release
21 ##
22 if [ ! -d rpm_src ] 
23 then 
24   mkdir rpm_src;
25 fi
28 if [ ! -d rpm_src/gosa-core ] 
29 then
30 svn export https://oss.gonicus.de/repositories/gosa/$release/gosa-core \
31     ./rpm_src/gosa-core  
32 else
33         echo "SVN export of 'gosa-core' exists, skipping!"
34 fi
36 if [ ! -d rpm_src/gosa-plugins ]
37 then
38 svn export https://oss.gonicus.de/repositories/gosa/$release/gosa-plugins \
39     ./rpm_src/gosa-plugins
40 else
41         echo "SVN export of 'gosa-plugins' exists, skipping!"
42 fi
44 # Detect build version 
45 ##
46 VERSION=$(cat rpm_src/gosa-core/debian/changelog | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
49 case "$distribution" in 
50  "RHEL" ) 
51         rm -rf /var/tmp/gosa*
52         build_path='/usr/src/redhat'
53         target='redhat'
54         ;;
55  "SLES" ) 
56         build_path='/usr/src/packages'
57         target='SLES'
58         ;;
59  "OpenSuse" ) 
60         rm -rf /var/tmp/rpm-tmp*
61         build_path='/usr/src/packages'
62         target='suse'
63         ;;
64  * ) 
65         echo "$distribution is unknown"
66         exit 1;
67         ;;
68 esac
70 # Clean up
71 ## 
72 echo ".. some cleanup in '$build_path'"
73 rm -rf $build_path/RPMS/noarch/gosa*
74 rm -rf $build_path/SOURCES/gosa*
75 rm -rf $build_path/SPECS/gosa*
76 rm -rf rpm_src/gosa-$VERSION
78 PATHS='BUILD SPECS RPMS SOURCES'
79 for path in $PATHS; do
80         if [ ! -d $build_path/$path ] 
81         then 
82                 mkdir -p $build_path/$path
83         fi
84 done
86 # Create SRC tar 
87 ##
88 echo "Creating source tar.gz for gosa-$VERSION"
89 cp -a rpm_src/gosa-core rpm_src/gosa-$VERSION
90 cd rpm_src
91 tar cfj $build_path/SOURCES/gosa-$VERSION.tar.bz2 gosa-$VERSION
92 cd ..
94 # Copy patches 
95 ##
96 echo "Copying build patches"
97 cp rpm_src/gosa-$VERSION/redhat/*.patch $build_path/SOURCES/
99 # Prepare spec file, replace Version 
100 ##
101 echo "Preparing spec file"
102 sed "s/^Version:.*$/Version:            $VERSION/" \
103      rpm_src/gosa-$VERSION/redhat/gosa.spec > $build_path/SPECS/gosa.spec
106 # Build GOsa RPM 
107 ##
108 echo "Try to build package ... rpmbuild" 
109 rpmbuild -bb $build_path/SPECS/gosa.spec
110 if [ $? != 0 ]
111 then
112         echo "Error: Build error" 
113         exit 1
114 fi
117 # Build GOsa plugins
120 # Create a list of all available plugins  
121 ## 
122 MAKE_PLUGINS=$(ls -1 rpm_src/gosa-plugins/*/plugin.dsc \
123    | sed 's/^.*\/\([^\/]*\)\/plugin.dsc$/\1/')
125 # Skip black listed plugins
126 ##
127 for i in $NOT_RELEASED; do
128         MAKE_PLUGINS=$(echo -n $MAKE_PLUGINS | sed "s/$i//")
129 done
131 # Try to create plugin specfiles and try to build
132 ##
133 for plugin in $MAKE_PLUGINS; do
135         echo "# $plugin "
137         ./gosa-core/redhat/rpm-make-gosa $plugin $build_path
138         if [ $? != 0 ]
139         then 
140                 echo "Error: Could not prepare build process"
141                 exit 1
142         fi
144         rpmbuild -bb $build_path/SPECS/gosa-plugin-$plugin.spec 
145         if [ $? != 0 ]
146         then 
147                 echo "Error: Build error in $plugin"
148                 exit 1
149         fi
150 done
152 echo ""
153 echo ""
154 echo ""
155 echo "#### Build done "
157 if [ ! -d "RPMS/$target" ] 
158 then 
159         mkdir -p "RPMS/$target"
160         
161         echo "Copying rpms to '$curdir/RPMS/$target'"
162         curdir=`pwd`
163         cp $build_path/RPMS/noarch/gosa* "RPMS/$target"
164 fi
167 if [ "$distribution" == "OpenSuse" ]
168 then
169         cd "RPMS/$target"
170         curdir=`pwd`
171         echo "Creating repostory in '$curdir'"
172         createrepo .
173 fi