Filtrar por arquitetura para pesquisa de dívidas

1

Eu tenho multiarch ativado e, quando corro debtags search , recebo muitos resultados duplicados.

$ debtags search 'works-with-format::man' | head
docbook-to-man - converter from DocBook SGML into roff man macros
docbook-to-man:i386 - converter from DocBook SGML into roff man macros
docbook-utils - Convert DocBook files to other formats (HTML, RTF, PS, man, PDF)
docbook2x - Converts DocBook/XML documents into man pages and TeXinfo
docbook2x:i386 - Converts DocBook/XML documents into man pages and TeXinfo
doclifter - Convert troff to DocBook
dwww - Read all on-line documentation with a WWW browser
dwww:i386 - Read all on-line documentation with a WWW browser
ebook-speaker - eBook reader that reads aloud in a synthetic voice
ebook-speaker:i386 - eBook reader that reads aloud in a synthetic voice

Há uma solução alternativa usando grep :

$ debtags search 'works-with-format::man' | grep -v ':i386 - ' | head
docbook-to-man - converter from DocBook SGML into roff man macros
docbook-utils - Convert DocBook files to other formats (HTML, RTF, PS, man, PDF)
docbook2x - Converts DocBook/XML documents into man pages and TeXinfo
doclifter - Convert troff to DocBook
dwww - Read all on-line documentation with a WWW browser
ebook-speaker - eBook reader that reads aloud in a synthetic voice
git-man - fast, scalable, distributed revision control system (manual pages)
gman - small man(1) front-end for X
gmanedit - GTK+ man pages editor
gnulib - GNU Portability Library

Isso pressupõe que a string :i386 - não apareça na descrição de qualquer pacote, que é um pouco de um hack. Existe uma maneira melhor?

    
por Nathaniel M. Beaver 21.03.2018 / 19:19

1 resposta

1
debtags search 'works-with-format::man' | awk 'BEGIN { FS="[: ]" }  ! ($1 in seen) { print; seen[$1]=1 }'

Isso memorizará os pacotes vistos (no índice% array seen ), independentemente da arquitetura (portanto, usando tanto espaço quanto : como separador) e não os imprimirá novamente se já tiver sido visto. Assim, ele também exibirá um pacote que existiria apenas em i386 e não na arquitetura padrão (amd64) (por exemplo: zsnes:i386 marcado com hardware::emulation não existe como zsnes (ou seja, zsnes:amd64 )). Como os pacotes sem arquitetura explícita mostrados vêm em primeiro lugar (nos algoritmos de pré-seleção de dívida ...), não é necessário se preocupar em exibir :i386 extra, a menos que seja necessário.

UPDATE: como desejado, o mesmo script awk em um arquivo de script independente colocado como / usr / local / bin / debtagsfilter com este conteúdo

#!/usr/bin/awk -f
BEGIN           {
                        FS="[: ]"
                }
! ($1 in seen)  {
                        print
                        seen[$1]=1
                }

e executável com ( chmod a+rx /usr/local/bin/filterdebtags ) pode ser usado por exemplo com: debtags search 'works-with-format::man' | filterdebtags

Ou, se uma "nova" versão de debtags chamada /usr/local/bin/debtagswithfilter for preferida (voltando assim para sh como linguagem de script chamada):

#!/bin/sh
debtags "$@" | awk '
BEGIN           {
                        FS="[: ]"
                }
! ($1 in seen)  {
                        print
                        seen[$1]=1
                }
'

compare (recebo duplicatas simples, talvez por causa de várias fontes de repositório):

$ debtags search 'hardware::emulation'

[...]

xtrs - emulator for TRS-80 Model I/III/4/4P computers
xtrs:i386 - emulator for TRS-80 Model I/III/4/4P computers
yabause - beautiful and under-rated Saturn emulator
yabause - beautiful and under-rated Saturn emulator
yabause-gtk - beautiful and under-rated Saturn emulator - Gtk port
yabause-gtk - beautiful and under-rated Saturn emulator - Gtk port
yabause-gtk:i386 - beautiful and under-rated Saturn emulator - Gtk port
yabause-gtk:i386 - beautiful and under-rated Saturn emulator - Gtk port
yabause-qt - beautiful and under-rated Saturn emulator - Qt port
yabause-qt - beautiful and under-rated Saturn emulator - Qt port
yabause-qt:i386 - beautiful and under-rated Saturn emulator - Qt port
yabause-qt:i386 - beautiful and under-rated Saturn emulator - Qt port
zsnes:i386 - Emulator of the Super Nintendo Entertainment System

com:

$ debtagswithfilter search 'hardware::emulation'

[...]

xtrs - emulator for TRS-80 Model I/III/4/4P computers
yabause - beautiful and under-rated Saturn emulator
yabause-gtk - beautiful and under-rated Saturn emulator - Gtk port
yabause-qt - beautiful and under-rated Saturn emulator - Qt port
zsnes:i386 - Emulator of the Super Nintendo Entertainment System

Funciona bem com solicitações de pesquisa mais complexas também:

$ debtagswithfilter search 'works-with-format::tex && interface::text-mode'
asymptote - script-based vector graphics language inspired by MetaPost
auctex - integrated document editing environment for TeX etc.
axiom-tex - General purpose computer algebra system: style file for TeX
bibcursed - Interactive program to edit BibTeX bibliographies
chktex - Finds typographic errors in LaTeX
fweb - literate-programming tool for C/C++/Fortran/Ratfor
groff - GNU troff text-formatting system
vim-latexsuite - view, edit and compile LaTeX documents from within Vim
yatex - Yet Another TeX mode for Emacs
    
por 22.03.2018 / 22:39