-
Notifications
You must be signed in to change notification settings - Fork 0
/
qt-switcher
154 lines (135 loc) · 5.86 KB
/
qt-switcher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# Using this script you can easily switch between your installed Qt versions
# This script is intended to be used on ArchLinux with the compiled Qt versions of the following qt pkgbuilds: http://github.com/friesoft/archlinux-friesoft-pkgbuilds/tree/master
# Copyleft Bernhard Friedreich (friesoft), 2009
# Usage: source ./qt-switcher
checkQtInstallations()
{
echo -e "\r\nSearching for installed Qt versions via pacman"
qtversioncount="1"
######################## DEFAULT INSTALL PATH ########################
# search for a qt-stable package which is installed in your default path --> no parallel package
default_path=`pacman -Qq | grep -E "^qt-stable*" | grep -v parallel`
if [ -n "$default_path" ]; then
# No stable package in /usr found - search for unstable
# search for a qt-unstable package which is installed in your default path --> no parallel package
default_path=`pacman -Qq | grep -E "^qt-unstable*" | grep -v parallel`
if [ -n "$default_path" ]; then
# No unstable package in /usr found - search for experimental
# search for a qt-experimental package which is installed in your default path --> no parallel package
default_path=`pacman -Qq | grep -E "^qt-experimental*" | grep -v parallel`
if [ -n "$default_path" ]; then
echo "No Qt installation by friesoft has been found in /usr - I strongly advice you to use my stuff :P"
else
echo "Found Qt experimental installed in /usr default installation path"
fi
else
echo "Found Qt unstable installed in /usr default installation path"
fi
else
echo "Found Qt stable installed in /usr default installation path"
fi
######################## DEFAULT INSTALL PATH ########################
parallel_experimental=`pacman -Qq | grep -E "^qt-experimental*" | grep parallel`
echo -e "\r\nFound the following experimental Qt versions installed in parallel:"
echo $parallel_experimental
parallel_unstable=`pacman -Qq | grep -E "^qt-unstable*" | grep parallel`
echo -e "\r\nFound the following unstable Qt versions installed in parallel:"
echo $parallel_unstable
parallel_stable=`pacman -Qq | grep -E "^qt-stable*" | grep parallel`
echo -e "\r\nFound the following stable Qt versions installed in parallel:"
echo $parallel_stable
# TODO: show a list with numbers about the installed versions and share it with the "askForUserInput" function
# TODO: save the list of installed packages
# TODO: offer option to install new (not yet installed) qt version
# TODO: show userfriendly strings (e.g. instead of "qt-unstable-git-parallel" show "Qt Unstable installed in /opt/qt-unstable")
#if "qt-experimental-kinetic-declarative-git"
# printInstalledQtVersion $qtversioncount "Default path (/usr) - Qt Experimental kinetic declarative"
#fi
#echo -n " (1) Default path (/usr)"
#echo -n " (2) Qt Stable 4.5"
#echo -n " (3) Qt Stable 4.6"
#echo -n " (4) Qt Unstable (master)"
#echo -n " (5) Qt Experimental - kinetic clone (head - animations)"
#echo -n " (6) Qt Experimental - kinetic clone (declarativeui)"
}
printInstalledQtVersion()
{
echo -n " $1 $2"
}
askForUserInput()
{
echo -n "Switch to Qt version: "
read -n 1 key
switchQtVersion $key
returnvalue=$?
while [ "$returnvalue" -ne "0" ]
do
askForUserInput
done
}
switchQtVersion()
{
# TODO: clear PATH and LD_LIBRARY_PATH before setting again - otherwise those paths will fill up if using qt-switcher more than once
qttargetversion=""
case "$1" in
"1")
qttargetversion="Default path (/usr)"
export PATHSAVE="$PATH"
export LDSAVE="$LD_LIBRARY_PATH"
export QTDIR="/usr"
export PATH="$QTDIR/bin:$PATHSAVE"
export LD_LIBRARY_PATH="$QTDIR/lib:$LDSAVE"
;;
"2")
qttargetversion="Qt Stable 4.5"
export PATHSAVE="$PATH"
export LDSAVE="$LD_LIBRARY_PATH"
export QTDIR="/opt/qt-stable-4.5"
export PATH="$QTDIR/bin:$PATHSAVE"
export LD_LIBRARY_PATH="$QTDIR/lib:$LDSAVE"
;;
"3")
qttargetversion="Qt Stable 4.6"
export PATHSAVE="$PATH"
export LDSAVE="$LD_LIBRARY_PATH"
export QTDIR="/opt/qt-stable-4.6"
export PATH="$QTDIR/bin:$PATHSAVE"
export LD_LIBRARY_PATH="$QTDIR/lib:$LDSAVE"
;;
"4")
qttargetversion="Qt Unstable"
export PATHSAVE="$PATH"
export LDSAVE="$LD_LIBRARY_PATH"
export QTDIR="/opt/qt-unstable"
export PATH="$QTDIR/bin:$PATHSAVE"
export LD_LIBRARY_PATH="$QTDIR/lib:$LDSAVE"
;;
"5")
qttargetversion="Qt Experimental kinetic"
export PATHSAVE="$PATH"
export LDSAVE="$LD_LIBRARY_PATH"
export QTDIR="/opt/qt-experimental/kinetic"
export PATH="$QTDIR/bin:$PATHSAVE"
export LD_LIBRARY_PATH="$QTDIR/lib:$LDSAVE"
;;
"6")
qttargetversion="Qt Experimental kinetic - declarativeui"
export PATHSAVE="$PATH"
export LDSAVE="$LD_LIBRARY_PATH"
export QTDIR="/opt/qt-experimental/kinetic-declarative"
export PATH="$QTDIR/bin:$PATHSAVE"
export LD_LIBRARY_PATH="$QTDIR/lib:$LDSAVE"
;;
*)
echo -e "\r\n\r\nWrong input! Please try again\r\n\r\n"
return 1
;;
esac
echo -e "\r\n\r\nSwitching Qt version to "$qttargetversion
return
}
echo "Welcome to the Qt version switcher by friesoft - Have fun :-)"
checkQtInstallations
askForUserInput
echo "Finished setting up your dev environment! - Have fun hacking (with) Qt!"