Code

Updated si xml_parser
[gosa.git] / gosa-core / contrib / make-gosa-package
index c9a346cfe5af9336d1c78968127cef08f6a2cffc..ae4199ed6d02e542d702a1ae4cf9ffb9a0fd7610 100755 (executable)
@@ -1,10 +1,86 @@
 #!/bin/sh
+# This code is part of GOsa (http://www.gosa-project.org)
+# Copyright (C) 2008 GONICUS GmbH
+#
+# ID: $$Id$$
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+# Define defaults
 RELEASE_REASON="GOsa svn snapshot"
 BRANCH="trunk"
-SECTION="gonicus"
+SECTION="web"
+SI_SECTION="utils"
 TARGET_RELEASE="etch"
 MAKE_PLUGINS=""
 
+usage() {
+       cat <<-EOF
+       GOsa Debian package build tool. Build snapshots from selected SVN locations.
+       Usage: ${0##*/} [options]
+       
+       Options:
+         -b|--branch      Branch to export [$BRANCH]
+         -p|--plugins     Comma seperate list of plugins to build. Leave empty to build all.
+         -r|--release     Debian release to build for [$TARGET_RELEASE]
+         -c|--changelog   Debian changelog entry [$RELEASE_REASON]
+         -s|--section     Debian section to place GOsa in [$SECTION]
+         -i|--si-section  Debian section to place GOsa-SI in [$SI_SECTION]
+          -d|--debian-pkg  Don't clear up debian packages for plugins (for developers only)
+         -h|--help        this help
+
+       EOF
+       exit 1
+}
+
+for cmd in dh-make-gosa debchange dpkg-buildpackage dpkg-source svn; do
+  if ! which $cmd >/dev/null; then
+       echo "Error: cannot find '$cmd' command in path!";
+       exit 1
+  fi
+done
+
+# Import command line parameters
+PARMS=`getopt -o d::b:r:s:c:i:p:,h --long branch:,changelog:,plugins:,section:,si-section:,release:,help -n "${0##*/}" -- "$@"`
+eval set -- "$PARMS"
+
+while true; do
+        case "$1" in
+                -b|--branch)
+                       BRANCH=$2; shift 2 ;;
+                -r|--release)
+                       TARGET_RELEASE=$2; shift 2 ;;
+                -c|--changelog)
+                       RELEASE_REASON=$2; shift 2 ;;
+                -p|--plugins)
+                       MAKE_PLUGINS=$(echo $2 | tr ',' ' '); shift 2 ;;
+                -s|--section)
+                       SECTION=$2; shift 2 ;;
+                -i|--si-section)
+                       SI_SECTION=$2; shift 2 ;;
+                -d|--debian-pkg)
+                        DEBIAN_PKG=$2; shift 2 ;;
+                -h|--help)
+                       usage ;;
+                --)
+                       shift; break ;;
+                *)
+                       echo "getopt error" ;;
+        esac
+done
+
 [ $BRANCH = "trunk" ] || BRANCH="branches/$BRANCH"
 echo "Loading svn information for '${BRANCH}'..."
 svn co -N https://oss.gonicus.de/repositories/gosa/${BRANCH} gosa-info/ > /dev/null
@@ -38,13 +114,13 @@ fi
 mv "gosa-${BRANCH}" "gosa-${GOSA_VER}"
 mv "gosa-si-${BRANCH}" "gosa-si-${GOSA_VER}"
 
-echo "Creating original sources '$gosa-{GOSA_VER}'..."
+echo "Creating original sources 'gosa-${GOSA_VER}'..."
 tar -c -f "gosa_${GOSA_VER}.orig.tar" "${GOSA_DIR}"
 tar -c -f "gosa-si_${GOSA_VER}.orig.tar" "${GOSA_SI_DIR}"
 
 echo "Compressing sources..."
-gzip -9 "gosa_${GOSA_VER}.orig.tar"
-gzip -9 "gosa-si_${GOSA_VER}.orig.tar"
+gzip -f -9 "gosa_${GOSA_VER}.orig.tar"
+gzip -f -9 "gosa-si_${GOSA_VER}.orig.tar"
 
 export OVERRIDE_VERSION="$GOSA_VER"
 if [ -z "$MAKE_PLUGINS" ]; then
@@ -56,14 +132,14 @@ for plugin in $MAKE_PLUGINS; do
        mv "gosa-plugins-${BRANCH}/$plugin" .
 
        echo "Debianizing plugin $plugin"
-       yes | ./dh-make-gosa $plugin
+       yes | dh-make-gosa --section $SECTION $plugin
        rm -rf "$plugin"
 
        echo "Packing original sources 'gosa-plugin-$plugin-${GOSA_VER}'..."
        tar -c -f "gosa-plugin-${plugin}_${GOSA_VER}.orig.tar" "${GOSA_PLUG_DIR}"
 
        echo "Compressing sources..."
-       gzip -9 "gosa-plugin-${plugin}_${GOSA_VER}.orig.tar"
+       gzip -f -9 "gosa-plugin-${plugin}_${GOSA_VER}.orig.tar"
 done
 
 rm -rf gosa-plugins-${BRANCH}
@@ -84,15 +160,15 @@ for patch in $(find patches -type f | grep -v .svn); do
 done
 
 # Passe section im GOsa_DIR an
-sed -i "s/^Section: web/Section: $SECTION\/web/g" ${GOSA_DIR}/debian/control
-sed -i "s/^Section: utils/Section: $SECTION\/utils/g" ${GOSA_SI_DIR}/debian/control
+sed -i "s#^Section: web#Section: $SECTION#g" ${GOSA_DIR}/debian/control
+sed -i "s#^Section: utils#Section: $SI_SECTION#g" ${GOSA_SI_DIR}/debian/control
 
 for plugin in $MAKE_PLUGINS; do
        GOSA_PLUGIN_DIRS="$GOSA_PLUGIN_DIRS gosa-plugin-$plugin-${GOSA_VER}"
 done
 for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
        echo "Adapting version in $dir"
-       (cd "$dir"; echo | debchange -v "${GOSA_VER}-${SECTION}1" -D "$TARGET_RELEASE" "$RELEASE_REASON" &> /dev/null)
+       (cd "$dir"; echo | debchange -v "${GOSA_VER}-1${TARGET_RELEASE}1" -D "$TARGET_RELEASE" "$RELEASE_REASON" >/dev/null 2>&1)
        [ -d $dir/debian/patches ] || continue
        echo "Creating patch list for $dir"
        ls -1 $dir/debian/patches | grep -v 00list | sed 's%^.*/%%g' > $dir/debian/patches/00list
@@ -115,14 +191,15 @@ else
 fi
 
 echo "Removing gosa snapshot..."
-for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
+if [ -z "$DEBIAN_PKG" ]
+then
+       for dir in $GOSA_DIR; do
+        rm -rf "$dir"
+       done
+else
+       for dir in $GOSA_DIR $GOSA_SI_DIR $GOSA_PLUGIN_DIRS; do
        rm -rf "$dir"
-done
-
-echo
-echo "Moving result to 'dest'"
-[ -d dest ] && rm -rf dest
-mkdir dest
+       done
+fi
 
-mv *.deb *.changes *.dsc *.gz dest/