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