Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 895 lines (757 sloc) 22.068 kb
effac9f initial commit
niXman authored
1 #!/bin/bash
2
3 #
4 # The BSD 3-Clause License. http://www.opensource.org/licenses/BSD-3-Clause
5 #
6 # This file is part of mingw-env project.
7 # Copyright (c) 2011,2012, by niXman (i dotty nixman doggy gmail dotty com)
8 # All rights reserved.
9 # Project: mingw-env ( http://sourceforge.net/projects/mingw-env/ )
10 #
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions are met:
13 # - Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # - Redistributions in binary form must reproduce the above copyright
16 # notice, this list of conditions and the following disclaimer in
17 # the documentation and/or other materials provided with the distribution.
18 # - Neither the name of the 'mingw-env' nor the names of its contributors may
19 # be used to endorse or promote products derived from this software
20 # without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 # A PARTICULAR PURPOSE ARE DISCLAIMED.
26 # IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
27 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
32 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #
34
35 # **************************************************************************
36 # **************************************************************************
37 # **************************************************************************
38
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
39 source common/utils.mfun
40 source common/version.mfun
41 source common/packaging.mfun
42
43 # constants
44 MINGW_ENV_VERSION="0.1.0"
45 BUG_URL='http://sourceforge.net/projects/mingw-env/'
46 PKGVERSION='Built by mingw-env project'
47 TAB_STOP=3
48
effac9f initial commit
niXman authored
49 IS_LINUX_HOST=no
50 IS_WINDOWS_HOST=no
51 IS_MACOSX_HOST=no
52
53 case $OSTYPE in
54 linux-gnu) IS_LINUX_HOST=yes ;;
55 msys) IS_WINDOWS_HOST=yes ;;
56 darwin*) IS_MACOSX_HOST=yes ;;
57 *) echo "bad host. terminate."; exit 1 ;;
58 esac
59
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
60 VIEWVER_NAME=""
61
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
62 [[ $# > 0 && ${@:1} != --install ]] && {
effac9f initial commit
niXman authored
63 [[ -n $MINGW_ENV ]] && {
f57e4e6 @Alexpux Some refactoring
Alexpux authored
64 . $MINGW_ENV/common/config.sh
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
65 func_find_logviewer \
66 LOGVIEWERS[@] \
67 VIEWVER_NAME
68 [[ $? != 0 ]] && {
69 echo "can not find default logviewer."
70 }
effac9f initial commit
niXman authored
71 }
72 }
73
74 # **************************************************************************
75
76 # check if mingw-env already installed
77 function func_mingw_env_installed {
78 [[ ! -f $HOME/.profile ]] && return 1 # not installed
79 [[ -n $(cat $HOME/.profile | grep 'MINGW_ENV') ]] && {
80 [[ -z $MINGW_ENV ]] && {
81 return 2 # installed. need to restart the shell.
82 } || {
83 return 0 # installed and shell restarted.
84 }
85 }
86 return 1 # not installed
87 }
88
89 # **************************************************************************
90
91 # prepare mingw-env environment
92 function func_make_environment {
93 # $1 - $MINGW_ENV
94 # $2 - $WORK_DIR
95
96 # common variable
97 ROOT_DIR=$1
f57e4e6 @Alexpux Some refactoring
Alexpux authored
98 COMMON_DIR=$ROOT_DIR/common
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
99 METADATA_DIR=$ROOT_DIR/metadata
effac9f initial commit
niXman authored
100 RULES_DIR=$ROOT_DIR/rules
101 PATCHES_DIR=$ROOT_DIR/patches
102 TESTS_DIR=$ROOT_DIR/tests
103 DATA_DIR=$ROOT_DIR/data
104 DATA_TOOLS_DIR=$DATA_DIR/tools
105 DATA_MARKERS_DIR=$DATA_DIR/markers
106 DATA_STATE_DIR=$DATA_DIR/states
107
108 # work dir variable
109 BUILDS_DIR=$2/builds
110 LOGS_DIR=$2/logs
111 SRCS_DIR=$2/srcs
112 PACKAGES_DIR=$2/packages
113
114 # installed packages list
115 INSTALLED_PACKAGES_FILENAME=$DATA_MARKERS_DIR/installed_packages.list
116
117 # tab marker
118 TAB_LEVEL=0
119 }
120
121 # **************************************************************************
122
123 # install mingw-env
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
124 function func_mingw_env_install {
effac9f initial commit
niXman authored
125 # $1 - path for install too
126
127 [[ ! -f ./mingw-env ]] && {
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
128 echo "run install from the mingw-env root directory."
effac9f initial commit
niXman authored
129 return 1
130 }
131
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
132 mkdir -p $1/data || return 1
133 cp ./mingw-env $1 || return 1
f57e4e6 @Alexpux Some refactoring
Alexpux authored
134 cp -r $COMMON_DIR $1 || return 1
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
135 cp -r $METADATA_DIR $1 || return 1
effac9f initial commit
niXman authored
136 cp -r $RULES_DIR $1 || return 1
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
137 cp -r $PATCHES_DIR $1 || return 1
effac9f initial commit
niXman authored
138 cp -r $TESTS_DIR $1 || return 1
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
139 cp -r $DATA_TOOLS_DIR $1/data || return 1
effac9f initial commit
niXman authored
140
141 [[ ! -f $HOME/.profile ]] && {
142 touch $HOME/.profile
143 }
144
145 mv $HOME/.profile $HOME/.profile.back && \
146 echo "export MINGW_ENV=$1" > $HOME/.profile && \
147 echo "export PATH=\$MINGW_ENV:\$PATH" >> $HOME/.profile && \
148 cat $HOME/.profile.back >> $HOME/.profile && \
149 rm $HOME/.profile.back
150
151 [[ $? != 0 ]] && {
152 rm -fR $1
153 echo "can't setup MINGW_ENV environment variable."
154 return 1
155 }
156
157 return 0
158 }
159
160 # uninstall mingw-env
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
161 function func_mingw_env_uninstall {
effac9f initial commit
niXman authored
162 sed /MINGW_ENV/d -i $HOME/.profile
163 rm -fR $MINGW_ENV
164 }
165
166 # **************************************************************************
167
168 # create state of the prefix dir
169 function func_create_state {
170 # $1 - state name
171
172 [[ -f $DATA_STATE_DIR/$1.marker ]] && {
173 echo ""
174 echo "state \"$1\" already exists. terminate."
175 exit 1
176 }
177
178 touch $DATA_STATE_DIR/$1.marker
179 }
180
181 # restore state of the prefix dir
182 function func_restore_state {
183 # $1 - state name
184
185 [[ ! -f $DATA_STATE_DIR/$1.marker ]] && {
186 echo "state \"$1\" does not exist. terminate."
187 exit 1
188 }
189
190 local _prev=$PWD
191 cd $PREFIX_DIR
192 find . -type f -newer $DATA_STATE_DIR/$1.marker | xargs rm -fR > /dev/null 2>&1
193 find . -type d -newer $DATA_STATE_DIR/$1.marker | xargs rmdir -p > /dev/null 2>&1
194 cd $_prev
195
196 [[ $1 != initial ]] && {
197 rm -f $DATA_STATE_DIR/$1.marker
198 }
199 }
200
201 # **************************************************************************
202
203 function func_is_valid_package {
204 # $1 - (meta)package name
205
206 RULE_TYPE=""
207 RULE_NAME=""
208
a1d918c @Alexpux Add new functions to process packages
Alexpux authored
209 . $1
effac9f initial commit
niXman authored
210
211 [[ -z $RULE_TYPE || -z $RULE_NAME ]] && {
212 echo "package \"$1\" is not for using directly. terminate."
213 exit 1
214 }
215 }
216
217 # **************************************************************************
218
219 # create the error report
220 function func_create_error_report {
221 # $1 - (meta)package name
222 # $2 - report name
223
224 echo ""
225 }
226
227 # **************************************************************************
228
229 # create the absolute path to relative
230 function func_absolute_to_relative {
231 local common_part=$1
232 local target=$2
233 local back=""
234
235 while [[ "${target#$common_part}" == "${target}" ]]; do
236 common_part=$(dirname $common_part)
237 back="../${back}"
238 done
239
240 echo "${back}${target#$common_part/}"
241 }
242
243 # **************************************************************************
244
245 # create common dirs
246 function func_create_common_dirs {
247 mkdir -p \
248 $WORK_DIR \
249 $PREFIX_DIR \
250 $BUILDS_DIR \
251 $LOGS_DIR \
252 $SRCS_DIR \
253 $PACKAGES_DIR \
254 $DATA_TOOLS_DIR \
255 $DATA_MARKERS_DIR \
256 $DATA_STATE_DIR
257 }
258
259 # **************************************************************************
260 # **************************************************************************
261 # **************************************************************************
262
263 case $1 in
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
264 --install)
effac9f initial commit
niXman authored
265 [[ $# != 2 ]] && {
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
266 echo "usage: mingw-env --install <path>"
effac9f initial commit
niXman authored
267 exit 1
268 }
269
270 # check if mingw-env already installed
271 func_mingw_env_installed
272 _function_result=$?
273 [[ $_function_result == 0 ]] && {
274 # already installed
275 echo "already installed."; exit 0
276 } || {
277 [[ $_function_result == 2 ]] && {
278 # already installed
279 echo "already installed. need to restart the shell."
280 exit 0
281 }
282 }
283
284 # load config
f57e4e6 @Alexpux Some refactoring
Alexpux authored
285 . common/config.sh
effac9f initial commit
niXman authored
286
287 # prepare environment
288 func_make_environment "$PWD" ""
289
290 # installing
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
291 func_mingw_env_install $2
effac9f initial commit
niXman authored
292 [[ $? != 0 ]] && {
293 echo "error on installig. terminate."
294 exit 1
295 }
296
297 echo "successfully installed. please restart the shell."
298 exit 0
299 ;;
300
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
301 --uninstall)
effac9f initial commit
niXman authored
302 [[ $# != 1 ]] && {
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
303 echo "usage: mingw-env --uninstall"
effac9f initial commit
niXman authored
304 exit 1
305 }
306
307 # check if mingw-env already installed
308 func_mingw_env_installed
309 _function_result=$?
310 [[ $_function_result == 1 ]] && {
311 echo "mingw-env is not installed. terminate."
312 exit 1
313 } || {
314 [[ $_function_result == 2 ]] && {
315 # already installed
316 echo "mingw-env installed. need to restart the shell."
317 exit 0
318 }
319 }
320
321 # prepare environment
322 func_make_environment $MINGW_ENV ""
323
324 # uninstall
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
325 func_mingw_env_uninstall
effac9f initial commit
niXman authored
326 [[ $? == 0 ]] && {
327 echo "successfully uninstalled."
328 exit 0
329 } || {
330 echo "error on uninstallig. terminate."
331 exit 1
332 }
333 ;;
334
335 --version|-v)
336 echo "mingw-env-$MINGW_ENV_VERSION"
337 exit 0
338 ;;
339
340 # print list of available packages
341 --list)
342 [[ $# > 2 ]] && {
343 echo "usage: mingw-env --list [substring]"
344 exit 1
345 }
346
347 # check if mingw-env already installed
348 func_mingw_env_installed
349 _function_result=$?
350 [[ $_function_result == 1 ]] && {
351 echo "mingw-env is not installed. terminate."; exit 1
352 } || {
353 [[ $_function_result == 2 ]] && {
354 echo "mingw-env installed. need to restart the shell."
355 exit 0
356 }
357 }
358
359 # set up environment
360 func_make_environment $MINGW_ENV $WORK_DIR
361
362 # print list of available packages
363 [[ $# == 1 ]] && {
364 func_print_packages ""
365 } || {
366 func_print_packages ${@:2}
367 }
368 exit 0
369 ;;
370
371 # print list of installed packages
372 --installed)
373 [[ $# != 1 ]] && {
374 echo "usage: mingw-env --installed"
375 exit 1
376 }
377
378 # check if mingw-env already installed
379 func_mingw_env_installed
380 _function_result=$?
381 [[ $_function_result == 1 ]] && {
382 echo "mingw-env is not installed. terminate."
383 exit 1
384 } || {
385 [[ $_function_result == 2 ]] && {
386 echo "mingw-env installed. need to restart the shell."
387 exit 0
388 }
389 }
390
391 # set up environment
392 func_make_environment $MINGW_ENV $WORK_DIR
393
394 # print list of installed packages
395 func_print_installed_packages
396 exit 0
397 ;;
398
399 # update mingw-env sources from repository
400 --update)
401 exit 0
402 ;;
403
404 # propose package for include in mingw-env
405 --propose-package)
406 exit 0
407 ;;
408
409 # create bug-report for specified package
410 --create-report)
411 exit 0
412 ;;
413
414 # fix current state of the prefix path
415 --create-state)
416 [[ $# != 2 ]] && {
417 echo "usage: mingw-env --create-state <state name>"
418 exit 1
419 }
420
421 # check if mingw-env already installed
422 func_mingw_env_installed
423 _function_result=$?
424 [[ $_function_result == 1 ]] && {
425 echo "mingw-env is not installed. terminate."
426 exit 1
427 } || {
428 [[ $_function_result == 2 ]] && {
429 echo "mingw-env installed. need to restart the shell."
430 exit 0
431 }
432 }
433
434 # set up environment
435 func_make_environment $MINGW_ENV $WORK_DIR
436
437 # create
438 func_create_common_dirs
439
440 echo -n "create state \"$2\"... "
441 func_create_state $2
442 echo "done."
443 exit 0
444 ;;
445
446 # restore state of the prefix path content.
447 # if state name is not specified - restore last state.
448 --restore-state)
449 [[ $# != 2 ]] && {
450 echo "usage: mingw-env --restore-state <state name>"
451 exit 1
452 }
453
454 # check if mingw-env already installed
455 func_mingw_env_installed
456 _function_result=$?
457 [[ $_function_result == 1 ]] && {
458 echo "mingw-env is not installed. terminate."
459 exit 1
460 } || {
461 [[ $_function_result == 2 ]] && {
462 echo "mingw-env installed. need to restart the shell."
463 exit 0
464 }
465 }
466
467 # set up environment
468 func_make_environment $MINGW_ENV $WORK_DIR
469
470 # restore specified state
471 echo -n "restore state \"$2\"... "
472 func_restore_state $2
473 echo "done."; exit 0
474 ;;
475
476 # install
477 --install)
478 [[ $# < 2 ]] && {
479 echo "usage: mingw-env --install <packages list>"
480 exit 1
481 }
482
483 # check if mingw-env already installed
484 func_mingw_env_installed
485 _function_result=$?
486 [[ $_function_result == 1 ]] && {
487 echo "mingw-env is not installed. terminate."
488 exit 1
489 } || {
490 [[ $_function_result == 2 ]] && {
491 echo "mingw-env installed. need to restart the shell."
492 exit 0
493 }
494 }
495
496 # check used compiler
497 [[ $USE_HOST_COMPILER == no && -z $DEFAULT_MINGW_VERSION ]] && {
498 echo "please set default mingw version in config file (DEFAULT_MINGW_VERSION). terminate."
499 exit 1
500 }
501 [[ $USE_HOST_COMPILER == yes && -n $(echo $@ | grep -oi mingw) ]] && {
502 echo "you can't build the new host compiler while USE_HOST_COMPILER is set to \"yes\""
503 exit 1
504 }
505
506 # append the PATH environment
507 [[ $USE_HOST_COMPILER == no ]] && {
508 export PATH=$PREFIX_DIR/bin:$PREFIX_DIR/lib:$PATH
509 }
510
511 # set up environment
512 func_make_environment $MINGW_ENV $WORK_DIR
513
514 # create
515 func_create_common_dirs
516
517 # create initial state
518 [[ ! -f $DATA_STATE_DIR/initial.marker ]] && {
519 echo -n "first run. create initial state... "
520 func_create_state initial
521 echo "done."
522 }
523
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
524 OIFS=$IFS
525 IFS=" "
526 _pkg_list=(${@:2})
527 IFS=$OIFS;
528 _inst_list=(`func_set_pkg_list _pkg_list[@]`)
a1d918c @Alexpux Add new functions to process packages
Alexpux authored
529 for it in "${_inst_list[@]}"; do
530 [[ ! -f $it ]] && {
effac9f initial commit
niXman authored
531 echo "package \"$it\" is not exists. terminate."
532 exit 1
533 }
534 func_processing "$it" "no" "install" "yes" ""
535 done
536 ;;
537
538 # uninstall specified packages
539 --uninstall)
540 [[ $# < 2 ]] && {
541 echo "usage: mingw-env --uninstall <packages list>"
542 exit 1
543 }
544
545 # check if mingw-env already installed
546 func_mingw_env_installed
547 _function_result=$?
548 [[ $_function_result == 1 ]] && {
549 echo "mingw-env is not installed. terminate."
550 exit 1
551 } || {
552 [[ $_function_result == 2 ]] && {
553 echo "mingw-env installed. need to restart the shell."
554 exit 0
555 }
556 }
557
558 # check used compiler
559 [[ $USE_HOST_COMPILER == no && -z $DEFAULT_MINGW_VERSION ]] && {
560 echo "please set default mingw version in config file (DEFAULT_MINGW_VERSION). terminate."
561 exit 1
562 }
563 [[ $USE_HOST_COMPILER == yes && -n $(echo $@ | grep -oi mingw) ]] && {
564 echo "you can't build the new host compiler while USE_HOST_COMPILER is set to \"yes\""
565 exit 1
566 }
567
568 # append the PATH environment
569 [[ $USE_HOST_COMPILER == no ]] && {
570 export PATH=$PREFIX_DIR/bin:$PREFIX_DIR/lib:$PATH
571 }
572
573 # set up environment
574 func_make_environment $MINGW_ENV $WORK_DIR
575
576 # create
577 func_create_common_dirs
578
579 # get list of dependent packages
580 all_dependent=()
581 args_list=( ${@:2} )
582 for it in ${args_list[@]}; do
583 func_get_dependent_for_installed $it args_list[@]
584 all_dependent=( ${all_dependent[@]} ${deps_list[@]} )
585 done
586 all_dependent=( $(printf "%s\n" ${all_dependent[@]} | sort -u) )
587 ((cnt = ${#@}-1))
588
589 [[ ${#all_dependent[@]} > $cnt ]] && {
590 printf "will be uninstalled this packages:\n %s\n[yes/no]: " ${all_dependent[@]}
591 read ask
592 [[ $ask != yes && $ask != no ]] && {
593 echo "bad input. terminate."
594 exit 1
595 }
596 [[ $ask == no ]] && exit 0
597 }
598
599 # process uninstall packages
600 echo "uninstalling ${#all_dependent[@]} packages... "
601 for it in ${all_dependent[@]}; do
602 func_processing "$it" "no" "uninstall" "no" ""
603 done
604
605 exit 0
606 ;;
607
608 # reinstall specified packages and it's dependencies
609 --reinstall)
610 [[ $# < 2 ]] && {
611 echo "usage: mingw-env --reinstall <packages list>"
612 exit 1
613 }
614
615 # check if mingw-env already installed
616 func_mingw_env_installed
617 _function_result=$?
618 [[ $_function_result == 1 ]] && {
619 echo "mingw-env is not installed. terminate."
620 exit 1
621 } || {
622 [[ $_function_result == 2 ]] && {
623 echo "mingw-env installed. need to restart the shell."
624 exit 1
625 }
626 }
627
628 # set up environment
629 func_make_environment $MINGW_ENV $WORK_DIR
630
631 # create
632 func_create_common_dirs
633
634 # check used compiler
635 [[ $USE_HOST_COMPILER == no && -z $DEFAULT_MINGW_VERSION ]] && {
636 echo "please set default mingw version in config file (DEFAULT_MINGW_VERSION)."
637 exit 1
638 }
639 [[ $USE_HOST_COMPILER == yes && -n $(echo $@ | grep -oi mingw) ]] && {
640 echo "you can't build the new host compiler while USE_HOST_COMPILER is set to \"yes\""
641 exit 1
642 }
643
644 # process reinstall packages
645 echo "reinstall specified packages... "
646
647 # reinstall
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
648 OIFS=$IFS
649 IFS=" "
650 _pkg_list=(${@:2})
651 IFS=$OIFS;
652 _reinst_list=(`func_set_pkg_list _pkg_list[@]`)
a1d918c @Alexpux Add new functions to process packages
Alexpux authored
653 for it in "${_reinst_list[@]}"; do
effac9f initial commit
niXman authored
654 # check if rule exists
a1d918c @Alexpux Add new functions to process packages
Alexpux authored
655 [[ ! -f $it ]] && {
effac9f initial commit
niXman authored
656 echo "package \"$it\" is not exists. terminate."
657 exit 1
658 }
659 # check if package installed
a1d918c @Alexpux Add new functions to process packages
Alexpux authored
660 local _reinst_pkg=`basename ${it} .$RULES_EXT`
661 [[ -z $(cat $INSTALLED_PACKAGES_FILENAME | grep -o $_reinst_pkg) ]] && {
662 echo "package \"$_reinst_pkg\" does not installed. terminate."
effac9f initial commit
niXman authored
663 exit 1
664 }
665 func_processing "$it" "no" "uninstall" "yes" ""
666 func_processing "$it" "no" "install" "yes" ""
667 done
668
669 exit 0
670 ;;
671
672 # uninstall all packages
673 # build directory will not remove
674 --uninstall-all)
675 #
676 ;;
677
678 # reinstall all packages
679 --reinstall-all)
680 #
681 ;;
682
683 # clean specified packages
684 --clean)
685 [[ $# < 2 ]] && {
686 echo "usage: mingw-env --clean <packages list>"
687 exit 1
688 }
689 ;;
690
691 # distclean specified packages
692 --distclean)
693 [[ $# < 2 ]] && {
694 echo "usage: mingw-env --distclean <packages list>"
695 exit 1
696 }
697
698 exit 0
699 ;;
700
701 # download
702 --download|--download-unpack)
703 [[ $# < 2 ]] && {
704 [[ "${@:1:1}" == --download ]] && {
705 echo "usage: mingw-env --download <packages list>"
706 exit 1
707 } || {
708 echo "usage: mingw-env --download-unpack <packages list>"
709 exit 1
710 }
711 }
712
713 # check if mingw-env already installed
714 func_mingw_env_installed
715 _function_result=$?
716 [[ $_function_result == 1 ]] && {
717 echo "mingw-env is not installed. terminate."
718 exit 1
719 } || {
720 [[ $_function_result == 2 ]] && {
721 echo "mingw-env installed. need to restart the shell."
722 exit 0
723 }
724 }
725
726 # set up environment
727 func_make_environment $MINGW_ENV $WORK_DIR
728
729 # create
730 func_create_common_dirs
731
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
732 OIFS=$IFS
733 IFS=" "
734 _pkg_list=(${@:2})
735 IFS=$OIFS;
736 _inst_list=(`func_set_pkg_list _pkg_list[@]`)
737 for it in "${_inst_list[@]}"; do
738 [[ ! -f $it ]] && {
effac9f initial commit
niXman authored
739 echo "package \"$it\" is not exists. terminate."
740 exit 1
741 }
742 func_processing "$it" "no" "install" "yes" "${@:1}"
743 done
744
745 exit 0
746 ;;
747
748 # trace
749 --trace)
750 [[ $# < 2 ]] && {
751 echo "usage: mingw-env --trace <packages list>"
752 exit 1
753 }
754
755 # check if mingw-env already installed
756 func_mingw_env_installed
757 _function_result=$?
758 [[ $_function_result == 1 ]] && {
759 echo "mingw-env is not installed. terminate."
760 exit 1
761 } || {
762 [[ $_function_result == 2 ]] && {
763 echo "mingw-env installed. need to restart the shell."
764 exit 0
765 }
766 }
767
768 # set up environment
769 func_make_environment $MINGW_ENV $WORK_DIR
770
771 # create
772 func_create_common_dirs
773
d87deab @Alexpux - Move some functions from ming-env to external common/packaging.mfun
Alexpux authored
774 OIFS=$IFS
775 IFS=" "
776 _pkg_list=(${@:2})
777 IFS=$OIFS;
778 _inst_list=(`func_set_pkg_list _pkg_list[@]`)
779 for it in "${_inst_list[@]}"; do
a1d918c @Alexpux Add new functions to process packages
Alexpux authored
780 [[ ! -f $RULES_DIR/$it.$RULES_EXT ]] && {
effac9f initial commit
niXman authored
781 echo "package \"$it\" is not exists. terminate."
782 exit 1
783 }
784 func_processing "$it" "no" "install" "yes" "${@:1}"
785 done
786
787 exit 0
788 ;;
789
790 --dependencies)
791 [[ $# < 2 ]] && {
792 echo "usage: mingw-env --dependencies <package>"
793 exit 1
794 }
795
796 # check if mingw-env already installed
797 func_mingw_env_installed
798 _function_result=$?
799 [[ $_function_result == 1 ]] && {
800 echo "mingw-env is not installed. terminate."
801 exit 1
802 } || {
803 [[ $_function_result == 2 ]] && {
804 echo "mingw-env installed. need to restart the shell."
805 exit 0
806 }
807 }
808
809 # set up environment
810 func_make_environment $MINGW_ENV $WORK_DIR
811
812 # create
813 func_create_common_dirs
814
815 func_get_dependencies "${@:2}"
816 printf "%s\n" "$( printf "%s\n" ${deps_list[@]} | sort -u )"
817
818 exit 0
819 ;;
820
821 --dependent)
822 [[ $# < 2 ]] && {
823 echo "usage: mingw-env --dependent <package>"
824 exit 1
825 }
826
827 # check if mingw-env already installed
828 func_mingw_env_installed
829 _function_result=$?
830 [[ $_function_result == 1 ]] && {
831 echo "mingw-env is not installed. terminate."
832 exit 1
833 } || {
834 [[ $_function_result == 2 ]] && {
835 echo "mingw-env installed. need to restart the shell."
836 exit 0
837 }
838 }
839
840 # set up environment
841 func_make_environment $MINGW_ENV $WORK_DIR
842
843 # create
844 func_create_common_dirs
845
846 func_get_dependent_for_installed "${@:2}"
847 printf "%s\n" "$( printf "%s\n" ${deps_list[@]} | sort -u )"
848
849 exit 0
850 ;;
851
852 -h|--help|*)
853 printf "%s\n" \
854 "Usage: mingw-env [option]... [packages]" \
855 " mingw-env --help | display this help and exit" \
856 "" \
857 "mingw-env install/uninstall:" \
dfaa558 @froex Parameters --setup and --unsetup replaced by --install and --uninstall
froex authored
858 " --install <path> | install mingw-env in the specified path" \
859 " --uninstall | uninstall the mingw-env" \
effac9f initial commit
niXman authored
860 "" \
861 "mingw-env commands:" \
862 " --version | show mingw-env version" \
863 " --list | show list of available packages" \
864 " --installed | show list of installed packages" \
865 " --update | update mingw-env from repository" \
866 " --propose-package <package> | propose a package to mingw-env" \
867 " --create-report <package> | create bug-report archive for package" \
868 "" \
869 "Prefix path controll:" \
870 " --create-state <state name> | save state of the prefix directory" \
871 " --restore-state <state name> | restore state of the prefix directory" \
872 "" \
873 "Packages controll:" \
874 " --download <packages> | download packages and it's dependencies" \
875 " --download-unpack <packages> | download and unpack packages and it's" \
876 " | dependencies" \
877 " --trace <package> | trace packages install process" \
878 " --dependencies <package> | show list of dependencies for package" \
879 " --dependent <package> | show list of dependent packages" \
880 " --install <packages> | install specified packages" \
881 " --uninstall <packages> | uninstall specified packages" \
882 " --reinstall <packages> | reinstall specified packages" \
883 " --uninstall-all | uninstall all installed packages" \
884 " --reinstall-all | reinstall all installed packages" \
885 " --clean <packages> | clean specified packages" \
886 " --distclean <packages> | distclean specified packages"
887 exit 0
888 ;;
889 esac
890
891 # **************************************************************************
892 # **************************************************************************
893 # **************************************************************************
894
Something went wrong with that request. Please try again.