Code

Added missing gosa.conf entries.
[gosa.git] / gosa-core / contrib / make-gosa-package
index f80e325885c16ecfc291b45d2fd8bfd7f074b381..b5a622f20a10d0f14fb7b5e16c71d14272f50657 100755 (executable)
@@ -25,6 +25,10 @@ SECTION="web"
 SI_SECTION="utils"
 TARGET_RELEASE="etch"
 MAKE_PLUGINS=""
+NOT_RELEASED="heimdal dak dfs glpi apache2 ssh"
+DEBIAN_PKG="remove"
+NO_SVN="use"
+EXTRACT=`pwd`
 
 usage() {
        cat <<-EOF
@@ -32,25 +36,31 @@ usage() {
        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]
-         -h|--help        this help
+         -b|--branch       Branch to export [$BRANCH]
+         -p|--plugins      Comma seperate list of plugins to build. Leave empty to build all.
+         -e|--experimental Build not released plugins (for testers and developers only)
+         -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)
+         -n|--no-svn       Don't extract gosa from svn (when internet connectivity is not present)
+         -x|--extract-dir  Directory where the checkout is for no-svn 
+         -h|--help         this help
 
        EOF
        exit 1
 }
 
-if ! which dh-make-gosa >/dev/null; then
-       echo "Error: cannot find dh-make-gosa binary in path!";
-       exit 1
-fi
+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 brscip:,h --long branch,changelog,plugins,section,si-section,release:,help -n "${0##*/}" -- "$@"`
+PARMS=`getopt -o e::d::b:r:s:c:i:p:n:x:,h --long branch:,changelog:,plugins:,section:,si-section:,release:,help -n "${0##*/}" -- "$@"`
 eval set -- "$PARMS"
 
 while true; do
@@ -63,10 +73,18 @@ while true; do
                        RELEASE_REASON=$2; shift 2 ;;
                 -p|--plugins)
                        MAKE_PLUGINS=$(echo $2 | tr ',' ' '); shift 2 ;;
+               -e|--experimental)
+                       NOT_RELEASED=""; shift 2;;
                 -s|--section)
                        SECTION=$2; shift 2 ;;
                 -i|--si-section)
                        SI_SECTION=$2; shift 2 ;;
+                -d|--debian-pkg)
+                        DEBIAN_PKG=""; shift 2 ;;
+                -n|--no-svn)
+                        NO_SVN=""; shift 2;;
+                -x|--extract-dir)
+                        EXTRACT=$2; shift 2;;
                 -h|--help)
                        usage ;;
                 --)
@@ -76,68 +94,133 @@ while true; do
         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
-BRANCH_REV=$(LANG=C svn info gosa-info | sed -n -e 's/^Last Changed Rev: \([0-9]*\).*$/\1/p')
-rm -rf gosa-info
+if [ "$NO_SVN" = "use" ]
+then
+       echo "Loading svn information for '${BRANCH}'..."
+       svn co -N https://oss.gonicus.de/repositories/gosa/${BRANCH} gosa-info/ > /dev/null
+       BRANCH_REV=$(LANG=C svn info gosa-info | sed -n -e 's/^Last Changed Rev: \([0-9]*\).*$/\1/p')
+       rm -rf gosa-info
+else
+        echo "Loading svn information for '${BRANCH}' from local checkout ..."
+       BRANCH_REV=$(LANG=C svn info $EXTRACT/gosa-core | sed -n -e 's/^Last Changed Rev: \([0-9]*\).*$/\1/p')
+fi
+
+if [ "$NO_SVN" = "use" ]
+then
+       # Load current revision from logs
+       VERSION=$(svn cat -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-core/debian/changelog \
+               | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
+       if [ "$BRANCH" == "trunk" ]; then
+               GOSA_VER="${VERSION}+svn${BRANCH_REV}"
+       else
+               GOSA_VER="${VERSION}"
+       fi
+else
+        # Load current revision from logs
+       VERSION=$(cat $EXTRACT/gosa-core/debian/changelog | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
+
+        if [ "$BRANCH" == "trunk" ]; then
+                GOSA_VER="${VERSION}+svn${BRANCH_REV}"
+        else
+                GOSA_VER="${VERSION}"
+        fi
+       echo $GOSA_VER
+fi
 
-# Load current revision from logs
-VERSION=$(svn cat -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-core/debian/changelog \
-       | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
-GOSA_VER="${VERSION}+svn${BRANCH_REV}"
 GOSA_DIR="gosa-${GOSA_VER}"
 
 ORIG_FILE="gosa_${GOSA_VER}.orig.tar.gz"
 
-# Export from svn...
-[ -d "gosa-${BRANCH}" ] && rm -rf gosa-$BRANCH
-echo "Exporting current GOsa (rev: ${BRANCH_REV}) from '${BRANCH}'..."
-svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-core gosa-${BRANCH} > /dev/null
-svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-si gosa-si-${BRANCH} > /dev/null
-svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-plugins gosa-plugins-${BRANCH} > /dev/null
+if [ "$NO_SVN" = "use" ]
+then
+       # Export from svn...
+       BNAME=$(basename $BRANCH)
+       [ -d "gosa-${BNAME}" ] && rm -rf gosa-$BNAME
+       echo "Exporting current GOsa (rev: ${BRANCH_REV}) from '${BRANCH}'..."
+       svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-core gosa-${BNAME} > /dev/null
+       svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-si gosa-si-${BNAME} > /dev/null
+       svn export -r "${BRANCH_REV}" https://oss.gonicus.de/repositories/gosa/${BRANCH}/gosa-plugins gosa-plugins-${BNAME} > /dev/null
+else
+        # Export from local checkout...
+        echo "Exporting current GOsa (rev: ${BRANCH_REV}) from localcheckout '${BRANCH}'..."
+       BNAME=$(basename $BRANCH)
+       cp -r gosa-core gosa-${GOSA_VER}
+       mv gosa-si gosa-si-${GOSA_VER}
+       mv gosa-plugins gosa-plugins-${BNAME}
+fi
+
+if [ "$NO_SVN" = "use" ]
+then
+        VERSION=$(cat "gosa-${BNAME}/debian/changelog" | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
+fi
+
+#if [ "$BRANCH" == "trunk" ]; then
+#      GOSA_VER="${VERSION}+svn${BRANCH_REV}"
+#else
+#      GOSA_VER="${VERSION}"
+#fi
 
-VERSION=$(cat "gosa-${BRANCH}/debian/changelog" | head -n 1 | sed -n -e 's/.*(\([^-]*\).*/\1/p')
-GOSA_VER="${VERSION}+svn${BRANCH_REV}"
 GOSA_DIR="gosa-${GOSA_VER}"
 GOSA_SI_DIR="gosa-si-${GOSA_VER}"
 
-if [ -d "gosa-${GOSA_VER}" ]
+if [ "$NO_SVN" = "use" ]
 then
-       rm -rf "gosa-${GOSA_VER}"
+       if [ "$BNAME" != "$GOSA_VER" ]
+       then
+               rm -rf "gosa-${GOSA_VER}"
+       fi
 fi
-mv "gosa-${BRANCH}" "gosa-${GOSA_VER}"
-mv "gosa-si-${BRANCH}" "gosa-si-${GOSA_VER}"
+
+if [ "$NO_SVN" = "use" ]
+then
+       if [ "$BNAME" != "$GOSA_VER" ]
+       then
+               mv "gosa-${BNAME}" "gosa-${GOSA_VER}"
+               mv "gosa-si-${BNAME}" "gosa-si-${GOSA_VER}"
+       fi
+fi
+
+echo "cleaning svn entries from sources"
+find ${GOSA_DIR} -type d -name ".svn" -exec rm -rf {} \; >/dev/null 2>&1
+find ${GOSA_SI_DIR} -type d -name ".svn" -exec rm -rf {} \; >/dev/null 2>&1
+find gosa-plugins-${BNAME} -type d -name ".svn" -exec rm -rf {} \; >/dev/null 2>&1
 
 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
-       MAKE_PLUGINS=$(ls -1 gosa-plugins-${BRANCH}/*/plugin.dsc | sed 's/^.*\/\([^\/]*\)\/plugin.dsc$/\1/')
+       MAKE_PLUGINS=$(ls -1 gosa-plugins-${BNAME}/*/plugin.dsc | sed 's/^.*\/\([^\/]*\)\/plugin.dsc$/\1/')
+       for i in $NOT_RELEASED; do
+               MAKE_PLUGINS=$(echo -n $MAKE_PLUGINS | sed "s/$i//")
+       done
 fi
+
 for plugin in $MAKE_PLUGINS; do
 
        GOSA_PLUG_DIR="gosa-plugin-$plugin-${GOSA_VER}"
-       mv "gosa-plugins-${BRANCH}/$plugin" .
+
+       echo "gosa plugin dir" $GOSA_PLUG_DIR
+
+       mv "gosa-plugins-${BNAME}/$plugin" .
 
        echo "Debianizing plugin $plugin"
-       yes | dh-make-gosa --section web $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}
+rm -rf gosa-plugins-${BNAME}
 
 echo "Deploying patches..."
 for patch in $(find patches -type f | grep -v .svn); do
@@ -154,7 +237,7 @@ for patch in $(find patches -type f | grep -v .svn); do
        fi
 done
 
-# Passe section im GOsa_DIR an
+# Put section in GOsa_DIR
 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
 
@@ -163,7 +246,11 @@ for plugin in $MAKE_PLUGINS; do
 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}-1${TARGET_RELEASE}1" -D "$TARGET_RELEASE" "$RELEASE_REASON" >/dev/null 2>&1)
+       if [ "$TARGET_RELEASE" == "unstable" ]; then
+               (cd "$dir"; echo | debchange -v "${GOSA_VER}" "$RELEASE_REASON" >/dev/null 2>&1)
+       else
+               (cd "$dir"; echo | debchange -v "${GOSA_VER}-1${TARGET_RELEASE}1" -D "$TARGET_RELEASE" "$RELEASE_REASON" >/dev/null 2>&1)
+       fi
        [ -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
@@ -186,7 +273,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
+       done
+fi
+