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" printf -v qs 'text=1&arch=%s&grep=%s' $ARCH "$pkg"
wget -O matches cygwin.com/cgi-bin2/package-grep.cgi?"$qs" wget -O matches cygwin.com/cgi-bin2/package-grep.cgi?"$qs"
awk ' awk '
NR == 1 {next} {
/-doc-/ {next} if (NR == 1)
/-debuginfo-/ {next} next
/-devel-/ && pkg~/\.exe$/ {next} if (mc[$1]++)
/-src\t$/ {next} next
mc[$1]++ {next} if (/-debuginfo-/)
$0 = $1 next
' FS=-[[:digit:]] pkg="$pkg" matches if (/^ /)
next
print $1
}
' FS=-[[:digit:]] matches
done done
} }

View File

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