[Pkg-virtualbox-commits] [virtualbox-ext-pack] 01/01: Move the license check to the preinstall script.

Unit 193 unit193-guest at moszumanska.debian.org
Mon Jan 11 21:39:26 UTC 2016


This is an automated email from the git hooks/post-receive script.

unit193-guest pushed a commit to branch master
in repository virtualbox-ext-pack.

commit 936c98aea61565e1756af215dae0faece1b94e34
Author: Unit 193 <unit193 at ubuntu.com>
Date:   Mon Jan 11 16:39:21 2016 -0500

    Move the license check to the preinstall script.
---
 debian/changelog |  1 +
 debian/control   |  1 +
 debian/postinst  | 17 ++++++----------
 debian/preinst   | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 0b4de34..f22ef66 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 virtualbox-ext-pack (5.0.12-2) UNRELEASED; urgency=medium
 
   * d/prerm: Ignore failures on file removal if nonexistent.
+  * Move the license check to the preinstall script.
 
  -- Unit 193 <unit193 at ubuntu.com>  Mon, 11 Jan 2016 16:12:06 -0500
 
diff --git a/debian/control b/debian/control
index 7273b8c..0197b94 100644
--- a/debian/control
+++ b/debian/control
@@ -12,6 +12,7 @@ Vcs-Browser: http://anonscm.debian.org/gitweb/?p=pkg-virtualbox/virtualbox-ext-p
 
 Package: virtualbox-ext-pack
 Architecture: all
+Pre-Depends: debconf
 Depends: virtualbox (>= 5.0) | virtualbox-5.0, wget, ${misc:Depends}
 Description: extra capabilities for VirtualBox, downloader.
  VirtualBox requires an extension pack to provide support for Remote
diff --git a/debian/postinst b/debian/postinst
index fa3ef87..657a44b 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -15,17 +15,12 @@ error ()
 . /usr/share/debconf/confmodule
 
 if [ "$1" = "configure" ] ; then
-        db_get virtualbox-ext-pack/license
-        if [ "$RET" = true ] ; then
-		cd /usr/share/virtualbox-ext-pack
-		echo "virtualbox-ext-pack: downloading: http://download.virtualbox.org/virtualbox/$version/$file"
-		echo "The file will be downloaded into /usr/share/virtualbox-ext-pack"
-		wget -q -N http://download.virtualbox.org/virtualbox/$version/$file
-		echo "$hash  $file" | sha256sum -c > /dev/null 2>&1 || error
-		vboxmanage extpack install --replace $file
-	else
-		exit 1
-	fi
+	cd /usr/share/virtualbox-ext-pack
+	echo "virtualbox-ext-pack: downloading: http://download.virtualbox.org/virtualbox/$version/$file"
+	echo "The file will be downloaded into /usr/share/virtualbox-ext-pack"
+	wget -q -N http://download.virtualbox.org/virtualbox/$version/$file
+	echo "$hash  $file" | sha256sum -c > /dev/null 2>&1 || error
+	vboxmanage extpack install --replace $file
 fi
 
 #DEBHELPER#
diff --git a/debian/preinst b/debian/preinst
new file mode 100644
index 0000000..9ff6b11
--- /dev/null
+++ b/debian/preinst
@@ -0,0 +1,62 @@
+#!/bin/sh
+set -e
+
+#DEBHELPER#
+
+# Source debconf library.
+. /usr/share/debconf/confmodule
+
+errmsg()
+{
+    echo >&2 ''
+    echo >&2 "$@"
+    echo >&2 "try 'dpkg-reconfigure debconf' to select a frontend other than noninteractive"
+    echo >&2 ''
+}
+
+db_get virtualbox-ext-pack/license
+if [ "$RET" = "true" ]; then
+    echo "License has already been accepted." >&2
+    exit 0
+else
+    # show license again
+    db_fset virtualbox-ext-pack/license seen false
+fi
+
+# facilitate backup capability per debconf-devel(7)
+STATE=1
+while true; do
+    case "$STATE" in
+    0)  # ensure going back from license presentment is harmless
+        STATE=1
+        continue
+        ;;
+    1)  # present license
+        if ! db_get virtualbox-ext-pack/license ; then
+            errmsg "Could not display license."
+            exit 1
+        fi
+        if [ "$RET" = "true" ]; then
+            # license accepted
+            exit 0
+        fi
+        ;;
+    2)  # user has confirmed declining license
+        echo "User did not accept the license." >&2
+        exit 1
+        ;;
+    *)  # unknown state
+        echo "State unknown: $STATE" >&2
+        exit 2
+        ;;
+    esac
+    if db_go; then
+        STATE=$(($STATE + 1))
+    else
+        STATE=$(($STATE - 1))
+    fi
+done
+
+# proper exit (0 or 1) above
+errmsg "License could not be presented / was not accepted."
+exit 2

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-virtualbox/virtualbox-ext-pack.git



More information about the Pkg-virtualbox-commits mailing list