@@ -8,13 +8,21 @@ usage: ./install [options]
8
8
Options:
9
9
10
10
-n, --dry-run list what would be done without making any changes.
11
- Display a list of steps when run with --build or --update.
11
+ Display a list of steps when run with --update, --build
12
+ or --clean.
13
+
12
14
--update[=steps] perform all or selected software updates from online
13
15
source repositories. Update steps are comma separated
14
16
integers or ranges such as '1,3,5-6'. Use option -n to
15
17
display the steps.
18
+
16
19
--build[=steps] rebuild all or specified packages from sources in the
17
20
src folder. Use option -n to display the build steps.
21
+
22
+ --clean[=steps] remove generated files from the source folders of the
23
+ specified packages. This ensures that --build is run
24
+ from a pristine state.
25
+
18
26
-h, --help display this message and exit
19
27
"
20
28
@@ -66,7 +74,8 @@ SRCDIR=${BASEDIR}/src
66
74
PTHFILE=${BASEDIR} /diffpy_cmi.pth
67
75
VERSION=$( cd $BASEDIR && test -s VERSION.txt && < VERSION.txt)
68
76
69
- typeset -aU build_selection update_selection
77
+ typeset -aU clean_selection build_selection update_selection
78
+ clean_selection=( )
70
79
build_selection=( )
71
80
update_selection=( )
72
81
HASHLINE=${(l: 78::#: ):- }
@@ -92,13 +101,14 @@ export LIBRARY_PATH=${BASEDIRSHORT}/lib:\$LIBRARY_PATH
92
101
# Extract command-line options -----------------------------------------------
93
102
94
103
zmodload zsh/zutil
95
- zparseopts -K -E -D \
104
+ zparseopts -D -E \
96
105
n=opt_dryrun -dry-run=opt_dryrun \
97
- h=opt_help -help=opt_help -update::=opt_update -build::=opt_build ||
106
+ h=opt_help -help=opt_help \
107
+ -clean::=opt_clean -update::=opt_update -build::=opt_build ||
98
108
exit $?
99
109
100
110
if [[ -n $* ]]; then
101
- print -u2 " Invalid arguments or options : $* "
111
+ print -u2 " Invalid option : $* "
102
112
exit 2
103
113
fi
104
114
@@ -223,6 +233,7 @@ adjust_macosx_environment() {
223
233
}
224
234
225
235
236
+ integer CIDX=0
226
237
integer UIDX=0
227
238
integer BIDX=0
228
239
@@ -231,6 +242,10 @@ ListSkipOrDo() {
231
242
local idx
232
243
typeset -gA didheader
233
244
case $1 in
245
+ (clean)
246
+ idx=$(( ++ CIDX ))
247
+ selection=( $clean_selection )
248
+ ;;
234
249
(build)
235
250
idx=$(( ++ BIDX ))
236
251
selection=( $build_selection )
@@ -264,6 +279,57 @@ ListSkipOrDo() {
264
279
}
265
280
266
281
282
+ do_clean () {
283
+ local PS4=" >> "
284
+ local msg_noupdate
285
+ MSG_NOCLEAN=" No cleanup needed for this package. Skipped."
286
+ ListSkipOrDo clean " src/pycifrw (N/A)" || {
287
+ print $MSG_NOCLEAN
288
+ } || return $?
289
+ ListSkipOrDo clean " src/diffpy.Structure" || (
290
+ setopt xtrace
291
+ cd $SRCDIR /diffpy.Structure &&
292
+ rm -rf build temp diffpy.Structure.egg-info
293
+ ) || return $?
294
+ ListSkipOrDo clean " src/diffpy.utils" || (
295
+ setopt xtrace
296
+ cd $SRCDIR /diffpy.utils &&
297
+ rm -rf build temp diffpy.utils.egg-info
298
+ ) || return $?
299
+ ListSkipOrDo clean " src/periodictable (N/A)" || {
300
+ print $MSG_NOCLEAN
301
+ } || return $?
302
+ ListSkipOrDo clean " src/libobjcryst" || (
303
+ setopt xtrace
304
+ cd $SRCDIR /libobjcryst && $SCONS --clean
305
+ ) || return $?
306
+ ListSkipOrDo clean " src/pyobjcryst" || (
307
+ setopt xtrace
308
+ cd $SRCDIR /pyobjcryst &&
309
+ rm -rf build temp pyobjcryst.egg-info
310
+ ) || return $?
311
+ ListSkipOrDo clean " src/libdiffpy" || (
312
+ setopt xtrace
313
+ cd $SRCDIR /libdiffpy && $SCONS --clean
314
+ ) || return $?
315
+ ListSkipOrDo clean " src/diffpy.srreal" || (
316
+ setopt xtrace
317
+ cd $SRCDIR /diffpy.srreal &&
318
+ rm -rf build temp diffpy.srreal.egg-info
319
+ ) || return $?
320
+ ListSkipOrDo clean " src/diffpy.srfit" || (
321
+ setopt xtrace
322
+ cd $SRCDIR /diffpy.srfit &&
323
+ rm -rf build temp diffpy.srreal.egg-info
324
+ ) || return $?
325
+ ListSkipOrDo clean " src/srfit-sasview" || {
326
+ setopt xtrace
327
+ cd $SRCDIR /srfit-sasview &&
328
+ rm -rf build temp srfit_sasview.egg-info
329
+ } || return $?
330
+ }
331
+
332
+
267
333
do_update () {
268
334
local PS4=" >> "
269
335
local msg_noupdate
@@ -483,6 +549,11 @@ do_install() {
483
549
484
550
# Main section here ----------------------------------------------------------
485
551
552
+ if [[ -n ${opt_clean} ]]; then
553
+ expand_ranges clean_selection ${${opt_clean## --clean=# } :- all}
554
+ do_clean || exit $?
555
+ fi
556
+
486
557
if [[ -n ${opt_update} ]]; then
487
558
expand_ranges update_selection ${${opt_update## --update=# } :- all}
488
559
do_update || exit $?
@@ -493,6 +564,6 @@ if [[ -n ${opt_build} ]]; then
493
564
do_build || exit $?
494
565
fi
495
566
496
- if [[ -z " ${opt_update}${opt_build} " ]]; then
567
+ if [[ -z " ${opt_clean}${ opt_update}${opt_build} " ]]; then
497
568
do_install
498
569
fi
0 commit comments