Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 895 lines (757 sloc) 22.068 kb
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 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894
#!/bin/bash

#
# The BSD 3-Clause License. http://www.opensource.org/licenses/BSD-3-Clause
#
# This file is part of mingw-env project.
# Copyright (c) 2011,2012, by niXman (i dotty nixman doggy gmail dotty com)
# All rights reserved.
# Project: mingw-env ( http://sourceforge.net/projects/mingw-env/ )
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# - Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# - Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the distribution.
# - Neither the name of the 'mingw-env' nor the names of its contributors may
# be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

# **************************************************************************
# **************************************************************************
# **************************************************************************

source common/utils.mfun
source common/version.mfun
source common/packaging.mfun

# constants
MINGW_ENV_VERSION="0.1.0"
BUG_URL='http://sourceforge.net/projects/mingw-env/'
PKGVERSION='Built by mingw-env project'
TAB_STOP=3

IS_LINUX_HOST=no
IS_WINDOWS_HOST=no
IS_MACOSX_HOST=no

case $OSTYPE in
linux-gnu) IS_LINUX_HOST=yes ;;
msys) IS_WINDOWS_HOST=yes ;;
darwin*) IS_MACOSX_HOST=yes ;;
*) echo "bad host. terminate."; exit 1 ;;
esac

VIEWVER_NAME=""

[[ $# > 0 && ${@:1} != --install ]] && {
[[ -n $MINGW_ENV ]] && {
. $MINGW_ENV/common/config.sh
func_find_logviewer \
LOGVIEWERS[@] \
VIEWVER_NAME
[[ $? != 0 ]] && {
echo "can not find default logviewer."
}
}
}

# **************************************************************************

# check if mingw-env already installed
function func_mingw_env_installed {
[[ ! -f $HOME/.profile ]] && return 1 # not installed
[[ -n $(cat $HOME/.profile | grep 'MINGW_ENV') ]] && {
[[ -z $MINGW_ENV ]] && {
return 2 # installed. need to restart the shell.
} || {
return 0 # installed and shell restarted.
}
}
return 1 # not installed
}

# **************************************************************************

# prepare mingw-env environment
function func_make_environment {
# $1 - $MINGW_ENV
# $2 - $WORK_DIR

# common variable
ROOT_DIR=$1
COMMON_DIR=$ROOT_DIR/common
METADATA_DIR=$ROOT_DIR/metadata
RULES_DIR=$ROOT_DIR/rules
PATCHES_DIR=$ROOT_DIR/patches
TESTS_DIR=$ROOT_DIR/tests
DATA_DIR=$ROOT_DIR/data
DATA_TOOLS_DIR=$DATA_DIR/tools
DATA_MARKERS_DIR=$DATA_DIR/markers
DATA_STATE_DIR=$DATA_DIR/states

# work dir variable
BUILDS_DIR=$2/builds
LOGS_DIR=$2/logs
SRCS_DIR=$2/srcs
PACKAGES_DIR=$2/packages

# installed packages list
INSTALLED_PACKAGES_FILENAME=$DATA_MARKERS_DIR/installed_packages.list

# tab marker
TAB_LEVEL=0
}

# **************************************************************************

# install mingw-env
function func_mingw_env_install {
# $1 - path for install too

[[ ! -f ./mingw-env ]] && {
echo "run install from the mingw-env root directory."
return 1
}

mkdir -p $1/data || return 1
cp ./mingw-env $1 || return 1
cp -r $COMMON_DIR $1 || return 1
cp -r $METADATA_DIR $1 || return 1
cp -r $RULES_DIR $1 || return 1
cp -r $PATCHES_DIR $1 || return 1
cp -r $TESTS_DIR $1 || return 1
cp -r $DATA_TOOLS_DIR $1/data || return 1

[[ ! -f $HOME/.profile ]] && {
touch $HOME/.profile
}

mv $HOME/.profile $HOME/.profile.back && \
echo "export MINGW_ENV=$1" > $HOME/.profile && \
echo "export PATH=\$MINGW_ENV:\$PATH" >> $HOME/.profile && \
cat $HOME/.profile.back >> $HOME/.profile && \
rm $HOME/.profile.back

[[ $? != 0 ]] && {
rm -fR $1
echo "can't setup MINGW_ENV environment variable."
return 1
}

return 0
}

# uninstall mingw-env
function func_mingw_env_uninstall {
sed /MINGW_ENV/d -i $HOME/.profile
rm -fR $MINGW_ENV
}

# **************************************************************************

# create state of the prefix dir
function func_create_state {
# $1 - state name

[[ -f $DATA_STATE_DIR/$1.marker ]] && {
echo ""
echo "state \"$1\" already exists. terminate."
exit 1
}

touch $DATA_STATE_DIR/$1.marker
}

# restore state of the prefix dir
function func_restore_state {
# $1 - state name

[[ ! -f $DATA_STATE_DIR/$1.marker ]] && {
echo "state \"$1\" does not exist. terminate."
exit 1
}

local _prev=$PWD
cd $PREFIX_DIR
find . -type f -newer $DATA_STATE_DIR/$1.marker | xargs rm -fR > /dev/null 2>&1
find . -type d -newer $DATA_STATE_DIR/$1.marker | xargs rmdir -p > /dev/null 2>&1
cd $_prev

[[ $1 != initial ]] && {
rm -f $DATA_STATE_DIR/$1.marker
}
}

# **************************************************************************

function func_is_valid_package {
# $1 - (meta)package name

RULE_TYPE=""
RULE_NAME=""

. $1

[[ -z $RULE_TYPE || -z $RULE_NAME ]] && {
echo "package \"$1\" is not for using directly. terminate."
exit 1
}
}

# **************************************************************************

# create the error report
function func_create_error_report {
# $1 - (meta)package name
# $2 - report name

echo ""
}

# **************************************************************************

# create the absolute path to relative
function func_absolute_to_relative {
local common_part=$1
local target=$2
local back=""

while [[ "${target#$common_part}" == "${target}" ]]; do
common_part=$(dirname $common_part)
back="../${back}"
done

echo "${back}${target#$common_part/}"
}

# **************************************************************************

# create common dirs
function func_create_common_dirs {
mkdir -p \
$WORK_DIR \
$PREFIX_DIR \
$BUILDS_DIR \
$LOGS_DIR \
$SRCS_DIR \
$PACKAGES_DIR \
$DATA_TOOLS_DIR \
$DATA_MARKERS_DIR \
$DATA_STATE_DIR
}

# **************************************************************************
# **************************************************************************
# **************************************************************************

case $1 in
--install)
[[ $# != 2 ]] && {
echo "usage: mingw-env --install <path>"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 0 ]] && {
# already installed
echo "already installed."; exit 0
} || {
[[ $_function_result == 2 ]] && {
# already installed
echo "already installed. need to restart the shell."
exit 0
}
}

# load config
. common/config.sh

# prepare environment
func_make_environment "$PWD" ""

# installing
func_mingw_env_install $2
[[ $? != 0 ]] && {
echo "error on installig. terminate."
exit 1
}

echo "successfully installed. please restart the shell."
exit 0
;;

--uninstall)
[[ $# != 1 ]] && {
echo "usage: mingw-env --uninstall"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
# already installed
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# prepare environment
func_make_environment $MINGW_ENV ""

# uninstall
func_mingw_env_uninstall
[[ $? == 0 ]] && {
echo "successfully uninstalled."
exit 0
} || {
echo "error on uninstallig. terminate."
exit 1
}
;;

--version|-v)
echo "mingw-env-$MINGW_ENV_VERSION"
exit 0
;;

# print list of available packages
--list)
[[ $# > 2 ]] && {
echo "usage: mingw-env --list [substring]"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."; exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# print list of available packages
[[ $# == 1 ]] && {
func_print_packages ""
} || {
func_print_packages ${@:2}
}
exit 0
;;

# print list of installed packages
--installed)
[[ $# != 1 ]] && {
echo "usage: mingw-env --installed"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# print list of installed packages
func_print_installed_packages
exit 0
;;

# update mingw-env sources from repository
--update)
exit 0
;;

# propose package for include in mingw-env
--propose-package)
exit 0
;;

# create bug-report for specified package
--create-report)
exit 0
;;

# fix current state of the prefix path
--create-state)
[[ $# != 2 ]] && {
echo "usage: mingw-env --create-state <state name>"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# create
func_create_common_dirs

echo -n "create state \"$2\"... "
func_create_state $2
echo "done."
exit 0
;;

# restore state of the prefix path content.
# if state name is not specified - restore last state.
--restore-state)
[[ $# != 2 ]] && {
echo "usage: mingw-env --restore-state <state name>"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# restore specified state
echo -n "restore state \"$2\"... "
func_restore_state $2
echo "done."; exit 0
;;

# install
--install)
[[ $# < 2 ]] && {
echo "usage: mingw-env --install <packages list>"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# check used compiler
[[ $USE_HOST_COMPILER == no && -z $DEFAULT_MINGW_VERSION ]] && {
echo "please set default mingw version in config file (DEFAULT_MINGW_VERSION). terminate."
exit 1
}
[[ $USE_HOST_COMPILER == yes && -n $(echo $@ | grep -oi mingw) ]] && {
echo "you can't build the new host compiler while USE_HOST_COMPILER is set to \"yes\""
exit 1
}

# append the PATH environment
[[ $USE_HOST_COMPILER == no ]] && {
export PATH=$PREFIX_DIR/bin:$PREFIX_DIR/lib:$PATH
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# create
func_create_common_dirs

# create initial state
[[ ! -f $DATA_STATE_DIR/initial.marker ]] && {
echo -n "first run. create initial state... "
func_create_state initial
echo "done."
}

OIFS=$IFS
IFS=" "
_pkg_list=(${@:2})
IFS=$OIFS;
_inst_list=(`func_set_pkg_list _pkg_list[@]`)
for it in "${_inst_list[@]}"; do
[[ ! -f $it ]] && {
echo "package \"$it\" is not exists. terminate."
exit 1
}
func_processing "$it" "no" "install" "yes" ""
done
;;

# uninstall specified packages
--uninstall)
[[ $# < 2 ]] && {
echo "usage: mingw-env --uninstall <packages list>"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# check used compiler
[[ $USE_HOST_COMPILER == no && -z $DEFAULT_MINGW_VERSION ]] && {
echo "please set default mingw version in config file (DEFAULT_MINGW_VERSION). terminate."
exit 1
}
[[ $USE_HOST_COMPILER == yes && -n $(echo $@ | grep -oi mingw) ]] && {
echo "you can't build the new host compiler while USE_HOST_COMPILER is set to \"yes\""
exit 1
}

# append the PATH environment
[[ $USE_HOST_COMPILER == no ]] && {
export PATH=$PREFIX_DIR/bin:$PREFIX_DIR/lib:$PATH
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# create
func_create_common_dirs

# get list of dependent packages
all_dependent=()
args_list=( ${@:2} )
for it in ${args_list[@]}; do
func_get_dependent_for_installed $it args_list[@]
all_dependent=( ${all_dependent[@]} ${deps_list[@]} )
done
all_dependent=( $(printf "%s\n" ${all_dependent[@]} | sort -u) )
((cnt = ${#@}-1))

[[ ${#all_dependent[@]} > $cnt ]] && {
printf "will be uninstalled this packages:\n %s\n[yes/no]: " ${all_dependent[@]}
read ask
[[ $ask != yes && $ask != no ]] && {
echo "bad input. terminate."
exit 1
}
[[ $ask == no ]] && exit 0
}

# process uninstall packages
echo "uninstalling ${#all_dependent[@]} packages... "
for it in ${all_dependent[@]}; do
func_processing "$it" "no" "uninstall" "no" ""
done

exit 0
;;

# reinstall specified packages and it's dependencies
--reinstall)
[[ $# < 2 ]] && {
echo "usage: mingw-env --reinstall <packages list>"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 1
}
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# create
func_create_common_dirs

# check used compiler
[[ $USE_HOST_COMPILER == no && -z $DEFAULT_MINGW_VERSION ]] && {
echo "please set default mingw version in config file (DEFAULT_MINGW_VERSION)."
exit 1
}
[[ $USE_HOST_COMPILER == yes && -n $(echo $@ | grep -oi mingw) ]] && {
echo "you can't build the new host compiler while USE_HOST_COMPILER is set to \"yes\""
exit 1
}

# process reinstall packages
echo "reinstall specified packages... "

# reinstall
OIFS=$IFS
IFS=" "
_pkg_list=(${@:2})
IFS=$OIFS;
_reinst_list=(`func_set_pkg_list _pkg_list[@]`)
for it in "${_reinst_list[@]}"; do
# check if rule exists
[[ ! -f $it ]] && {
echo "package \"$it\" is not exists. terminate."
exit 1
}
# check if package installed
local _reinst_pkg=`basename ${it} .$RULES_EXT`
[[ -z $(cat $INSTALLED_PACKAGES_FILENAME | grep -o $_reinst_pkg) ]] && {
echo "package \"$_reinst_pkg\" does not installed. terminate."
exit 1
}
func_processing "$it" "no" "uninstall" "yes" ""
func_processing "$it" "no" "install" "yes" ""
done

exit 0
;;

# uninstall all packages
# build directory will not remove
--uninstall-all)
#
;;

# reinstall all packages
--reinstall-all)
#
;;

# clean specified packages
--clean)
[[ $# < 2 ]] && {
echo "usage: mingw-env --clean <packages list>"
exit 1
}
;;

# distclean specified packages
--distclean)
[[ $# < 2 ]] && {
echo "usage: mingw-env --distclean <packages list>"
exit 1
}

exit 0
;;

# download
--download|--download-unpack)
[[ $# < 2 ]] && {
[[ "${@:1:1}" == --download ]] && {
echo "usage: mingw-env --download <packages list>"
exit 1
} || {
echo "usage: mingw-env --download-unpack <packages list>"
exit 1
}
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# create
func_create_common_dirs

OIFS=$IFS
IFS=" "
_pkg_list=(${@:2})
IFS=$OIFS;
_inst_list=(`func_set_pkg_list _pkg_list[@]`)
for it in "${_inst_list[@]}"; do
[[ ! -f $it ]] && {
echo "package \"$it\" is not exists. terminate."
exit 1
}
func_processing "$it" "no" "install" "yes" "${@:1}"
done

exit 0
;;

# trace
--trace)
[[ $# < 2 ]] && {
echo "usage: mingw-env --trace <packages list>"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# create
func_create_common_dirs

OIFS=$IFS
IFS=" "
_pkg_list=(${@:2})
IFS=$OIFS;
_inst_list=(`func_set_pkg_list _pkg_list[@]`)
for it in "${_inst_list[@]}"; do
[[ ! -f $RULES_DIR/$it.$RULES_EXT ]] && {
echo "package \"$it\" is not exists. terminate."
exit 1
}
func_processing "$it" "no" "install" "yes" "${@:1}"
done

exit 0
;;

--dependencies)
[[ $# < 2 ]] && {
echo "usage: mingw-env --dependencies <package>"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# create
func_create_common_dirs

func_get_dependencies "${@:2}"
printf "%s\n" "$( printf "%s\n" ${deps_list[@]} | sort -u )"

exit 0
;;

--dependent)
[[ $# < 2 ]] && {
echo "usage: mingw-env --dependent <package>"
exit 1
}

# check if mingw-env already installed
func_mingw_env_installed
_function_result=$?
[[ $_function_result == 1 ]] && {
echo "mingw-env is not installed. terminate."
exit 1
} || {
[[ $_function_result == 2 ]] && {
echo "mingw-env installed. need to restart the shell."
exit 0
}
}

# set up environment
func_make_environment $MINGW_ENV $WORK_DIR

# create
func_create_common_dirs

func_get_dependent_for_installed "${@:2}"
printf "%s\n" "$( printf "%s\n" ${deps_list[@]} | sort -u )"

exit 0
;;

-h|--help|*)
printf "%s\n" \
"Usage: mingw-env [option]... [packages]" \
" mingw-env --help | display this help and exit" \
"" \
"mingw-env install/uninstall:" \
" --install <path> | install mingw-env in the specified path" \
" --uninstall | uninstall the mingw-env" \
"" \
"mingw-env commands:" \
" --version | show mingw-env version" \
" --list | show list of available packages" \
" --installed | show list of installed packages" \
" --update | update mingw-env from repository" \
" --propose-package <package> | propose a package to mingw-env" \
" --create-report <package> | create bug-report archive for package" \
"" \
"Prefix path controll:" \
" --create-state <state name> | save state of the prefix directory" \
" --restore-state <state name> | restore state of the prefix directory" \
"" \
"Packages controll:" \
" --download <packages> | download packages and it's dependencies" \
" --download-unpack <packages> | download and unpack packages and it's" \
" | dependencies" \
" --trace <package> | trace packages install process" \
" --dependencies <package> | show list of dependencies for package" \
" --dependent <package> | show list of dependent packages" \
" --install <packages> | install specified packages" \
" --uninstall <packages> | uninstall specified packages" \
" --reinstall <packages> | reinstall specified packages" \
" --uninstall-all | uninstall all installed packages" \
" --reinstall-all | reinstall all installed packages" \
" --clean <packages> | clean specified packages" \
" --distclean <packages> | distclean specified packages"
exit 0
;;
esac

# **************************************************************************
# **************************************************************************
# **************************************************************************

Something went wrong with that request. Please try again.