notes/pl/cpp/compilers/mingw-get/mingw-get-info
Ihar Hancharenka 5dff80e88e first
2023-03-27 16:52:17 +03:00

114 строки
2.7 KiB
Bash

#!/bin/sh
# mingw-get-info.sh
#
# Display information about software installations managed by mingw-get
#
# Usage:
# mingw-get-info {all | installed | index}
#
# Copyright (C) 2011, Keith D. Marshall
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
mingw_get=`type -p mingw-get`
test -n "$mingw_get" || {
echo >&2 $0: cannot find mingw-get.exe
exit 2
}
spinwait(){
case $spinmark in
'/') spinmark='-' ;;
'-') spinmark='\\' ;;
'\\') spinmark='|' ;;
*) spinmark='/' ;;
esac
printf '\r'"$spinmark"
}
query(){
$mingw_get list "$@" 2>/dev/null | tr -d \\015
}
index(){
query | awk '
/^Package:/{pkg=$2;sys=$4}
/^Components:/{print "Subsystem:", sys, "Package:", pkg, $0}
' | tr -d ,
}
packages(){
test -f index.$$ || index > index.$$
awk '{print $4}' index.$$
}
entities(){
for pkg in `packages`
do awk '$4 == "'"$pkg"'"{
for( i = 5; i < NF; print $4"-"$++i );
}' index.$$
done
rm -f index.$$
}
report(){
printf '\r%s\n' "$1:"
query $1 | awk '/^Repository/||/^Installed/{print " "$0}'
}
all(){
for pkg in `entities`
do
report $pkg
done
}
installed(){
for pkg in `entities`
do
spinwait
report=`report $pkg`
test `echo "$report" | awk '
/^ *Installed/{print $NF}'` = none || echo "$report"
done
printf '\r \r'
}
cmd=""
test $# -eq 0 && set all
for cmds in index installed all
do
case $cmds in $1*)
test -z "$cmd" || {
echo >&2 $0: $1: ambiguous command
exit 1
}
cmd=$cmds
esac
done
test -z "$cmd" && {
echo >&2 $0: $1: unknown command
exit 1
}
$cmd "$@"
#
# mingw-get-info.sh: end of file