From d279f01adb41c67e0671a15950875093bf32d537 Mon Sep 17 00:00:00 2001
From: Daniel Schwager <daniel.schwager@dtnet.de>
Date: Sat, 4 Feb 2012 10:55:24 +0100
Subject: [PATCH] New: Added  OPSI_REPOS_OPSIMANAGER_INSTALL to
 opsi-builder.cfg. If set, the created opsi-package will be automatically
 installed to the depot

---
 conf/opsi-builder.cfg  | 16 ++++++++++------
 lib/builder-targets.sh |  5 +++++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/conf/opsi-builder.cfg b/conf/opsi-builder.cfg
index ed485a1..8bd0573 100644
--- a/conf/opsi-builder.cfg
+++ b/conf/opsi-builder.cfg
@@ -60,19 +60,23 @@ OPSI_REPOS_PRODUCT_DIR=${OPSI_REPOS_BASE_DIR}/${STATUS}/${VENDOR}/${PN}/${VERSIO
 OPSI_REPOS_FILE_PATTERN=${PN}_${VERSION}-${CREATOR_TAG}${RELEASE}
 
 # Force alway upload  to opsi repos
+# Target: publish, Valid values: true|false, Default: false
 # OPSI_REPOS_FORCE_UPLOAD=true
 
-# define the artifacts uploading to the repository
-# Default:
-#  OPSI_REPOS_UPLOAD_SOURCE        : product directory
+# define the artifacts uploading to the repository (OPSI_REPOS_FORCE_UPLOAD must be "true")
+#  OPSI_REPOS_UPLOAD_SOURCE        product directory
 #  OPSI_REPOS_UPLOAD_OPSI          : opsi package
-#  OPSI_REPOS_UPLOAD_BIN           : file used by opsi package creation
-#  OPSI_REPOS_UPLOAD_OPSI_ZSYNC    : additional files (*.md5, *.zsync) to sync opsi package using opsi-product-updater
+#  OPSI_REPOS_UPLOAD_BIN           : File used by opsi package creation
+#  OPSI_REPOS_UPLOAD_OPSI_ZSYNC    : Additional files (*.md5, *.zsync) to sync opsi package using opsi-product-updater
+#  OPSI_REPOS_OPSIMANAGER_INSTALL  : Install the created opsi packet automatically after building
+#      It equal to the command "opsi-package-manager -i"
+#      Note: the OPSI_REPOS_BASE_DIR must be RW for the user pcpatch. 
+#            You must be member of the unix group pcpatch&opsiadmin
 OPSI_REPOS_UPLOAD_OPSI=true
 OPSI_REPOS_UPLOAD_OPSI_ZSYNC=false
 OPSI_REPOS_UPLOAD_SOURCE=true
 OPSI_REPOS_UPLOAD_BIN=false
-
+OPSI_REPOS_OPSIMANAGER_INSTALL=false
 
 ###############################
 # Distribution / Vendor settings
diff --git a/lib/builder-targets.sh b/lib/builder-targets.sh
index ede1de1..f1f4910 100644
--- a/lib/builder-targets.sh
+++ b/lib/builder-targets.sh
@@ -271,6 +271,11 @@ builder_publish() {
 	builder_check_error "Can't upload file ${dst}-src.zip --> ${dst}-src.zip"
     fi
 
+    if [ "${OPSI_REPOS_OPSIMANAGER_INSTALL}" = "true" ] ; then
+	opsi-package-manager -i -v ${dst}.opsi
+	builder_check_error "Can't install ${dst}.opsi"
+    fi
+
     if [ "${OPSI_REPOS_UPLOAD_OPSI_ZSYNC}" = "true" ] ; then 
 	md5sum "${dst}.opsi" | sed 's/ .*//' > ${dst}.opsi.md5
 	builder_check_error "Can't create md5 file"