From 9b5de3f26cc00be33b220b683608f65c61548f8e Mon Sep 17 00:00:00 2001 From: Steven Penny Date: Wed, 12 Nov 2014 15:18:38 -0600 Subject: [PATCH] searchall: account for broken lines http://cygwin.com/ml/cygwin/2014-11/msg00278.html --- apt-cyg | 20 ++++++++++++-------- apt-msys2 | 14 +++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/apt-cyg b/apt-cyg index 95e984a..5f71753 100755 --- a/apt-cyg +++ b/apt-cyg @@ -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 } diff --git a/apt-msys2 b/apt-msys2 index 1f32986..e22c893 100755 --- a/apt-msys2 +++ b/apt-msys2 @@ -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[*]}