Code

- Added option -e to build non officialy released plugins
[gosa.git] / gosa-core / contrib / make-gosa-package
1 #!/bin/sh
2 # This code is part of GOsa (http://www.gosa-project.org)
3 # Copyright (C) 2008 GONICUS GmbH
4 #
5 # ID: $$Id$$
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21 # Define defaults
22 RELEASE_REASON="GOsa svn snapshot"
23 BRANCH="trunk"
24 SECTION="web"
25 SI_SECTION="utils"
26 TARGET_RELEASE="etch"
27 MAKE_PLUGINS=""
28 NOT_RELEASED="heimdal dak dfs glpi opsi apache2 ssh"
30 usage() {
31         cat <<-EOF
32         GOsa Debian package build tool. Build snapshots from selected SVN locations.
33         Usage: ${0##*/} [options]
34         
35         Options:
36           -b|--branch       Branch to export [$BRANCH]
37           -p|--plugins      Comma seperate list of plugins to build. Leave empty to build all.
38           -e|--experimental Build not released plugins (for testers and developers only)
39           -r|--release      Debian release to build for [$TARGET_RELEASE]
40           -c|--changelog    Debian changelog entry [$RELEASE_REASON]
41           -s|--section      Debian section to place GOsa in [$SECTION]
42           -i|--si-section   Debian section to place GOsa-SI in [$SI_SECTION]
43           -d|--debian-pkg   Don't clear up debian packages for plugins (for developers only)
44           -h|--help         this help
46         EOF
47         exit 1
48 }
50 for cmd in dh-make-gosa debchange dpkg-buildpackage dpkg-source svn; do
51   if ! which $cmd >/dev/null; then
52         echo "Error: cannot find '$cmd' command in path!";
53         exit 1
54   fi
55 done
57 # Import command line parameters
58 PARMS=`getopt -o e::d::b:r:s:c:i:p:,h --long branch:,changelog:,plugins:,section:,si-section:,release:,help -n "${0##*/}" -- "$@"`
59 eval set -- "$PARMS"
61 while true; do
62         case "$1" in
63                 -b|--branch)
64                         BRANCH=$2; shift 2 ;;
65                 -r|--release)
66                         TARGET_RELEASE=$2; shift 2 ;;
67                 -c|--changelog)
68                         RELEASE_REASON=$2; shift 2 ;;
69                 -p|--plugins)
70                         MAKE_PLUGINS=$(echo $2 | tr ',' ' '); shift 2 ;;
71                 -e|--experimental)
72                         NOT_RELEASED=""; shift 2;;
73                 -s|--section)
74                         SECTION=$2; shift 2 ;;
75                 -i|--si-section)
76                         SI_SECTION=$2; shift 2 ;;
77                 -d|--debian-pkg)
78                         DEBIAN_PKG=$2; shift 2 ;;
79                 -h|--help)
80                         usage ;;
81                 --)
82                         shift; break ;;
83                 *)
84                         echo "getopt error" ;;
85         esac
86 done
88 echo "Loading svn information for '${BRANCH}'..."
89 svn co -N https://oss.gonicus.de/repositories/gosa/${BRANCH} gosa-info/ > /dev/null
90 BRANCH_REV=$(LANG=C svn info gosa-info | sed -n -e 's/^Last Changed Rev: \([0-9]*\).*$/\1/p')
91 rm -rf gosa-info
93 # Load current revision from logs
94 VERSION=$(svn cat -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-core/debian/changelog \
95         | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
96 if [ "$BRANCH" == "trunk" ]; then
97         GOSA_VER="${VERSION}+svn${BRANCH_REV}"
98 else
99         GOSA_VER="${VERSION}"
100 fi
101 GOSA_DIR="gosa-${GOSA_VER}"
103 ORIG_FILE="gosa_${GOSA_VER}.orig.tar.gz"
105 # Export from svn...
106 BNAME=$(basename $BRANCH)
107 [ -d "gosa-${BNAME}" ] && rm -rf gosa-$BNAME
108 echo "Exporting current GOsa (rev: ${BRANCH_REV}) from '${BRANCH}'..."
109 svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-core gosa-${BNAME} > /dev/null
110 svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-si gosa-si-${BNAME} > /dev/null
111 svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-plugins gosa-plugins-${BNAME} > /dev/null
113 VERSION=$(cat "gosa-${BNAME}/debian/changelog" | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
114 if [ "$BRANCH" == "trunk" ]; then
115         GOSA_VER="${VERSION}+svn${BRANCH_REV}"
116 else
117         GOSA_VER="${VERSION}"
118 fi
119 GOSA_DIR="gosa-${GOSA_VER}"
120 GOSA_SI_DIR="gosa-si-${GOSA_VER}"
122 if [ "$BNAME" != "$GOSA_VER" ]
123 then
124         rm -rf "gosa-${GOSA_VER}"
125 fi
127 if [ "$BNAME" != "$GOSA_VER" ]
128 then
129         mv "gosa-${BNAME}" "gosa-${GOSA_VER}"
130         mv "gosa-si-${BNAME}" "gosa-si-${GOSA_VER}"
131 fi
133 echo "Creating original sources 'gosa-${GOSA_VER}'..."
134 tar -c -f "gosa_${GOSA_VER}.orig.tar" "${GOSA_DIR}"
135 tar -c -f "gosa-si_${GOSA_VER}.orig.tar" "${GOSA_SI_DIR}"
137 echo "Compressing sources..."
138 gzip -f -9 "gosa_${GOSA_VER}.orig.tar"
139 gzip -f -9 "gosa-si_${GOSA_VER}.orig.tar"
141 export OVERRIDE_VERSION="$GOSA_VER"
142 if [ -z "$MAKE_PLUGINS" ]; then
143         MAKE_PLUGINS=$(ls -1 gosa-plugins-${BNAME}/*/plugin.dsc | sed 's/^.*\/\([^\/]*\)\/plugin.dsc$/\1/')
144         for i in $NOT_RELEASED; do
145                 MAKE_PLUGINS=$(echo -n $MAKE_PLUGINS | sed "s/$i//")
146         done
147 fi
148 for plugin in $MAKE_PLUGINS; do
150         GOSA_PLUG_DIR="gosa-plugin-$plugin-${GOSA_VER}"
151         mv "gosa-plugins-${BNAME}/$plugin" .
153         echo "Debianizing plugin $plugin"
154         yes | dh-make-gosa --section $SECTION $plugin
155         rm -rf "$plugin"
157         echo "Packing original sources 'gosa-plugin-$plugin-${GOSA_VER}'..."
158         tar -c -f "gosa-plugin-${plugin}_${GOSA_VER}.orig.tar" "${GOSA_PLUG_DIR}"
160         echo "Compressing sources..."
161         gzip -f -9 "gosa-plugin-${plugin}_${GOSA_VER}.orig.tar"
162 done
164 rm -rf gosa-plugins-${BNAME}
166 echo "Deploying patches..."
167 for patch in $(find patches -type f | grep -v .svn); do
169         if echo $patch | grep -q gosa-plugin; then
170                 plugin=$(echo $patch | sed 's/^.*gosa-plugin-\([^-]*\).*$/\1/g')
171                 echo "* gosa-plugin-$plugin patch: $patch"
172                 [ -d "gosa-plugin-${plugin}-${GOSA_VER}/debian/patches" ] || mkdir -p "gosa-plugin-${plugin}-${GOSA_VER}/debian/patches"
173                 cp "$patch" gosa-plugin-${plugin}-${GOSA_VER}/debian/patches
174         else
175                 echo "* gosa-core patch: $patch"
176                 [ -d "${GOSA_DIR}/debian/patches" ] && mkdir -p "${GOSA_DIR}/debian/patches"
177                 cp "$patch" ${GOSA_DIR}/debian/patches
178         fi
179 done
181 # Passe section im GOsa_DIR an
182 sed -i "s#^Section: web#Section: $SECTION#g" ${GOSA_DIR}/debian/control
183 sed -i "s#^Section: utils#Section: $SI_SECTION#g" ${GOSA_SI_DIR}/debian/control
185 for plugin in $MAKE_PLUGINS; do
186         GOSA_PLUGIN_DIRS="$GOSA_PLUGIN_DIRS gosa-plugin-$plugin-${GOSA_VER}"
187 done
188 for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
189         echo "Adapting version in $dir"
190         if [ "$TARGET_RELEASE" == "unstable" ]; then
191                 (cd "$dir"; echo | debchange -v "${GOSA_VER}" "$RELEASE_REASON" >/dev/null 2>&1)
192         else
193                 (cd "$dir"; echo | debchange -v "${GOSA_VER}-1${TARGET_RELEASE}1" -D "$TARGET_RELEASE" "$RELEASE_REASON" >/dev/null 2>&1)
194         fi
195         [ -d $dir/debian/patches ] || continue
196         echo "Creating patch list for $dir"
197         ls -1 $dir/debian/patches | grep -v 00list | sed 's%^.*/%%g' > $dir/debian/patches/00list
198 done
200 # Update revision
201 sed -i "s/^\$svn_revision = .*$/\$svn_revision = '\$Revision: $BRANCH_REV \$';/g" $GOSA_DIR/include/functions.inc
203 if [ "$1" = "-s" ]
204 then
205         echo "Creating debian sources..."
206         for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
207                 dpkg-source -b "$dir"
208         done
209 else
210         echo "Creating debian packages..."
211         for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
212                 (cd "$dir"; dpkg-buildpackage -k$DEBSIGN_KEYID -rfakeroot -sa)
213         done
214 fi
216 echo "Removing gosa snapshot..."
217 if [ -z "$DEBIAN_PKG" ]
218 then
219         for dir in $GOSA_DIR; do
220         rm -rf "$dir"
221         done
222 else
223         for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
224         rm -rf "$dir"
225         done
226 fi