summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.in2
-rwxr-xr-xbin/ptxdist42
-rwxr-xr-xbin/ptxdist-auto-version24
4 files changed, 63 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 16a273359..b1fef9423 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,4 @@ scripts/kconfig/lxdialog/*.o
/bin/*
!/bin/ptxdist
+!/bin/ptxdist-auto-version
diff --git a/Makefile.in b/Makefile.in
index 5387f1dbb..64dc80874 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -103,7 +103,7 @@ install: all dirty-check
@mkdir -p "$(DESTDIR)$(bindir)"
@rm -f "$(DESTDIR)$(bindir)/ptxdist"
@ln -sf "$(instdir)/bin/ptxdist" "$(DESTDIR)$(bindir)/ptxdist-$(version)"
- @ln -sf "$(instdir)/bin/ptxdist" "$(DESTDIR)$(bindir)/ptxdist"
+ @ln -sf "$(instdir)/bin/ptxdist-auto-version" "$(DESTDIR)$(bindir)/ptxdist"
@if [ -d "$(DESTDIR)@BASH_COMPLETION_DIR@" -a \
-w "$(DESTDIR)@BASH_COMPLETION_DIR@" ]; then \
cp scripts/bash_completion "$(DESTDIR)@BASH_COMPLETION_DIR@/ptxdist"; \
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 "${@}"