summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2014-06-20 12:47:17 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2014-06-20 12:50:36 +0200
commitece2c10678a8835089b22d3d74e40bbefe495a23 (patch)
tree6c877df34a8de4c625702c32b9a934f8dcf512fe /bin
parent65fcce610bbe37243bfe32493b0c173075b9a2f9 (diff)
downloadptxdist-ece2c10678a8835089b22d3d74e40bbefe495a23.tar.gz
ptxdist-ece2c10678a8835089b22d3d74e40bbefe495a23.tar.xz
ptxdist: add '--auto-version' and helper script
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ptxdist42
-rwxr-xr-xbin/ptxdist-auto-version24
2 files changed, 61 insertions, 5 deletions
diff --git a/bin/ptxdist b/bin/ptxdist
index 2183684af..e1aa51e17 100755
--- a/bin/ptxdist
+++ b/bin/ptxdist
@@ -247,10 +247,7 @@ check_version() {
-#
-# check the ptxconfig file
-#
-_check_config_ptx() {
+_get_config_ptx() {
if [ ! -e "${PTXDIST_PTXCONFIG}" ]; then
ptxd_dialog_msgbox \
"error: '${PTXDIST_PTXCONFIG#${PTXDIST_WORKSPACE}/}' file is missing\n" \
@@ -263,7 +260,6 @@ _check_config_ptx() {
return
fi
- local configfile_version
configfile_version="$(ptxd_get_ptxconf PTXCONF_CONFIGFILE_VERSION)" || {
ptxd_dialog_msgbox \
"error: the config file '${PTXDIST_PTXCONFIG#${PTXDIST_WORKSPACE}/}'\n" \
@@ -274,6 +270,15 @@ _check_config_ptx() {
" 'ptxdist clone <project>' to clone an existing project"
return 1
}
+}
+
+#
+# check the ptxconfig file
+#
+_check_config_ptx() {
+ local configfile_version
+
+ _get_config_ptx
check_version "${configfile_version}" || {
ptxd_dialog_msgbox \
@@ -986,6 +991,7 @@ Options:
--git use git to apply patches
+ --auto-version automatically switch to the correct PTXdist version
EOF
}
@@ -1280,6 +1286,9 @@ parse_first()
# overwrite default from ptxdistrc
export PTXCONF_SETUP_CHECK="update"
;;
+ --auto-version)
+ PTXDIST_AUTOVERSION=1
+ ;;
--)
while [ ${#} -ne 0 ]; do
arg="${1}"
@@ -2277,6 +2286,27 @@ setup_config() {
+setup_auto_version()
+{
+ local configfile_version
+
+ if [ -z "${PTXDIST_AUTOVERSION}" ]; then
+ return
+ fi
+
+ _get_config_ptx
+ if ! check_version "${configfile_version}"; then
+ local next
+ if next="$(which ptxdist-${configfile_version})"; then
+ exec "${next}" "${PTXDIST_ARGS_FULL[@]}"
+ else
+ ptxd_bailout "ptxdist-${configfile_version} not found!"
+ fi
+ fi
+}
+
+
+
#
# this function defines which args are allowed in case of a broken
# config during "setup_platform"
@@ -2548,6 +2578,8 @@ main() {
parse_first &&
# --- vars to config files are setup ---
+ setup_auto_version &&
+
setup_platform &&
# --- platformdir and other *dirs are available from here ---
# --- all variables are defined now ---
diff --git a/bin/ptxdist-auto-version b/bin/ptxdist-auto-version
new file mode 100755
index 000000000..2f6414ae0
--- /dev/null
+++ b/bin/ptxdist-auto-version
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+#
+# bash implementation of realpath / readlink -f
+# arg1 - filename
+realpath()
+{
+ local fname oldfname
+
+ fname="${1%/}" # strips trailing '/'
+ while [ -L "${fname}" ]; do
+ oldfname="${fname}"
+ fname="$(readlink "${fname}")"
+ if [ "${fname}" = "." ] ; then
+ fname="$(dirname "${oldfname}")"
+ elif [ "${fname}" = "${fname#/}" ]; then
+ fname="$(dirname "${oldfname}")/${fname}"
+ fi
+ done
+
+ (cd "$(dirname "${fname}")"; echo $(pwd -P)/$(basename "${fname}"))
+}
+
+exec "$(dirname $(realpath "$0"))/ptxdist" --auto-version "${@}"