[SCM] xbmc packaging branch, master, updated. upstream/9.11.svn24886.deb1-57-gfa2cf59

ceros-guest at users.alioth.debian.org ceros-guest at users.alioth.debian.org
Wed Dec 9 18:36:36 UTC 2009


The following commit has been merged in the master branch:
commit 28eb0c64fbe32f46f4558fa1b5dc2f78654b0d6d
Author: Andres Mejia <mcitadel at gmail.com>
Date:   Sun Dec 6 16:54:25 2009 -0500

    Simplify maintainer scripts for xbmc-live.

diff --git a/debian/xbmc-live.postinst b/debian/xbmc-live.postinst
index ce83b46..4d9cf9c 100755
--- a/debian/xbmc-live.postinst
+++ b/debian/xbmc-live.postinst
@@ -55,47 +55,40 @@ case "$1" in
 		fi
 	done
 
-	SUDOERS="$(cat /etc/sudoers)"
 
-	XBMC_ENTRIES="### XBMC-specific configuration ###
-	# XBMC
-	Cmnd_Alias SHUTDOWN_CMDS = /sbin/shutdown, /sbin/reboot, /sbin/halt # XBMC
-	Cmnd_Alias MOUNT_CMDS = /bin/mount, /bin/umount # XBMC
-	$xbmcUser ALL=(ALL) ALL # XBMC
-	$xbmcUser ALL=NOPASSWD: SHUTDOWN_CMDS, MOUNT_CMDS # XBMC"
+	SUDOERSBLOCK_TEMPFILE=$(mktemp -q)
+
+	cat > $SUDOERSBLOCK_TEMPFILE <<ENDOFBLOCK
+### XBMC-specific configuration ###
+# XBMC
+Cmnd_Alias SHUTDOWN_CMDS = /sbin/shutdown, /sbin/reboot, /sbin/halt # XBMC
+Cmnd_Alias MOUNT_CMDS = /bin/mount, /bin/umount # XBMC
+$xbmcUser ALL=(ALL) ALL # XBMC
+$xbmcUser ALL=NOPASSWD: SHUTDOWN_CMDS, MOUNT_CMDS # XBMC
+ENDOFBLOCK
 
 	SUDOERS_TEMPFILE=$(mktemp -q)
 
 	# Add xbmc to the sudoers file (if not already done)
-	# Here we make use of perl to check the current sudoers file and create one
-	# for us in case we need to add the xbmc specific entries.
-	if ! perl -e '$sudoers=$ARGV[0]; $entries=$ARGV[1];' \
-	    -e '$entries =~ s/^\s*?(\S)/$1/msg;' \
-	    -e '($sudoers =~ m/$entries/ms) ? exit 0 : exit 1;' \
-	    "$SUDOERS" "$XBMC_ENTRIES"; then
-
-	    # First write a sudoers file to a tempfile.
-	    perl -e '$sudoers=$ARGV[0]; $entries=$ARGV[1];' \
-		-e '$entries =~ s/^\s*?(\S)/$1/msg;' \
-		-e '$sudoers =~ s/\Q### XBMC-specific configuration ###\E\n//g;' \
-		-e '$sudoers =~ s/\n.*# XBMC.*//g;' \
-		-e 'chomp $sudoers;' \
-		-e 'print "$sudoers\n\n$entries\n";' \
-		"$SUDOERS" "$XBMC_ENTRIES" >$SUDOERS_TEMPFILE
-
-	    # Check if sudoers file is ok with visudo and write to /etc/sudoers if
-	    # it is ok, else display a message to the user.
-	    if visudo -c -f $SUDOERS_TEMPFILE >/dev/null 2>&1; then
-		cat $SUDOERS_TEMPFILE >/etc/sudoers
-	    else
-		# TODO: Use debconf for this message.
-		echo "Couldn't edit /etc/sudoers, must be manually edited."
-		echo "Please edit /etc/sudoers using 'visudo' and add the following"
-		echo "entries:"
-		echo "$XBMC_ENTRIES"
-	    fi
+	if ! grep -i -q XBMC-specific /etc/sudoers ; then 
+		cat /etc/sudoers $SUDOERSBLOCK_TEMPFILE > $SUDOERS_TEMPFILE
+
+		# Check if sudoers file is ok with visudo and write to /etc/sudoers if
+		# it is ok, else display a message to the user.
+		if visudo -c -f $SUDOERS_TEMPFILE >/dev/null 2>&1; then
+			cp $SUDOERS_TEMPFILE /etc/sudoers
+		else
+			# TODO: Use debconf for this message.
+			echo "Couldn't edit /etc/sudoers, must be manually edited."
+			echo "Please edit /etc/sudoers using 'visudo' and add the following"
+			echo "entries:"
+			cat $SUDOERSBLOCK_TEMPFILE
+		fi
 	fi
+
 	rm $SUDOERS_TEMPFILE
+	rm $SUDOERSBLOCK_TEMPFILE
+
 
 	# Our set of PolicyKit actions
 
diff --git a/debian/xbmc-live.postrm b/debian/xbmc-live.postrm
index f067ad3..f1516cb 100755
--- a/debian/xbmc-live.postrm
+++ b/debian/xbmc-live.postrm
@@ -5,38 +5,24 @@
 
 set -e
 if [ "$1" = "purge" ]; then
-	SUDOERS="$(cat /etc/sudoers)"
-
 	SUDOERS_TEMPFILE=$(mktemp -q)
 
-	# Check if there are XBMC specific entries in /etc/sudoers and remove
-	# them if so. This makes use of perl for checking and writing a sudoers
-	# file
-	if perl -e '$sudoers=$ARGV[0]; $entries=$ARGV[1];' \
-	    -e '($sudoers =~ m/$entries/ms) ? exit 0 : exit 1;' \
-	    "$SUDOERS" "### XBMC-specific configuration ###"; then
+	# Add xbmc to the sudoers file (if not already done)
+	if ! grep -i -q XBMC-specific /etc/sudoers ; then 
+		cat /etc/sudoers > $SUDOERS_TEMPFILE
 
-	    # First write a sudoers file to a tempfile.
-	    perl -e '$sudoers=$ARGV[0];' \
-		-e '$sudoers =~ s/\Q### XBMC-specific configuration ###\E\n//g;' \
-		-e '$sudoers =~ s/\n.*# XBMC.*//g;' \
-		-e 'chomp $sudoers;' \
-		-e 'print "$sudoers\n";' \
-		"$SUDOERS" >$SUDOERS_TEMPFILE
+		sed -i -e "/XBMC/d" $SUDOERS_TEMPFILE
 
-	    # Check if sudoers file is ok with visudo and write to /etc/sudoers if
-	    # it is ok, else display a message to the user.
-	    if visudo -c -f $SUDOERS_TEMPFILE >/dev/null 2>&1; then
-		cat $SUDOERS_TEMPFILE >/etc/sudoers
-	    else
-		# TODO: Use debconf for this message.
-		echo "Couldn't edit /etc/sudoers, must be manually edited."
-		echo "Please edit /etc/sudoers using 'visudo' and add the following"
-		echo "entries:"
-		echo "$XBMC_ENTRIES"
-	    fi
+		# Check if sudoers file is ok with visudo and write to /etc/sudoers if
+		# it is ok, else display a message to the user.
+		if visudo -c -f $SUDOERS_TEMPFILE >/dev/null 2>&1; then
+			cat $SUDOERS_TEMPFILE > /etc/sudoers
+		else
+			# TODO: Use debconf for this message.
+			echo "Couldn't edit /etc/sudoers, must be manually edited."
+			echo "Please edit /etc/sudoers using 'visudo' and remove the lines with 'XBMC'"
+		fi
 	fi
-	rm $SUDOERS_TEMPFILE
 
 	POLKIT_ACTIONS="org.freedesktop.hal.dockstation.undock
 		org.freedesktop.hal.wol.enabled

-- 
xbmc packaging



More information about the pkg-multimedia-commits mailing list