delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/12/02/14:56:10

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <n2m-g.cont66.3vvem75.1@buzzy-box.bavag>
From: Bas van Gompel <cygwin DOT buzz AT bavag DOT tmfweb DOT nl>
Subject: Finding package-descriptions.
Reply-To: cygwin mailing-list <cygwin AT cygwin DOT com>
Organisation: Ehm...
MIME-Version: 1.0
User-Agent: slrn/0.9.8.1 (Win32) Hamster/2.0.6.0 Korrnews/4.2
To: cygwin AT cygwin DOT com
Lines: 118
Date: Thu, 2 Dec 2004 20:55:51 +0100 (MET)
X-IsSubscribed: yes

--=====Cut=====
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8Bit

Hallo,

Sometimes one wants to read a description for one or more packages.

I wrote following script to retrieve that info from the locally
installed setup-inis. It's parameters are anchored regexes if
the first one is not ``-r'', after which they are plain text:
$ cyg-desc '.*ss[hl]' '.*x11.*'
or
$ cyg-desc -r gtk+ gcc-g++


The script requires /bin/sh, cat, awk, true, false, cygpath, a package-
dir left by setup, /etc/setup/last-mirror and /etc/setup/last-cache.

I hope this is of use to anybody.

L8r,


Buzz.
-- 
  ) |  | ---/ ---/  Yes, this | This message consists of true | I do not
--  |  |   /    /   really is |   and false bits entirely.    | mail for
  ) |  |  /    /    a 72 by 4 +-------------------------------+ any1 but
--  \--| /--- /---  .sigfile. |   |perl -pe "s.u(z)\1.as."    | me. 4^re

--=====Cut=====
Content-Type: text/plain; name="cyg-desc"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="cyg-desc"

#!/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


--=====Cut=====
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
--=====Cut=====--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019