From 41d829c1647e42b003fbf3d98c8c600c5e2fdf2a Mon Sep 17 00:00:00 2001
From: P. J. McDermott <pjm@nac.net>
Date: Sun, 29 Jan 2012 21:58:22 -0500
Subject: Use correct architecture name in oh-buildopk.

The interface and logic is changed to resemble that of oh-gencontrol.
---
(limited to 'src/oh-buildopk')

diff --git a/src/oh-buildopk b/src/oh-buildopk
index 3d67596..3021aa2 100644
--- a/src/oh-buildopk
+++ b/src/oh-buildopk
@@ -20,34 +20,86 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . @@LIBDIR@@/opkhelper/controlfields
+. @@LIBDIR@@/opkhelper/architecture
 
 print_usage()
 {
-	printf 'Usage: %s pkgname...\n' "$1"
+	printf 'Usage: %s -s | pkgname...\n' "$1"
 }
 
-if [ ${#} -eq 0 ]; then
-	print_usage ${0} >&2
-	exit 1
+opts=$(getopt -n "${0}" -o 's' -- "${@}")
+if [ ${?} -ne 0 ]; then
+	print_usage "${0}" >&2
+	exit 1;
 fi
+eval set -- "${opts}"
+while true; do
+	case "${1}" in
+		-s)
+			is_srcpkg=true
+			shift
+			;;
+		--)
+			shift
+			break
+			;;
+		*)
+			print_usage "${0}" >&2
+			exit 1
+			;;
+	esac
+done
 
-# Iterate over packages.
-while [ ${#} -gt 0 ]; do
-	printf 'oh-buildopk: Packing package "%s"...\n' "${1}"
+if [ -n "${is_srcpkg}" ]; then
+	pkg="${OH_SRCPKG}-src"
 
 	# Write debian-binary.
 	echo '2.0' > debian-binary || exit 2
+
 	# Pack data.tar.gz.
-	cd ${1}.data
+	cd ${pkg}.data
 	tar -czf ../data.tar.gz . || exit 2
 	cd ..
+
 	# Pack control.tar.gz.
-	cd ${1}.control
+	cd ${pkg}.control
 	tar -czf ../control.tar.gz . || exit 2
 	cd ..
+
 	# Pack opk file.
-	tar -czf ../../${1}_$(oh_get_field Version)_arch.opk \
+	tar -czf ../../${pkg}_${OH_PKGVER}-${OH_PKGREV}_all.opk \
 		debian-binary data.tar.gz control.tar.gz || exit 2
 	rm -Rf debian-binary control data.tar.gz control.tar.gz || exit 2
-	shift
-done
+else
+	if [ ${#} -eq 0 ]; then
+		print_usage ${0} >&2
+		exit 1
+	fi
+
+	# Iterate over packages.
+	while [ ${#} -gt 0 ]; do
+		printf 'oh-buildopk: Packing package "%s"...\n' "${1}"
+
+		arch="$(oh_get_package_architecture ${1})"
+	
+		# Write debian-binary.
+		echo '2.0' > debian-binary || exit 2
+
+		# Pack data.tar.gz.
+		cd ${1}.data
+		tar -czf ../data.tar.gz . || exit 2
+		cd ..
+
+		# Pack control.tar.gz.
+		cd ${1}.control
+		tar -czf ../control.tar.gz . || exit 2
+		cd ..
+
+		# Pack opk file.
+		tar -czf ../../${1}_${OH_PKGVER}-${OH_PKGREV}_${arch}.opk \
+			debian-binary data.tar.gz control.tar.gz || exit 2
+		rm -Rf debian-binary control data.tar.gz control.tar.gz || exit 2
+
+		shift
+	done
+fi
--
cgit v0.9.1