-
Notifications
You must be signed in to change notification settings - Fork 289
/
merge2out-gui
executable file
·256 lines (224 loc) · 7.06 KB
/
merge2out-gui
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/bash
# function to make the radiobuttons for the dialog box
config_radiobuttons () {
while [ "$1" != '' ]; do
if [ "$1" = "$DBUILD" ]; then
echo -n ' <radiobutton active="true">
<label>'"$1"'</label>
<variable>'"${1}"'</variable>
</radiobutton>
'
else
echo -n ' <radiobutton>
<label>'"$1"'</label>
<variable>'"${1}"'</variable>
</radiobutton>
'
fi
shift
done
}
export -f config_radiobuttons
[ -f ./woof.conf ] && . ./woof.conf
CURRENT_DIR=$PWD
if [ -d woof-CE ]; then
cd woof-CE
elif [ -d ../woof-CE ]; then
cd ../woof-CE
fi
ALL_BUILDS=""
for ONE_ARCH in $(find woof-distro -mindepth 1 -maxdepth 1 -type d | sed -e 's%^woof-distro/%%' | sort | tr '\n' ' ')
do
taPTN="s%^woof-distro/${ONE_ARCH}/%%"
for ONE_DISTRO in $(find woof-distro/${ONE_ARCH} -mindepth 1 -maxdepth 1 -type d | sed -e "${taPTN}" | sort | tr '\n' ' ')
do
for ONE_COMPAT in $(find woof-distro/${ONE_ARCH}/${ONE_DISTRO} -maxdepth 1 -mindepth 1 -type d | rev | cut -f 1 -d '/' | rev | sort | tr '\n' ' ')
do
ALL_BUILDS="$ALL_BUILDS ${ONE_ARCH}/${ONE_DISTRO}/${ONE_COMPAT}"
done
done
done
cd $CURRENT_DIR
START_DIR=${CURRENT_DIR%/woof-CE}
ALTERNATE_BUILD_STATE="false"
ALTERNATE_BUILD_ACTIVE=''
if [ -d "$ALTERNATE_BUILD" -a -f "${ALTERNATE_BUILD}/DISTRO_SPECS" ]; then
ALTERNATE_BUILD_STATE="true"
if [ "$BUILD" = "" ]; then
ALTERNATE_BUILD_ACTIVE=' active="true"'
else
ALTERNATE_BUILD_ACTIVE=''
fi
fi
if [ "$ENABLE_EXTRA_MERGE" ] ; then
ALT_BUILD_RD=' <radiobutton sensitive="'${ALTERNATE_BUILD_STATE}'"'${ALTERNATE_BUILD_ACTIVE}'>
<label>ALTERNATE_BUILD</label>
<variable>ALTERNATE_BUILD_SELECTED</variable>
</radiobutton>
<hbox>
<entry accept="directory" fs-folder="'${START_DIR}'">
<variable>BUILD_DIRECTORY</variable>
<default>'${ALTERNATE_BUILD:-optional}'</default>
<action condition="command_is_true([ -d \"$BUILD_DIRECTORY\" -a -f \"${BUILD_DIRECTORY}/DISTRO_SPECS\" ] && echo true)">enable:ALTERNATE_BUILD_SELECTED</action>
<action condition="command_is_false([ ! -d \"$BUILD_DIRECTORY\" -o ! -f \"${BUILD_DIRECTORY}/DISTRO_SPECS\" ] && echo false)">disable:ALTERNATE_BUILD_SELECTED</action>
</entry>
<button>
<input file stock="gtk-open"></input>
<variable>FILE_BROWSE1</variable>
<action type="fileselect">BUILD_DIRECTORY</action>
</button>
</hbox>'
EXTRA_MERGE_DLG=' <frame EXTRA_MERGE>
<hbox>
<entry accept="directory" fs-folder="'${START_DIR}'">
<variable>MERGE_DIRECTORY</variable>
<default>'${EXTRA_MERGE:-optional}'</default>
</entry>
<button>
<input file stock="gtk-open"></input>
<variable>FILE_BROWSE2</variable>
<action type="fileselect">MERGE_DIRECTORY</action>
</button>
</hbox>
</frame>'
fi
DBUILD=$BUILD #this is to select the active radio button
[ -z "$DBUILD" ] && DBUILD=none
MAIN_DIALOG='<window title="merge2out-gui" height-request="500" width-request="300">
<vbox scrollable="true">
<frame Select build>
'$(config_radiobuttons none ${ALL_BUILDS})'
'${ALT_BUILD_RD}'
</frame>
'${EXTRA_MERGE_DLG}'
<hbox>
<button cancel></button>
<button ok></button>
</hbox>
</vbox>
</window>'
export MAIN_DIALOG
# Uncomment the following line to see the finished dialog.
# echo "$MAIN_DIALOG"
GTKDIALOG_RESULT="`gtkdialog --center --program=MAIN_DIALOG`"
# Uncomment the following line to see any errors for debugging.
# echo "$GTKDIALOG_RESULT"
if echo "$GTKDIALOG_RESULT" | grep -q 'none="true"' ; then
[ -f woof.conf ] && sed -i '/^BUILD=/d' woof.conf
exit
fi
for ONE_VAR in $GTKDIALOG_RESULT
do
case $ONE_VAR in
EXIT*)
if [ "${ONE_VAR%\"cancel\"}" != "$ONE_VAR" ]; then
exit
elif [ "${ONE_VAR%\"OK\"}" != "$ONE_VAR" ]; then
EXIT_OK="true"
fi
;;
arm*|x86*|x86_64*)
if [ "${ONE_VAR%\"true\"}" != "$ONE_VAR" ]; then
NEW_BUILD="BUILD=\"${ONE_VAR%=\"true\"}\""
fi
;;
ALTERNATE_BUILD_SELECTED*)
if [ "${ONE_VAR%\"true\"}" != "$ONE_VAR" ]; then
NEW_BUILD="BUILD=\"\""
fi
;;
MERGE_DIRECTORY*)
EXTRA_MERGE=${ONE_VAR#MERGE_DIRECTORY=}
EXTRA_MERGE=${EXTRA_MERGE//\"}
if [ -d "$EXTRA_MERGE" ]; then
EXTRA_MERGE=$(realpath ${EXTRA_MERGE})
NEW_EXTRA_MERGE="EXTRA_MERGE=\"${EXTRA_MERGE}\""
else
NEW_EXTRA_MERGE="EXTRA_MERGE=\"\""
fi
;;
BUILD_DIRECTORY*)
ALTERNATE_BUILD=${ONE_VAR#BUILD_DIRECTORY=}
ALTERNATE_BUILD=${ALTERNATE_BUILD//\"}
if [ -d "$ALTERNATE_BUILD" -a -f "${ALTERNATE_BUILD}/DISTRO_SPECS" ]; then
ALTERNATE_BUILD=$(realpath ${ALTERNATE_BUILD})
NEW_ALTERNATE_BUILD="ALTERNATE_BUILD=\"${ALTERNATE_BUILD}\""
else
NEW_ALTERNATE_BUILD="ALTERNATE_BUILD=\"\""
fi
;;
esac
done
if [ "$EXIT_OK" = "true" ]; then
if [ -e woof.conf ]; then
# update each line in existing file
sed -i '/^$/d' woof.conf
( #>> woof.conf.new
while read LINE ; do
case $LINE in
"EXTRA_MERGE="*) echo "$NEW_EXTRA_MERGE" ;;
"BUILD="*) echo "$NEW_BUILD" ;;
"ALTERNATE_BUILD="*) echo "$NEW_ALTERNATE_BUILD" ;;
*) echo "$LINE" ;;
esac
done < woof.conf
# If any variables were not set in the original config file, add them to the new config file.
grep -q '^EXTRA_MERGE=' woof.conf.new || echo "$NEW_EXTRA_MERGE"
grep -q '^BUILD=' woof.conf.new || echo "$NEW_BUILD"
grep -q '^ALTERNATE_BUILD=' woof.conf.new || echo "$NEW_ALTERNATE_BUILD"
) >> woof.conf.new
mv woof.conf.new woof.conf
else
# otherwise write new woof.conf
echo "# This is the config file for merge2out-gui" > woof.conf
echo >> woof.conf
echo "$NEW_BUILD" >> woof.conf
if [ "$ENABLE_EXTRA_MERGE" ] ; then
echo "$NEW_EXTRA_MERGE" >> woof.conf
echo "$NEW_ALTERNATE_BUILD" >> woof.conf
fi
fi
. ./woof.conf
TARGETARCH=${BUILD%%/*}
# echo "TARGETARCH = $TARGETARCH"
export TARGETARCH
COMPATDISTRO=${BUILD%/*}
COMPATDISTRO=${COMPATDISTRO#*/}
# echo "COMPATDISTRO = $COMPATDISTRO"
export COMPATDISTRO
COMPATVERSION=${BUILD##*/}
# echo "COMPATVERSION = $COMPATVERSION"
export COMPATVERSION
[ -d $EXTRA_MERGE ] && export EXTRA_MERGE
# try to find a terminal emulator
# TERMINAL_COMMAND could be set in woof.conf
if [ "`which urxvt`" != '' ]; then
TERMCMND="${TERMINAL_COMMAND:-urxvt}"
elif [ "`which rxvt`" != '' ]; then
TERMCMND="${TERMINAL_COMMAND:-rxvt}"
elif [ "`which lxterminal`" != '' ]; then
TERMCMND="${TERMINAL_COMMAND:-lxterminal}"
elif [ "`which xterm`" != '' ]; then
TERMCMND="${TERMINAL_COMMAND:-xterm}"
elif [ "`which konsole`" != '' ]; then
TERMCMND="${TERMINAL_COMMAND:-konsole}"
elif [ "`which gnome-terminal`" != '' ]; then
TERMCMND="${TERMINAL_COMMAND:-gnome-terminal}"
fi
if [ -d woof-CE ]; then
cd woof-CE
elif [ -d ../woof-CE ]; then
cd ../woof-CE
fi
if [ "$TERMCMND" != '' ]; then
if [ "$BUILD" = "" ]; then
$TERMCMND -e sh -c "./merge2out $ALTERNATE_BUILD ; echo 'Press <Enter> to continue' ; read VAR"
else
$TERMCMND -e sh -c "./merge2out ; echo 'Press <Enter> to continue' ; read VAR"
fi
else
# if running on a system so minimal that it has no terminal emulator
# there is no reason for running this script instead of merge2out
echo "Cannot find a terminal emulator."
fi
fi