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 rm -rf /var/tmp/gosa*
51 build_path='/usr/src/redhat'
52 target='redhat'
53 ;;
54 "SLES" )
55 build_path='/usr/src/packages'
56 target='SLES'
57 ;;
58 "OpenSuse" )
59 rm -rf /var/tmp/rpm-tmp*
60 build_path='/usr/src/packages'
61 target='suse'
62 ;;
63 * )
64 echo "$distribution is unknown"
65 exit 1;
66 ;;
67 esac
69 # Clean up
70 ##
71 echo ".. some cleanup in '$build_path'"
72 rm -rf $build_path/RPMS/noarch/gosa*
73 rm -rf $build_path/SOURCES/gosa*
74 rm -rf $build_path/SPECS/gosa*
75 rm -rf rpm_src/gosa-$VERSION
77 PATHS='BUILD SPECS RPMS SOURCES'
78 for path in $PATHS; do
79 if [ ! -d $build_path/$path ]
80 then
81 mkdir -p $build_path/$path
82 fi
83 done
85 # Create SRC tar
86 ##
87 echo "Creating source tar.gz for gosa-$VERSION"
88 cp -a rpm_src/gosa-core rpm_src/gosa-$VERSION
89 cd rpm_src
90 tar cfj $build_path/SOURCES/gosa-$VERSION.tar.bz2 gosa-$VERSION
91 cd ..
93 # Copy patches
94 ##
95 echo "Copying build patches"
96 cp rpm_src/gosa-$VERSION/redhat/*.patch $build_path/SOURCES/
98 # Prepare spec file, replace Version
99 ##
100 echo "Preparing spec file"
101 sed "s/^Version:.*$/Version: $VERSION/" \
102 rpm_src/gosa-$VERSION/redhat/gosa.spec > $build_path/SPECS/gosa.spec
105 # Build GOsa RPM
106 ##
107 echo "Try to build package ... rpmbuild"
108 rpmbuild -bb $build_path/SPECS/gosa.spec
109 if [ $? != 0 ]
110 then
111 echo "Error: Build error"
112 exit 1
113 fi
115 #
116 # Build GOsa plugins
117 #
119 # Create a list of all available plugins
120 ##
121 MAKE_PLUGINS=$(ls -1 rpm_src/gosa-plugins/*/plugin.dsc \
122 | sed 's/^.*\/\([^\/]*\)\/plugin.dsc$/\1/')
124 # Skip black listed plugins
125 ##
126 for i in $NOT_RELEASED; do
127 MAKE_PLUGINS=$(echo -n $MAKE_PLUGINS | sed "s/$i//")
128 done
130 # Try to create plugin specfiles and try to build
131 ##
132 for plugin in $MAKE_PLUGINS; do
134 echo "# $plugin "
136 ./gosa-core/redhat/rpm-make-gosa $plugin $build_path
137 if [ $? != 0 ]
138 then
139 echo "Error: Could not prepare build process"
140 exit 1
141 fi
143 rpmbuild -bb $build_path/SPECS/gosa-plugin-$plugin.spec
144 if [ $? != 0 ]
145 then
146 echo "Error: Build error in $plugin"
147 exit 1
148 fi
149 done
151 echo ""
152 echo ""
153 echo ""
154 echo "#### Build done "
156 if [ ! -d "RPMS/$target" ]
157 then
158 mkdir -p "RPMS/$target"
160 echo "Copying rpms to '$curdir/RPMS/$target'"
161 curdir=`pwd`
162 cp $build_path/RPMS/noarch/gosa* "RPMS/$target"
163 fi
166 if [ "$distribution" == "OpenSuse" ]
167 then
168 cd "RPMS/$target"
169 curdir=`pwd`
170 echo "Creating repostory in '$curdir'"
171 createrepo .
172 fi