#!/bin/sh # Copyright (C) Bas van Gompel 2004. # All rights reserved. No warranties. # This software may not be used for aggressive purposes. RCS_ID="$Id: cyg-desc.sh,v 1.11 2004/12/02 18:25:30 Buzz Exp Buzz $" cache_files="" if test "$1"x = "-r"x; then regex=false shift else regex=true fi if test -f /etc/setup/last-mirror; then for f in $(cat /etc/setup/last-mirror); do cache_files="${cache_files}$( cygpath -u $( cat /etc/setup/last-cache ) )/$( echo "$f"|sed 's,:,%3a,g;s,/,%2f,g' )/setup.ini " done until test -z "$1"; do echo "${cache_files}" |until read cache_file if test -z "${cache_file}"; then echo "$0: desc for $1 not found." true elif test -f "${cache_file}"; then if ${regex}; then reg_op='~ /^'$1'$/' else reg_op='== "'$1'"' fi awk -f - ${cache_file} <<-EOA BEGIN {rv = 1} /^@/ { if (ib == 1) { if (!hd && sd) { print gensub (/^sdesc/, pn, 1, sd) sd = "" rv = 0 } print "" } hd = 0 if (\$2 ${reg_op}) { ib = 1 pn = \$2 next } else { ib = 0 } } /^sdesc: "/ {if (ib) {sd = \$0; next}} /^ldesc: ".*"/ {if (ib) {print gensub (/^ldesc/, pn, 1); hd = 1; rv = 0; next}} /^ldesc: "/ {if (ib) {id = 1; print gensub (/^ldesc/, pn, 1); hd = 1; next}} /"\$/ {if (id) {id = 0; print \$0; rv = 0}} /.*/ {if (id) {print \$0}} END {exit rv} EOA else false fi do : done shift done else echo "$0: Can not read mirror-file /etc/setup/last-mirror" >&2 fi