0001-makepkg-Better-error-messages-for-versions-in-check-.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. From 0b1dacfbd6ed3e8b8af290a108cbcd90e2fbea5c Mon Sep 17 00:00:00 2001
  2. From: Luke Shumaker <lukeshu@parabola.nu>
  3. Date: Mon, 6 Aug 2018 23:42:48 -0400
  4. Subject: [PATCH 1/4] makepkg: Better error messages for versions in
  5. (check,make,opt)depends/provides/conflicts
  6. Given the depends
  7. depends=('foo>=1.2-1.par2')
  8. and the error message
  9. ==> ERROR: pkgver in depends is not allowed to contain colons, forward slashes, hyphens or whitespace.
  10. One would be lead to believe that the problem is that they gave a pkgrel in
  11. depends at all, not that the pkgrel contains letters.
  12. Each of the (check,make,opt)depends, conflicts, and provides linters use a
  13. glob to trim off properly formed epoch an rel from the full version string,
  14. and pass the remainder to check_pkgver(). This does a good job of
  15. accepting/rejecting full versions, but doesn't do a good job of generating
  16. good error messages when rejecting if it's because of the epoch or rel.
  17. 1. Factor out check_epoch() and check_pkgrel() from lint_epoch() and
  18. lint_pkgrel(), similarly to check_pkgver().
  19. 2. Add a check_fullpkgver() that takes a full [epoch:]ver[-rel] string and
  20. splits it in to epoch/ver/rel, and calls the appropriate check_ function
  21. on each.
  22. 3. Use check_fullpkgver() in the {,check,make,opt}depends, conflicts, and
  23. provides linters.
  24. ---
  25. scripts/Makefile.am | 1 +
  26. .../lint_pkgbuild/checkdepends.sh.in | 10 ++--
  27. .../libmakepkg/lint_pkgbuild/conflicts.sh.in | 10 ++--
  28. .../libmakepkg/lint_pkgbuild/depends.sh.in | 14 ++---
  29. scripts/libmakepkg/lint_pkgbuild/epoch.sh.in | 10 +++-
  30. .../libmakepkg/lint_pkgbuild/fullpkgver.sh.in | 54 +++++++++++++++++++
  31. .../lint_pkgbuild/makedepends.sh.in | 10 ++--
  32. .../libmakepkg/lint_pkgbuild/optdepends.sh.in | 10 ++--
  33. scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in | 20 +++++--
  34. .../libmakepkg/lint_pkgbuild/provides.sh.in | 10 ++--
  35. 10 files changed, 106 insertions(+), 43 deletions(-)
  36. create mode 100644 scripts/libmakepkg/lint_pkgbuild/fullpkgver.sh.in
  37. diff --git a/scripts/Makefile.am b/scripts/Makefile.am
  38. index f759e149..7cf8bed0 100644
  39. --- a/scripts/Makefile.am
  40. +++ b/scripts/Makefile.am
  41. @@ -73,6 +73,7 @@ LIBMAKEPKG_IN = \
  42. libmakepkg/lint_pkgbuild/conflicts.sh \
  43. libmakepkg/lint_pkgbuild/depends.sh \
  44. libmakepkg/lint_pkgbuild/epoch.sh \
  45. + libmakepkg/lint_pkgbuild/fullpkgver.sh \
  46. libmakepkg/lint_pkgbuild/install.sh \
  47. libmakepkg/lint_pkgbuild/makedepends.sh \
  48. libmakepkg/lint_pkgbuild/optdepends.sh \
  49. diff --git a/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
  50. index d5648bd4..0a9ddf67 100644
  51. --- a/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
  52. +++ b/scripts/libmakepkg/lint_pkgbuild/checkdepends.sh.in
  53. @@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_CHECKDEPENDS_SH=1
  54. LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
  55. +source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
  56. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  57. -source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  58. source "$LIBRARY/util/message.sh"
  59. source "$LIBRARY/util/pkgbuild.sh"
  60. @@ -43,12 +43,10 @@ lint_checkdepends() {
  61. for checkdepend in "${checkdepends_list[@]}"; do
  62. name=${checkdepend%%@(<|>|=|>=|<=)*}
  63. - # remove optional epoch in version specifier
  64. - ver=${checkdepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  65. lint_one_pkgname checkdepends "$name" || ret=1
  66. - if [[ $ver != $checkdepend ]]; then
  67. - # remove optional pkgrel in version specifier
  68. - check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" checkdepends || ret=1
  69. + if [[ $name != $checkdepend ]]; then
  70. + ver=${checkdepend##$name@(<|>|=|>=|<=)}
  71. + check_fullpkgver "$ver" checkdepends || ret=1
  72. fi
  73. done
  74. diff --git a/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
  75. index a18c25fa..b61459e1 100644
  76. --- a/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
  77. +++ b/scripts/libmakepkg/lint_pkgbuild/conflicts.sh.in
  78. @@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_CONFLICTS_SH=1
  79. LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
  80. +source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
  81. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  82. -source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  83. source "$LIBRARY/util/message.sh"
  84. source "$LIBRARY/util/pkgbuild.sh"
  85. @@ -43,12 +43,10 @@ lint_conflicts() {
  86. for conflict in "${conflicts_list[@]}"; do
  87. name=${conflict%%@(<|>|=|>=|<=)*}
  88. - # remove optional epoch in version specifier
  89. - ver=${conflict##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  90. lint_one_pkgname conflicts "$name" || ret=1
  91. - if [[ $ver != $conflict ]]; then
  92. - # remove optional pkgrel in version specifier
  93. - check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" conflicts || ret=1
  94. + if [[ $name != $conflict ]]; then
  95. + ver=${conflict##$name@(<|>|=|>=|<=)}
  96. + check_fullpkgver "$ver" conflicts || ret=1
  97. fi
  98. done
  99. diff --git a/scripts/libmakepkg/lint_pkgbuild/depends.sh.in b/scripts/libmakepkg/lint_pkgbuild/depends.sh.in
  100. index e363a039..aba43825 100644
  101. --- a/scripts/libmakepkg/lint_pkgbuild/depends.sh.in
  102. +++ b/scripts/libmakepkg/lint_pkgbuild/depends.sh.in
  103. @@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_DEPENDS_SH=1
  104. LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
  105. +source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
  106. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  107. -source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  108. source "$LIBRARY/util/message.sh"
  109. source "$LIBRARY/util/pkgbuild.sh"
  110. @@ -43,13 +43,13 @@ lint_depends() {
  111. for depend in "${depends_list[@]}"; do
  112. name=${depend%%@(<|>|=|>=|<=)*}
  113. - # remove optional epoch in version specifier
  114. - ver=${depend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  115. lint_one_pkgname depends "$name" || ret=1
  116. - # Don't validate empty version because of https://bugs.archlinux.org/task/58776
  117. - if [[ $ver != $depend && -n $ver ]]; then
  118. - # remove optional pkgrel in version specifier
  119. - check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" depends || ret=1
  120. + if [[ $name != $depend ]]; then
  121. + ver=${depend##$name@(<|>|=|>=|<=)}
  122. + # Don't validate empty version because of https://bugs.archlinux.org/task/58776
  123. + if [[ -n $ver ]]; then
  124. + check_fullpkgver "$ver" depends || ret=1
  125. + fi
  126. fi
  127. done
  128. diff --git a/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in b/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
  129. index 93bd05c1..c98f91b0 100644
  130. --- a/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
  131. +++ b/scripts/libmakepkg/lint_pkgbuild/epoch.sh.in
  132. @@ -29,9 +29,15 @@ source "$LIBRARY/util/message.sh"
  133. lint_pkgbuild_functions+=('lint_epoch')
  134. -lint_epoch() {
  135. +check_epoch() {
  136. + local epoch=$1 type=$2
  137. +
  138. if [[ $epoch != *([[:digit:]]) ]]; then
  139. - error "$(gettext "%s must be an integer, not %s.")" "epoch" "$epoch"
  140. + error "$(gettext "%s must be an integer, not %s.")" "epoch${type:+ in $type}" "$epoch"
  141. return 1
  142. fi
  143. }
  144. +
  145. +lint_epoch() {
  146. + check_epoch "$epoch"
  147. +}
  148. diff --git a/scripts/libmakepkg/lint_pkgbuild/fullpkgver.sh.in b/scripts/libmakepkg/lint_pkgbuild/fullpkgver.sh.in
  149. new file mode 100644
  150. index 00000000..1cac7fbc
  151. --- /dev/null
  152. +++ b/scripts/libmakepkg/lint_pkgbuild/fullpkgver.sh.in
  153. @@ -0,0 +1,54 @@
  154. +#!/bin/bash
  155. +#
  156. +# fullpkgver.sh - Check whether a full version conforms to requirements.
  157. +#
  158. +# Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
  159. +#
  160. +# This program is free software; you can redistribute it and/or modify
  161. +# it under the terms of the GNU General Public License as published by
  162. +# the Free Software Foundation; either version 2 of the License, or
  163. +# (at your option) any later version.
  164. +#
  165. +# This program is distributed in the hope that it will be useful,
  166. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  167. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  168. +# GNU General Public License for more details.
  169. +#
  170. +# You should have received a copy of the GNU General Public License
  171. +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  172. +#
  173. +
  174. +[[ -n "$LIBMAKEPKG_LINT_PKGBUILD_FULLPKGVER_SH" ]] && return
  175. +LIBMAKEPKG_LINT_PKGBUILD_FULLPKGVER_SH=1
  176. +
  177. +LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
  178. +
  179. +source "$LIBRARY/lint_pkgbuild/epoch.sh"
  180. +source "$LIBRARY/lint_pkgbuild/pkgrel.sh"
  181. +source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  182. +
  183. +
  184. +check_fullpkgver() {
  185. + local fullver=$1 type=$2
  186. + local ret=0
  187. +
  188. + # If there are multiple colons or multiple hyphens, there's a
  189. + # question of how we split it--it's invalid either way, but it
  190. + # will affect error messages. Let's mimic version.c:parseEVR().
  191. +
  192. + if [[ $fullver = *:* ]]; then
  193. + # split at the *first* colon
  194. + check_epoch "${fullver%%:*}" "$type" || ret=1
  195. + fullver=${fullver#*:}
  196. + fi
  197. +
  198. + if [[ $fullver = *-* ]]; then
  199. + # split at the *last* hyphen
  200. + check_pkgrel "${fullver##*-}" "$type" || ret=1
  201. + fullver=${fullver%-*}
  202. + fi
  203. +
  204. + check_pkgver "$fullver" "$type" || ret=1
  205. +
  206. + return $ret
  207. +}
  208. diff --git a/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in
  209. index 4cc4ab5d..20c7f7dc 100644
  210. --- a/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in
  211. +++ b/scripts/libmakepkg/lint_pkgbuild/makedepends.sh.in
  212. @@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_MAKEDEPENDS_SH=1
  213. LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
  214. +source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
  215. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  216. -source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  217. source "$LIBRARY/util/message.sh"
  218. source "$LIBRARY/util/pkgbuild.sh"
  219. @@ -43,12 +43,10 @@ lint_makedepends() {
  220. for makedepend in "${makedepends_list[@]}"; do
  221. name=${makedepend%%@(<|>|=|>=|<=)*}
  222. - # remove optional epoch in version specifier
  223. - ver=${makedepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  224. lint_one_pkgname makedepends "$name" || ret=1
  225. - if [[ $ver != $makedepend ]]; then
  226. - # remove optional pkgrel in version specifier
  227. - check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" makedepends || ret=1
  228. + if [[ $name != $makedepend ]]; then
  229. + ver=${makedepend##$name@(<|>|=|>=|<=)}
  230. + check_fullpkgver "$ver" makedepends || ret=1
  231. fi
  232. done
  233. diff --git a/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in b/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in
  234. index 9978fe9b..505ee848 100644
  235. --- a/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in
  236. +++ b/scripts/libmakepkg/lint_pkgbuild/optdepends.sh.in
  237. @@ -23,6 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_OPTDEPENDS_SH=1
  238. LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
  239. +source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
  240. +source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  241. source "$LIBRARY/util/message.sh"
  242. source "$LIBRARY/util/pkgbuild.sh"
  243. @@ -41,12 +43,10 @@ lint_optdepends() {
  244. for optdepend in "${optdepends_list[@]%%:[[:space:]]*}"; do
  245. name=${optdepend%%@(<|>|=|>=|<=)*}
  246. - # remove optional epoch in version specifier
  247. - ver=${optdepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  248. lint_one_pkgname optdepends "$name" || ret=1
  249. - if [[ $ver != $optdepend ]]; then
  250. - # remove optional pkgrel in version specifier
  251. - check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" optdepends || ret=1
  252. + if [[ $name != $optdepend ]]; then
  253. + ver=${optdepend##$name@(<|>|=|>=|<=)}
  254. + check_fullpkgver "$ver" optdepends || ret=1
  255. fi
  256. done
  257. diff --git a/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in b/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
  258. index f294a3bf..762f054a 100644
  259. --- a/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
  260. +++ b/scripts/libmakepkg/lint_pkgbuild/pkgrel.sh.in
  261. @@ -29,14 +29,24 @@ source "$LIBRARY/util/message.sh"
  262. lint_pkgbuild_functions+=('lint_pkgrel')
  263. -lint_pkgrel() {
  264. - if [[ -z $pkgrel ]]; then
  265. - error "$(gettext "%s is not allowed to be empty.")" "pkgrel"
  266. +check_pkgrel() {
  267. + local rel=$1 type=$2
  268. + if [[ -z $rel ]]; then
  269. + error "$(gettext "%s is not allowed to be empty.")" "pkgrel${type:+ in $type}"
  270. return 1
  271. fi
  272. - if [[ $pkgrel != +([0-9])?(.+([0-9])) ]]; then
  273. - error "$(gettext "%s must be a decimal, not %s.")" "pkgrel" "$pkgrel"
  274. + if [[ $rel != +([0-9])?(.+([0-9])) ]]; then
  275. + error "$(gettext "%s must be a decimal, not %s.")" "pkgrel${type:+ in $type}" "$rel"
  276. return 1
  277. fi
  278. }
  279. +
  280. +lint_pkgrel() {
  281. + if (( PKGVERFUNC )); then
  282. + # defer check to after getting version from pkgver function
  283. + return 0
  284. + fi
  285. +
  286. + check_pkgrel "$pkgrel"
  287. +}
  288. diff --git a/scripts/libmakepkg/lint_pkgbuild/provides.sh.in b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
  289. index 102be08e..5a529728 100644
  290. --- a/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
  291. +++ b/scripts/libmakepkg/lint_pkgbuild/provides.sh.in
  292. @@ -23,8 +23,8 @@ LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH=1
  293. LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
  294. +source "$LIBRARY/lint_pkgbuild/fullpkgver.sh"
  295. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  296. -source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  297. source "$LIBRARY/util/message.sh"
  298. source "$LIBRARY/util/pkgbuild.sh"
  299. @@ -48,12 +48,10 @@ lint_provides() {
  300. continue
  301. fi
  302. name=${provide%=*}
  303. - # remove optional epoch in version specifier
  304. - ver=${provide##$name=?(+([0-9]):)}
  305. lint_one_pkgname provides "$name" || ret=1
  306. - if [[ $ver != $provide ]]; then
  307. - # remove optional pkgrel in version specifier
  308. - check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" provides || ret=1
  309. + if [[ $name != $provide ]]; then
  310. + ver=${provide##$name=}
  311. + check_fullpkgver "$ver" provides || ret=1
  312. fi
  313. done
  314. --
  315. 2.18.0