f80e325885c16ecfc291b45d2fd8bfd7f074b381
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=""
29 usage() {
30 cat <<-EOF
31 GOsa Debian package build tool. Build snapshots from selected SVN locations.
32 Usage: ${0##*/} [options]
34 Options:
35 -b|--branch Branch to export [$BRANCH]
36 -p|--plugins Comma seperate list of plugins to build. Leave empty to build all.
37 -r|--release Debian release to build for [$TARGET_RELEASE]
38 -c|--changelog Debian changelog entry [$RELEASE_REASON]
39 -s|--section Debian section to place GOsa in [$SECTION]
40 -i|--si-section Debian section to place GOsa-SI in [$SI_SECTION]
41 -h|--help this help
43 EOF
44 exit 1
45 }
47 if ! which dh-make-gosa >/dev/null; then
48 echo "Error: cannot find dh-make-gosa binary in path!";
49 exit 1
50 fi
52 # Import command line parameters
53 PARMS=`getopt -o brscip:,h --long branch,changelog,plugins,section,si-section,release:,help -n "${0##*/}" -- "$@"`
54 eval set -- "$PARMS"
56 while true; do
57 case "$1" in
58 -b|--branch)
59 BRANCH=$2; shift 2 ;;
60 -r|--release)
61 TARGET_RELEASE=$2; shift 2 ;;
62 -c|--changelog)
63 RELEASE_REASON=$2; shift 2 ;;
64 -p|--plugins)
65 MAKE_PLUGINS=$(echo $2 | tr ',' ' '); shift 2 ;;
66 -s|--section)
67 SECTION=$2; shift 2 ;;
68 -i|--si-section)
69 SI_SECTION=$2; shift 2 ;;
70 -h|--help)
71 usage ;;
72 --)
73 shift; break ;;
74 *)
75 echo "getopt error" ;;
76 esac
77 done
79 [ $BRANCH = "trunk" ] || BRANCH="branches/$BRANCH"
80 echo "Loading svn information for '${BRANCH}'..."
81 svn co -N https://oss.gonicus.de/repositories/gosa/${BRANCH} gosa-info/ > /dev/null
82 BRANCH_REV=$(LANG=C svn info gosa-info | sed -n -e 's/^Last Changed Rev: \([0-9]*\).*$/\1/p')
83 rm -rf gosa-info
85 # Load current revision from logs
86 VERSION=$(svn cat -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-core/debian/changelog \
87 | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
88 GOSA_VER="${VERSION}+svn${BRANCH_REV}"
89 GOSA_DIR="gosa-${GOSA_VER}"
91 ORIG_FILE="gosa_${GOSA_VER}.orig.tar.gz"
93 # Export from svn...
94 [ -d "gosa-${BRANCH}" ] && rm -rf gosa-$BRANCH
95 echo "Exporting current GOsa (rev: ${BRANCH_REV}) from '${BRANCH}'..."
96 svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-core gosa-${BRANCH} > /dev/null
97 svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-si gosa-si-${BRANCH} > /dev/null
98 svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-plugins gosa-plugins-${BRANCH} > /dev/null
100 VERSION=$(cat "gosa-${BRANCH}/debian/changelog" | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
101 GOSA_VER="${VERSION}+svn${BRANCH_REV}"
102 GOSA_DIR="gosa-${GOSA_VER}"
103 GOSA_SI_DIR="gosa-si-${GOSA_VER}"
105 if [ -d "gosa-${GOSA_VER}" ]
106 then
107 rm -rf "gosa-${GOSA_VER}"
108 fi
109 mv "gosa-${BRANCH}" "gosa-${GOSA_VER}"
110 mv "gosa-si-${BRANCH}" "gosa-si-${GOSA_VER}"
112 echo "Creating original sources 'gosa-${GOSA_VER}'..."
113 tar -c -f "gosa_${GOSA_VER}.orig.tar" "${GOSA_DIR}"
114 tar -c -f "gosa-si_${GOSA_VER}.orig.tar" "${GOSA_SI_DIR}"
116 echo "Compressing sources..."
117 gzip -9 "gosa_${GOSA_VER}.orig.tar"
118 gzip -9 "gosa-si_${GOSA_VER}.orig.tar"
120 export OVERRIDE_VERSION="$GOSA_VER"
121 if [ -z "$MAKE_PLUGINS" ]; then
122 MAKE_PLUGINS=$(ls -1 gosa-plugins-${BRANCH}/*/plugin.dsc | sed 's/^.*\/\([^\/]*\)\/plugin.dsc$/\1/')
123 fi
124 for plugin in $MAKE_PLUGINS; do
126 GOSA_PLUG_DIR="gosa-plugin-$plugin-${GOSA_VER}"
127 mv "gosa-plugins-${BRANCH}/$plugin" .
129 echo "Debianizing plugin $plugin"
130 yes | dh-make-gosa --section web $plugin
131 rm -rf "$plugin"
133 echo "Packing original sources 'gosa-plugin-$plugin-${GOSA_VER}'..."
134 tar -c -f "gosa-plugin-${plugin}_${GOSA_VER}.orig.tar" "${GOSA_PLUG_DIR}"
136 echo "Compressing sources..."
137 gzip -9 "gosa-plugin-${plugin}_${GOSA_VER}.orig.tar"
138 done
140 rm -rf gosa-plugins-${BRANCH}
142 echo "Deploying patches..."
143 for patch in $(find patches -type f | grep -v .svn); do
145 if echo $patch | grep -q gosa-plugin; then
146 plugin=$(echo $patch | sed 's/^.*gosa-plugin-\([^-]*\).*$/\1/g')
147 echo "* gosa-plugin-$plugin patch: $patch"
148 [ -d "gosa-plugin-${plugin}-${GOSA_VER}/debian/patches" ] || mkdir -p "gosa-plugin-${plugin}-${GOSA_VER}/debian/patches"
149 cp "$patch" gosa-plugin-${plugin}-${GOSA_VER}/debian/patches
150 else
151 echo "* gosa-core patch: $patch"
152 [ -d "${GOSA_DIR}/debian/patches" ] && mkdir -p "${GOSA_DIR}/debian/patches"
153 cp "$patch" ${GOSA_DIR}/debian/patches
154 fi
155 done
157 # Passe section im GOsa_DIR an
158 sed -i "s#^Section: web#Section: $SECTION#g" ${GOSA_DIR}/debian/control
159 sed -i "s#^Section: utils#Section: $SI_SECTION#g" ${GOSA_SI_DIR}/debian/control
161 for plugin in $MAKE_PLUGINS; do
162 GOSA_PLUGIN_DIRS="$GOSA_PLUGIN_DIRS gosa-plugin-$plugin-${GOSA_VER}"
163 done
164 for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
165 echo "Adapting version in $dir"
166 (cd "$dir"; echo | debchange -v "${GOSA_VER}-1${TARGET_RELEASE}1" -D "$TARGET_RELEASE" "$RELEASE_REASON" >/dev/null 2>&1)
167 [ -d $dir/debian/patches ] || continue
168 echo "Creating patch list for $dir"
169 ls -1 $dir/debian/patches | grep -v 00list | sed 's%^.*/%%g' > $dir/debian/patches/00list
170 done
172 # Update revision
173 sed -i "s/^\$svn_revision = .*$/\$svn_revision = '\$Revision: $BRANCH_REV \$';/g" $GOSA_DIR/include/functions.inc
175 if [ "$1" = "-s" ]
176 then
177 echo "Creating debian sources..."
178 for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
179 dpkg-source -b "$dir"
180 done
181 else
182 echo "Creating debian packages..."
183 for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
184 (cd "$dir"; dpkg-buildpackage -k$DEBSIGN_KEYID -rfakeroot -sa)
185 done
186 fi
188 echo "Removing gosa snapshot..."
189 for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
190 rm -rf "$dir"
191 done