From 8bb6431fe1740f5f7fffaa8214a9b4e930754432 Mon Sep 17 00:00:00 2001
From: P. J. McDermott <pjm@nac.net>
Date: Wed, 19 Feb 2014 20:02:00 -0500
Subject: Unify alternatives lists into one file.

This file is used at build time and install/remove time.
---
diff --git a/alternatives b/alternatives
new file mode 100644
index 0000000..f5281e5
--- /dev/null
+++ b/alternatives
@@ -0,0 +1,6 @@
+/usr/bin/awk awk 10
+/usr/bin/ar ar 10
+/usr/bin/strings strings 10
+/usr/bin/clear clear 10
+/usr/bin/reset reset 10
+/usr/bin/mkpasswd mkpasswd 10
diff --git a/build b/build
index 80d4b74..c50860e 100755
--- a/build
+++ b/build
@@ -31,18 +31,13 @@ install:
 	oh-fixperms
 	oh-strip
 	chmod u+s dest/bin/busybox
-	set -e; for path in \
-			/usr/bin/awk \
-			/usr/bin/ar \
-			/usr/bin/strings \
-			/usr/bin/clear \
-			/usr/bin/reset \
-			/usr/bin/mkpasswd \
-			; do \
-		if [ -e "dest/$${path}" ]; then \
-			mv "dest/$${path}" "dest/$${path}.busybox"; \
+	set -e; while read link name prio; do \
+		if [ -e "dest/$${link}" ]; then \
+			mv "dest/$${link}" "dest/$${link}.busybox"; \
 		fi; \
-	done
+	done <../alternatives
+	mkdir -p dest/usr/share/busybox
+	cp ../alternatives dest/usr/share/busybox
 	set -e; $(config_enabled); $(install_init_script); \
 	if config_enabled INIT; then \
 		install -d -m 0755 dest/etc; \
diff --git a/busybox.pkg/postinst b/busybox.pkg/postinst
index 2120eeb..a9922b6 100755
--- a/busybox.pkg/postinst
+++ b/busybox.pkg/postinst
@@ -6,12 +6,5 @@ if [ "x${1}" = 'xconfigure' ]; then
 			update-alternatives --install "${link}" "${name}" \
 				"${link}.busybox" "${prio}"
 		fi
-	done <<-EOF
-		/usr/bin/awk awk 10
-		/usr/bin/ar ar 10
-		/usr/bin/strings strings 10
-		/usr/bin/clear clear 10
-		/usr/bin/reset reset 10
-		/usr/bin/mkpasswd mkpasswd 10
-		EOF
+	done </usr/share/busybox/alternatives
 fi
diff --git a/busybox.pkg/prerm b/busybox.pkg/prerm
index 5e7cf79..9565cab 100755
--- a/busybox.pkg/prerm
+++ b/busybox.pkg/prerm
@@ -5,12 +5,5 @@ if [ "${1}" = remove ]; then
 		if [ -e "${link}.busybox" ]; then
 			update-alternatives --remove "${name}" "${link}.busybox"
 		fi
-	done <<-EOF
-		/usr/bin/awk awk 10
-		/usr/bin/ar ar 10
-		/usr/bin/strings strings 10
-		/usr/bin/clear clear 10
-		/usr/bin/reset reset 10
-		/usr/bin/mkpasswd mkpasswd 10
-		EOF
+	done </usr/share/busybox/alternatives
 fi
--
cgit v0.9.1