# HG changeset patch
# User Antoine Bodin <gokhlayeh@slitaz.org>
# Date 1324075833 -3600
# Node ID 79d46277d7f9544db44b8ca44c257d8a29806f1f
# Parent  e584450f5f0e3f6fa6135079f2247b5b55495f0e
pam, busybox-pam: trigger the proper reinstallation of busybox before removing them

diff -r e584450f5f0e -r 79d46277d7f9 busybox-pam/receipt
--- a/busybox-pam/receipt	Fri Dec 16 20:31:59 2011 +0100
+++ b/busybox-pam/receipt	Fri Dec 16 23:50:33 2011 +0100
@@ -14,17 +14,24 @@
 # Rules to gen a SliTaz package suitable for Tazpkg.
 genpkg_rules()
 {
-    mkdir -p $fs/bin
-    cp -a $src/busybox-pam $fs/bin/busybox
-    cp -a $stuff/* $fs
+	mkdir -p $fs/bin
+	cp -a $src/busybox-pam $fs/bin/busybox
+	cp -a $stuff/* $fs
 }
 
 pre_remove()
 {
-    tazpkg get-install  ${PACKAGE%-pam}
+	# We install non-pam busybox to replace busybox-pam.
+	tazpkg get-install ${PACKAGE%-pam} --forced
+
+	# We remove /bin/busybox from the file.list of busybox-pam.
+	# This way, the non-pam busybox we just installed will not be
+	# removed.
+	sed '/\/bin\/busybox/d' \
+		-i /var/lib/tazpkg/installed/busybox-pam/files.list
 }
 
 post_install()
 {
-    chmod 4755 $1/bin/busybox
+	chmod 4755 $1/bin/busybox
 }
diff -r e584450f5f0e -r 79d46277d7f9 pam/receipt
--- a/pam/receipt	Fri Dec 16 20:31:59 2011 +0100
+++ b/pam/receipt	Fri Dec 16 23:50:33 2011 +0100
@@ -37,3 +37,13 @@
 	rm -f $fs/lib/security/*.la
 	cp -a $stuff/* $fs	
 }
+
+pre_remove()
+{
+	# If busybox-pam is installed, trigger its removal right now. Once pam shared
+	# library will be removed, it will be too late. Don't worry about this, while
+	# removing busybox-pam will replace itself by a non-pam busybox.
+	if [ -d /var/lib/tazpkg/installed/busybox-pam ]; then
+		tazpkg remove busybox-pam --auto
+	fi
+}