Code

d5acc74ead3030917ff5587c110747d849c91314
[gosa.git] / gosa-core / redhat / make-gosa-package
1 #!/bin/sh
3 if [ $# -ne 2 ]; then
4         echo "Usage: RHEL/SLES/OpenSuse 2.6.4"
5         exit 1
6 fi
8 # Prepare Variables depending on build system
9 ##
10 release=$2
11 distribution=$1
12 NOT_RELEASED="heimdal dak dfs glpi opsi apache2 ssh uw-imap"
13 if [ "$release" != "trunk" ]
14 then
15         release="tags/$release"
16 fi
19 # Export the requested SVN release
20 ##
21 if [ ! -d rpm_src ] 
22 then 
23   mkdir rpm_src;
24 fi
27 if [ ! -d rpm_src/gosa-core ] 
28 then
29 svn export https://oss.gonicus.de/repositories/gosa/$release/gosa-core \
30     ./rpm_src/gosa-core  
31 else
32         echo "SVN export of 'gosa-core' exists, skipping!"
33 fi
35 if [ ! -d rpm_src/gosa-plugins ]
36 then
37 svn export https://oss.gonicus.de/repositories/gosa/$release/gosa-plugins \
38     ./rpm_src/gosa-plugins
39 else
40         echo "SVN export of 'gosa-plugins' exists, skipping!"
41 fi
43 # Detect build version 
44 ##
45 VERSION=$(cat rpm_src/gosa-core/debian/changelog | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
48 case "$distribution" in 
49  "RHEL" ) 
50         build_path='/usr/src/redhat'
51         ;;
52  "SLES" ) 
53         build_path='/usr/src/packages'
54         ;;
55  "OpenSuse" ) 
56         build_path='/usr/src/packages'
57         ;;
58  * ) 
59         echo "$distribution is unknown"
60         exit 1;
61         ;;
62 esac
64 # Clean up
65 ## 
66 echo ".. some cleanup in '$build_path'"
67 rm -rf /var/tmp/gosa*
68 rm -rf $build_path/RPMS/noarch/gosa*
69 rm -rf $build_path/SOURCES/gosa*
70 rm -rf $build_path/SPECS/gosa*
71 rm -rf rpm_src/gosa-$VERSION
73 PATHS='BUILD SPECS RPMS SOURCES'
74 for path in $PATHS; do
75         if [ ! -d $build_path/$path ] 
76         then 
77                 mkdir -p $build_path/$path
78         fi
79 done
81 # Create SRC tar 
82 ##
83 echo "Creating source tar.gz for gosa-$VERSION"
84 cp -a rpm_src/gosa-core rpm_src/gosa-$VERSION
85 cd rpm_src
86 tar cfj $build_path/SOURCES/gosa-$VERSION.tar.bz2 gosa-$VERSION
87 cd ..
89 # Copy patches 
90 ##
91 echo "Copying build patches"
92 cp rpm_src/gosa-$VERSION/redhat/*.patch $build_path/SOURCES/
94 # Prepare spec file, replace Version 
95 ##
96 echo "Preparing spec file"
97 sed "s/^Version:.*$/Version:            $VERSION/" \
98      rpm_src/gosa-$VERSION/redhat/gosa.spec > $build_path/SPECS/gosa.spec
101 # Build GOsa RPM 
102 ##
103 echo "Try to build package ... rpmbuild" 
104 rpmbuild --quiet -bb $build_path/SPECS/gosa.spec
105 if [ $? != 0 ]
106 then
107         echo "Error: Build error" 
108         exit 1
109 fi
112 # Build GOsa plugins
115 # Create a list of all available plugins  
116 ## 
117 MAKE_PLUGINS=$(ls -1 rpm_src/gosa-plugins/*/plugin.dsc \
118    | sed 's/^.*\/\([^\/]*\)\/plugin.dsc$/\1/')
120 # Skip black listed plugins
121 ##
122 for i in $NOT_RELEASED; do
123         MAKE_PLUGINS=$(echo -n $MAKE_PLUGINS | sed "s/$i//")
124 done
126 # Try to create plugin specfiles and try to build
127 ##
128 for plugin in $MAKE_PLUGINS; do
130         echo "# $plugin "
132         ./gosa-core/redhat/rpm-make-gosa $plugin $build_path
133         if [ $? != 0 ]
134         then 
135                 echo "Error: Could not prepare build process"
136                 exit 1
137         fi
139         rpmbuild --quiet -bb $build_path/SPECS/gosa-plugin-$plugin.spec 
140         if [ $? != 0 ]
141         then 
142                 echo "Error: Build error in $plugin"
143                 exit 1
144         fi
145 done