searchall: account for broken lines

http://cygwin.com/ml/cygwin/2014-11/msg00278.html
This commit is contained in:
Steven Penny 2014-11-12 15:18:38 -06:00
parent e9bea37b95
commit 9b5de3f26c
2 changed files with 19 additions and 15 deletions

20
apt-cyg
View File

@ -339,14 +339,18 @@ function apt-searchall {
printf -v qs 'text=1&arch=%s&grep=%s' $ARCH "$pkg"
wget -O matches cygwin.com/cgi-bin2/package-grep.cgi?"$qs"
awk '
NR == 1 {next}
/-doc-/ {next}
/-debuginfo-/ {next}
/-devel-/ && pkg~/\.exe$/ {next}
/-src\t$/ {next}
mc[$1]++ {next}
$0 = $1
' FS=-[[:digit:]] pkg="$pkg" matches
{
if (NR == 1)
next
if (mc[$1]++)
next
if (/-debuginfo-/)
next
if (/^ /)
next
print $1
}
' FS=-[[:digit:]] matches
done
}

View File

@ -21,7 +21,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
usage () {
function usage {
local rw=(
'apt-msys2 [command] [packages]'
''
@ -33,14 +33,14 @@ usage () {
printf '%s\n' "${rw[@]}"
}
urlencode () {
function urlencode {
sed '
s / %2f g
s : %3a g
' <<< "$1"
}
findworkspace () {
function findworkspace {
mirror=http://downloads.sourceforge.net/project/msys2
repo=REPOS/MINGW/$ARCH
local mirrordir=/var/cache/$(urlencode $mirror)/$repo
@ -48,13 +48,13 @@ findworkspace () {
cd $mirrordir
}
getdb () {
function getdb {
[ -e mingw64.files.tar.gz ] && return
wget $mirror/$repo/mingw64.files.tar.gz
tar --no-an -Oxf mingw64.files.tar.gz desc files > mingw64.lst
}
apt-listfiles () {
function apt-listfiles {
findworkspace
getdb
local pkg
@ -69,7 +69,7 @@ apt-listfiles () {
head -c-1
}
apt-install () {
function apt-install {
findworkspace
getdb
local pkg file eu oe rw
@ -95,7 +95,7 @@ apt-install () {
done
}
apt-search () {
function apt-search {
findworkspace
getdb
for pkg in ${packages[*]}