summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-01-02 12:02:19 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2018-01-02 12:02:19 -0500
commit96ce209e48e7f729552809540cc2e97e6fe1e6aa (patch)
tree53b1801ad90f9472d407b01a2ae10695219fd6e7
parente8bed2be9f4a03b8573153f985653d3ccecdf8b3 (diff)
parent9c2ed3fab9cf19acd5a72d1240bc2a0c8003238d (diff)
Merge branch 'isacdaavid'
-rw-r--r--po/es/librelib.po82
-rwxr-xr-x[-rw-r--r--]src/lib/blacklist.sh46
-rwxr-xr-x[-rw-r--r--]test/lib-blacklist-test.sh42
-rwxr-xr-x[-rw-r--r--]test/test-common.sh8
4 files changed, 128 insertions, 50 deletions
diff --git a/po/es/librelib.po b/po/es/librelib.po
index 7205775..d50c188 100644
--- a/po/es/librelib.po
+++ b/po/es/librelib.po
@@ -1,11 +1,12 @@
# Copyright (C) 2017 David P <megver83@parabola.nu>
+# Copyright (C) 2017 Isaac David <isacdaavid@isacdaavid.info>
# This file is distributed under the same license as the libretools package.
#
msgid ""
-msgstr "Project-Id-Version: libretools 20170705\n"
+msgstr "Project-Id-Version: libretools 20170913\n"
"Report-Msgid-Bugs-To: Parabola Hackers <dev@lists.parabola.nu>\n"
- "PO-Revision-Date: 2017-07-05 20:02-0400\n"
- "Last-Translator: David P <megver83@parabola.nu>\n"
+ "PO-Revision-Date: 2017-09-09 00:00-0600\n"
+ "Last-Translator: Isaac David <isacdaavid@isacdaavid.info>\n"
"Language-Team: Spanish\n"
"Language: es\n"
"MIME-Version: 1.0\n"
@@ -18,98 +19,115 @@ msgid "Unable to delete subvolume %s"
msgstr "Incapaz de eliminar subvolumen %s"
#. embedded usage text
-#: src/lib/blacklist.sh:24
+#: src/lib/blacklist.sh:25
msgid "Usage: blacklist-normalize <$file"
msgstr "Uso: blacklist-normalize <$archivo"
#. embedded usage text
-#: src/lib/blacklist.sh:25
+#: src/lib/blacklist.sh:26
msgid "Normalizes the syntax of the blacklist on stdin."
-msgstr "Normaliza el sintaxis de la lista negra (blacklist) en stdin."
+msgstr "Normaliza la sintaxis de la lista negra en stdin."
#. embedded usage text
-#: src/lib/blacklist.sh:30
+#: src/lib/blacklist.sh:38
msgid "Usage: blacklist-cat"
msgstr "Uso: blacklist-cat"
#. embedded usage text
-#: src/lib/blacklist.sh:31
+#: src/lib/blacklist.sh:39
msgid "Prints the blacklist."
-msgstr "Imprime el blacklist"
+msgstr "Imprime la lista negra"
#. embedded usage text
-#: src/lib/blacklist.sh:32
+#: src/lib/blacklist.sh:40
msgid "Uses the cache, but downloads it if it doesn't exist. Also "
"normalizes the blacklist for easier parsing."
msgstr "Utiliza el caché, pero la descarga si no existe. También "
"normaliza la lista negra para facilitar el análisis sintáctico."
#. embedded usage text
-#: src/lib/blacklist.sh:42
+#: src/lib/blacklist.sh:50
msgid "Usage: blacklist-update"
msgstr "Uso: blacklist-update"
#. embedded usage text
-#: src/lib/blacklist.sh:43
+#: src/lib/blacklist.sh:51
msgid "Updates (or creates) the cached copy of the blacklist."
msgstr "Actualiza (o crea) la copia de la lista negra en caché."
-#: src/lib/blacklist.sh:51
+#: src/lib/blacklist.sh:59
msgid "Downloading blacklist of proprietary software packages"
-msgstr "Descarga la lista negra de paquetes de software propietario"
+msgstr "Descarga la lista negra de paquetes de software privativo"
-#: src/lib/blacklist.sh:61
+#: src/lib/blacklist.sh:69
msgid "Using local copy of blacklist"
msgstr "Usando copia local de la lista negra"
-#: src/lib/blacklist.sh:63
+#: src/lib/blacklist.sh:71
msgid "Download failed, exiting"
msgstr "Descarga fallida, saliendo"
#. embedded usage text
-#: src/lib/blacklist.sh:70
+#: src/lib/blacklist.sh:78
msgid "Usage: blacklist-cat | blacklist-lookup $pkgname"
msgstr "Uso: blacklist-cat | blacklist-lookup $pkgname"
#. embedded usage text
-#: src/lib/blacklist.sh:71
+#: src/lib/blacklist.sh:79
msgid "Filters to obtain the line for $pkgname from the blacklist on stdin."
-msgstr "Filtros para obtener la línea de $pkgname de la lista negra en stdin."
+msgstr "Filtra para obtener la línea de $pkgname de la lista negra en stdin."
#. embedded usage text
-#: src/lib/blacklist.sh:72
+#: src/lib/blacklist.sh:80
msgid "Exits successfully whether a line is found or not."
msgstr "Sale con éxito si una línea se encuentra o no."
#. embedded usage text
-#: src/lib/blacklist.sh:79
+#: src/lib/blacklist.sh:87
msgid "Usage: blacklist-cat | blacklist-get-pkg"
msgstr "Uso: blacklist-cat | blacklist-get-pkg"
#. embedded usage text
-#: src/lib/blacklist.sh:80
+#: src/lib/blacklist.sh:88
msgid "Prints only the package name field of the blacklist line(s) on stdin."
msgstr "Imprime sólo el campo del nombre del paquete de la(s) línea(s) de la lista negra en stdin."
#. embedded usage text
-#: src/lib/blacklist.sh:85
+#: src/lib/blacklist.sh:93
msgid "Usage: blacklist-cat | blacklist-get-rep"
msgstr "Uso: blacklist-cat | blacklist-get-rep"
#. embedded usage text
-#: src/lib/blacklist.sh:86
+#: src/lib/blacklist.sh:94
msgid "Prints only the replacement package field of the blacklist line(s) "
"on stdin."
msgstr "Imprime sólo el campo del paquete de reemplazo de la(s) línea(s) de la lista negra "
"en stdin."
#. embedded usage text
-#: src/lib/blacklist.sh:91
+#: src/lib/blacklist.sh:99
+msgid "Usage: blacklist-cat | blacklist-get-url"
+msgstr "Uso: blacklist-cat | blacklist-get-url"
+
+#. embedded usage text
+#: src/lib/blacklist.sh:100
+msgid "Prints URLs formed from the reference-id fields of the blacklist "
+ "line(s) on stdin."
+msgstr "Imprime sólo URLs a partir de los campos referencia-id de la(s) "
+ "línea(s) de la lista negra en stdin."
+
+#. embedded usage text
+#: src/lib/blacklist.sh:101
+msgid "Prints an empty line in the absence of reference."
+msgstr "Imprime una línea vacía en ausencia de referencia."
+
+#. embedded usage text
+#: src/lib/blacklist.sh:114
msgid "Usage: blacklist-cat | blacklist-get-reason"
msgstr "Uso: blacklist-cat | blacklist-get-reason"
#. embedded usage text
-#: src/lib/blacklist.sh:92
+#: src/lib/blacklist.sh:115
msgid "Prints only the reason field of the blacklist line(s) on stdin."
msgstr "Imprime sólo el campo de razón de la(s) línea(s) de la lista negra en stdin."
@@ -143,7 +161,7 @@ msgstr "Uso: %s [-h] COMANDO [ARGUMENTOS]"
#: src/lib/libreblacklist:46
msgid "Tool for working with the nonfree software blacklist"
-msgstr "Herramienta para trabajar la lista negra de software no libre"
+msgstr "Herramienta para trabajar con la lista negra de software no libre"
#: src/lib/libreblacklist:48
msgid "Commands:"
@@ -159,7 +177,7 @@ msgstr "Uso: %s -h"
#: src/lib/librelib:52
msgid "Finds a Bash library file"
-msgstr "Encuentra una librería de Bash"
+msgstr "Encuentra una archivo librería de Bash"
#: src/lib/librelib:54
msgid "While some libraries can be sourced just by their name because they "
@@ -167,7 +185,7 @@ msgid "While some libraries can be sourced just by their name because they "
"there (like conf.sh), so a path must be given. Hardcoding that path "
"is the way of the dark side."
msgstr "Mientras que algunas librerías se pueden obtener sólo por su nombre porque "
- "están instalados en RUTA (como libremessages), algunos no están instalados "
+ "están instaladas en RUTA (como libremessages), algunas no están instaladas "
"allí (como conf.sh), por lo que una ruta debe ser dada. Hacer 'hardcode' esa ruta "
"es el camino del lado oscuro."
@@ -241,7 +259,7 @@ msgstr "Busque KEYWORD como una palabra clave prose adicional"
#: src/lib/librexgettext:70
msgid "Disable using the default keywords"
-msgstr "Dishabilita el uso de las palabras clave predeterminadas"
+msgstr "Deshabilita el uso de las palabras clave predeterminadas"
#: src/lib/librexgettext:71
msgid "Show this text"
@@ -249,11 +267,11 @@ msgstr "Muestra este texto"
#: src/lib/librexgettext:177 src/lib/librexgettext:224
msgid "flag error: Missing expected flag meaning at argument %d"
-msgstr ""
+msgstr "error de `flag`: Se esperaba significado de `flag` en argumento %d"
#: src/lib/librexgettext:196
msgid "flag error: Jumped from argument %d to %d"
-msgstr ""
+msgstr "error de `flag`: Saltó del argumento %d al %d"
#: src/lib/librexgettext:255
msgid "unrecognized option: %s"
diff --git a/src/lib/blacklist.sh b/src/lib/blacklist.sh
index 249ee89..c092ed3 100644..100755
--- a/src/lib/blacklist.sh
+++ b/src/lib/blacklist.sh
@@ -2,6 +2,7 @@
# This may be included with or without `set -euE`
# Copyright (C) 2013-2014, 2016-2017 Luke Shumaker <lukeshu@sbcglobal.net>
+# Copyright (C) 2017 Isaac David <isacdaavid@isacdaavid.info>
#
# License: GNU GPLv2+
#
@@ -24,7 +25,14 @@
# Usage: blacklist-normalize <$file
# Normalizes the syntax of the blacklist on stdin.
blacklist-normalize() {
- sed -e '/^#/d' -e 's/^[^:]*$/&::/' -e 's/^[^:]*:[^:]*$/&:/'
+ # dynamically build sed expression based on number of fields
+ local -a expr
+ local fields=5 sep=: i
+ for (( i = $fields - 2; i >= 0; --i )); do
+ expr+=('-e' "s/^[^:]*(:[^:]*){${i}}$/&${sep}/")
+ sep+=${sep:0:1}
+ done
+ sed -r -e '/^#/d' "${expr[@]}"
}
# Usage: blacklist-cat
@@ -85,11 +93,43 @@ blacklist-get-pkg() {
# Usage: blacklist-cat | blacklist-get-rep
# Prints only the replacement package field of the blacklist line(s) on stdin.
blacklist-get-rep() {
- blacklist-normalize | cut -d: -f2
+ local -a targets=($(blacklist-get-pkg))
+ expac -Ss '%r/%n %n %P %R' | awk -v arr="${targets[*]}" '
+ {
+ gsub("[=<>]+[^[:blank:]]*", "", $0) # discard versioning
+ # build pkg -> providers table from pkg -> provides
+ for (provided = 2; provided <= NF; ++provided) {
+ if (! seen[$1 " " $provided]++) {
+ providers[$provided] = providers[$provided] $1 " "
+ }
+ }
+ }
+ END {
+ split(arr, targets, " ")
+ for (pkg in targets) {
+ sub("[ \t]+$", "", providers[targets[pkg]])
+ print providers[targets[pkg]]
+ }
+ }'
+}
+
+# Usage: blacklist-cat | blacklist-get-url
+# Prints URLs formed from the reference-id fields of the blacklist line(s) on stdin.
+# Prints an empty line in the absence of reference.
+blacklist-get-url() {
+ blacklist-normalize | awk -F: '
+ BEGIN {
+ refs["debian"] = "http://bugs.debian.org/"
+ refs["fsf"] = "http://libreplanet.org/wiki/List_of_software_that_does_not_respect_the_Free_System_Distribution_Guidelines#"
+ refs["sv"] = "https://savannah.nongnu.org/bugs/?"
+ refs["fedora"] = "https://bugzilla.redhat.com/show_bug.cgi?id="
+ refs["parabola"] = "https://labs.parabola.nu/issues/"
+ }
+ refs[$3] { print refs[$3] $4 } !refs[$3] { print "" }'
}
# Usage: blacklist-cat | blacklist-get-reason
# Prints only the reason field of the blacklist line(s) on stdin.
blacklist-get-reason() {
- blacklist-normalize | cut -d: -f3-
+ blacklist-normalize | cut -d: -f5-
}
diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh
index 49c756e..7b88b72 100644..100755
--- a/test/lib-blacklist-test.sh
+++ b/test/lib-blacklist-test.sh
@@ -6,38 +6,50 @@ describe libreblacklist
_blacklist_url=https://projects.parabola.nu/blacklist.git/plain/blacklist.txt
it_works_with_just_pkgname() {
- v="$(libreblacklist normalize <<<skype)"; [[ $v == 'skype::' ]]
+ v="$(libreblacklist normalize <<<skype)"; [[ $v == 'skype::::' ]]
v="$(libreblacklist get-pkg <<<skype)"; [[ $v == skype ]]
- v="$(libreblacklist get-rep <<<skype)"; [[ -z $v ]]
- v="$(libreblacklist get-reason <<<skype)"; [[ -z $v ]]
+ libreblacklist get-rep <<<irreplaceable | equals $'\n'
+ libreblacklist get-url <<<skype | equals $'\n'
+ libreblacklist get-reason <<<skype | equals $'\n'
}
it_works_with_everything_set() {
- line='linux:linux-libre:nonfree blobs and firmwares'
+ line='linux:conflict:parabola:id:[semifree] blobs and firmware'
v="$(libreblacklist normalize <<<"$line")"; [[ $v == "$line" ]]
v="$(libreblacklist get-pkg <<<"$line")"; [[ $v == 'linux' ]]
- v="$(libreblacklist get-rep <<<"$line")"; [[ $v == 'linux-libre' ]]
- v="$(libreblacklist get-reason <<<"$line")"; [[ $v == 'nonfree blobs and firmwares' ]]
+ v="$(libreblacklist get-rep <<<"$line")"; [[ $v == 'libre/linux-libre' ]]
+ v="$(libreblacklist get-url <<<"$line")"; [[ $v == 'https://labs.parabola.nu/issues/id' ]]
+ v="$(libreblacklist get-reason <<<"$line")"; [[ $v == '[semifree] blobs and firmware' ]]
}
it_normalizes_correctly() {
- v="$(libreblacklist normalize <<<pkg)"; [[ $v == 'pkg::' ]]
- v="$(libreblacklist normalize <<<pkg:)"; [[ $v == 'pkg::' ]]
- v="$(libreblacklist normalize <<<pkg::)"; [[ $v == 'pkg::' ]]
- v="$(libreblacklist normalize <<<pkg:rep)"; [[ $v == 'pkg:rep:' ]]
- v="$(libreblacklist normalize <<<pkg:rep:)"; [[ $v == 'pkg:rep:' ]]
- v="$(libreblacklist normalize <<<pkg:rep:reason)"; [[ $v == 'pkg:rep:reason' ]]
- v="$(libreblacklist normalize <<<pkg:rep:reason:)"; [[ $v == 'pkg:rep:reason:' ]]
+ libreblacklist normalize <<<'#comment' | equals ''
+ v="$(libreblacklist normalize <<<pkg)"; [[ $v == 'pkg::::' ]]
+ v="$(libreblacklist normalize <<<pkg:)"; [[ $v == 'pkg::::' ]]
+ v="$(libreblacklist normalize <<<pkg::)"; [[ $v == 'pkg::::' ]]
+ v="$(libreblacklist normalize <<<pkg:rep)"; [[ $v == 'pkg:rep:::' ]]
+ v="$(libreblacklist normalize <<<pkg:rep:)"; [[ $v == 'pkg:rep:::' ]]
+ v="$(libreblacklist normalize <<<pkg:rep:ref)"; [[ $v == 'pkg:rep:ref::' ]]
+ v="$(libreblacklist normalize <<<pkg:rep:ref:)"; [[ $v == 'pkg:rep:ref::' ]]
+ v="$(libreblacklist normalize <<<pkg:rep:ref:id)"; [[ $v == 'pkg:rep:ref:id:' ]]
+ v="$(libreblacklist normalize <<<pkg:rep:ref:id:)"; [[ $v == 'pkg:rep:ref:id:' ]]
+ v="$(libreblacklist normalize <<<pkg:rep:ref:id:reason)"; [[ $v == 'pkg:rep:ref:id:reason' ]]
}
it_works_with_colons_in_reason() {
- line='package:replacement:my:reason'
+ line='package:conflict:parabola:id:my:reason'
v="$(libreblacklist normalize <<<"$line")"; [[ $v == "$line" ]]
v="$(libreblacklist get-pkg <<<"$line")"; [[ $v == 'package' ]]
- v="$(libreblacklist get-rep <<<"$line")"; [[ $v == 'replacement' ]]
+ libreblacklist get-rep <<<"$line" | equals $'\n'
+ v="$(libreblacklist get-url <<<"$line")"; [[ $v == 'https://labs.parabola.nu/issues/id' ]]
v="$(libreblacklist get-reason <<<"$line")"; [[ $v == 'my:reason' ]]
}
+it_prints_urls_only_for_valid_references() {
+ libreblacklist get-url <<<package:::id: | equals $'\n'
+ libreblacklist get-url <<<package::unknown:id: | equals $'\n'
+}
+
it_fails_update_with_no_blacklist_or_network() {
mkdir -p $XDG_CONFIG_HOME/libretools
echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf
diff --git a/test/test-common.sh b/test/test-common.sh
index 7dd8128..da19490 100644..100755
--- a/test/test-common.sh
+++ b/test/test-common.sh
@@ -109,3 +109,11 @@ not() (
}
! eval "$@"
)
+
+# Plain command substitution would remove trailing whitespace, despite
+# being significant when testing for newline-terminated lines.
+equals() {
+ local stdin
+ IFS= read -rd '' stdin || :
+ [[ $1 == "$stdin" ]]
+}