mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: ptxdist@pengutronix.de
Cc: mol@pengutronix.de, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [ptxdist] [PATCH] ptxdist: support multiple targets per command
Date: Mon, 11 Jun 2012 17:54:10 +0200	[thread overview]
Message-ID: <1339430050-31347-1-git-send-email-mkl@pengutronix.de> (raw)

Without this patch ptxdist supports only one target per command. With
this patch, ptxdist supports multiple targets, e.g.:

    ptxdist clean libpcap tcpdump

or

    ptxdist targetinstall kernel ncurses

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 bin/ptxdist |   79 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 51 insertions(+), 28 deletions(-)

diff --git a/bin/ptxdist b/bin/ptxdist
index 9c96fc6..e10c03d 100755
--- a/bin/ptxdist
+++ b/bin/ptxdist
@@ -674,18 +674,10 @@ check_deps() {
 }
 
 
-
 #
 # checks if the given PTXCONF_ option is actually selected
 #
-check_if_selected() {
-	if [ -z "${1}" ]; then
-		echo
-		echo "${PTXDIST_LOG_PROMPT}error: please specify a target"
-		echo
-		exit 1
-	fi
-
+check_if_selected_single() {
 	local configvar="PTXCONF_$(ptxd_name_to_NAME "${1}")"	# FIXME
 	ptxd_get_ptxconf "${configvar}" > /dev/null || {
 		if [ ${?} -eq 2 ]; then
@@ -702,6 +694,44 @@ check_if_selected() {
 }
 
 
+#
+# checks if all the given PTXCONF_ option are actually selected
+#
+check_if_selected() {
+	if [ -z "${1}" ]; then
+		echo
+		echo "${PTXDIST_LOG_PROMPT}error: please specify a target"
+		echo
+		exit 1
+	fi
+
+	while [ ${#} -ne 0 ]; do
+	    check_if_selected_single "${1}" || return
+	    shift
+	done
+}
+
+
+#
+# check if the given packages can be targetinstalled
+#
+# (host and cross packaged
+#
+check_targetinstall_pkgs() {
+	while [ ${#} -ne 0 ]; do
+	    case "${1}" in
+		host-*|cross-*)
+		    ptxd_dialog_msgbox \
+			"error: 'host' or 'cross' packages cannot be targetinstalled!\n" \
+			"\n" \
+			"       You probably want to do: 'ptxdist install ${1}'"
+		    return 1
+		    ;;
+	    esac
+	    shift
+	done
+}
+
 
 #
 # runs the standard tests before calling into make:
@@ -910,8 +940,8 @@ clean() {
 
 	# we want to clean a single package
 	if [ -n "${1}" ]; then
-		check_if_selected "${1}" &&
-		ptxd_make_log "${1}_clean"
+		check_if_selected "${@}" &&
+		ptxd_make_log "${@/%/_clean}"
 		return
 	fi
 
@@ -1558,32 +1588,23 @@ parse_second()
 
 		extract|prepare|compile|install|targetinstall|tags)
 			local cmd_post
-			local pkg="${1}"
+			declare -a pkgs
 
 			check_premake_compiler &&
-			check_if_selected "${pkg}" &&
+			check_if_selected "${@}" &&
 
 			case "${cmd}" in
 			    install)
 				cmd_post=".post"
 				;;
-
 			    targetinstall)
 				cmd_post=".post"
-
-				case "${pkg}" in
-				    host-*|cross-*)
-					ptxd_dialog_msgbox \
-					    "error: 'host' or 'cross' packages cannot be '${cmd}'ed!\n" \
-					    "\n" \
-					    "       You probably want to do: 'ptxdist install ${pkg}'"
-					return 1
-					;;
-				esac
+				check_${cmd}_pkgs "${@}"
 				;;
 			esac &&
 
-			ptxd_make_log "${STATEDIR}/${pkg}.${cmd}${cmd_post}"
+			pkgs=( "${@/#/${STATEDIR}/}" ) &&
+			ptxd_make_log "${pkgs[@]/%/.${cmd}${cmd_post}}"
 			exit
 			;;
 
@@ -1672,7 +1693,7 @@ EOF
 		clean)
 			check_config &&
 			check_deps &&
-			clean "${1}"
+			clean "${@}"
 			exit
 			;;
 		clone)
@@ -1730,13 +1751,15 @@ EOF
 			exit
 			;;
 		get)
+			declare -a pkgs
 			check_premake &&
 
 			if [ ${#} -eq 0 ]; then
 				ptxd_make_log get
 			else
-				check_if_selected "${1}" &&
-				ptxd_make_log "${STATEDIR}/${1}.get"
+				check_if_selected "${@}" &&
+				pkgs=( "${@/#/${STATEDIR}/}" ) &&
+				ptxd_make_log "${pkgs[@]/%/.get}"
 			fi
 			exit
 			;;
-- 
1.7.4.1


-- 
ptxdist mailing list
ptxdist@pengutronix.de

                 reply	other threads:[~2012-06-11 15:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1339430050-31347-1-git-send-email-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=mol@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox