Advertisement
Guest User

Untitled

a guest
Aug 16th, 2018
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 303.38 KB | None | 0 0
  1. #!/usr/bin/bash
  2. #
  3. # makepkg - make packages compatible for use with pacman
  4. # Generated from makepkg.sh.in; do not edit by hand.
  5. #
  6. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  8. # Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
  9. # Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
  10. # Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
  11. # Copyright (c) 2006 by Alex Smith <alex@alex-smith.me.uk>
  12. # Copyright (c) 2006 by Andras Voroskoi <voroskoi@frugalware.org>
  13. #
  14. # This program is free software; you can redistribute it and/or modify
  15. # it under the terms of the GNU General Public License as published by
  16. # the Free Software Foundation; either version 2 of the License, or
  17. # (at your option) any later version.
  18. #
  19. # This program is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. #
  27.  
  28. # makepkg uses quite a few external programs during its execution. You
  29. # need to have at least the following installed for makepkg to function:
  30. # awk, bsdtar (libarchive), bzip2, coreutils, fakeroot, file, find (findutils),
  31. # gettext, gpg, grep, gzip, sed, tput (ncurses), xz
  32.  
  33. # gettext initialization
  34. export TEXTDOMAIN='pacman-scripts'
  35. + export TEXTDOMAIN=pacman-scripts
  36. + TEXTDOMAIN=pacman-scripts
  37. export TEXTDOMAINDIR='/usr/share/locale'
  38. + export TEXTDOMAINDIR=/usr/share/locale
  39. + TEXTDOMAINDIR=/usr/share/locale
  40.  
  41. # file -i does not work on Mac OSX unless legacy mode is set
  42. export COMMAND_MODE='legacy'
  43. + export COMMAND_MODE=legacy
  44. + COMMAND_MODE=legacy
  45. # Ensure CDPATH doesn't screw with our cd calls
  46. unset CDPATH
  47. + unset CDPATH
  48. # Ensure GREP_OPTIONS doesn't screw with our grep calls
  49. unset GREP_OPTIONS
  50. + unset GREP_OPTIONS
  51.  
  52. declare -r makepkg_version='5.1.1'
  53. + declare -r makepkg_version=5.1.1
  54. declare -r confdir='/etc'
  55. + declare -r confdir=/etc
  56. declare -r BUILDSCRIPT='PKGBUILD'
  57. + declare -r BUILDSCRIPT=PKGBUILD
  58. declare -r startdir="$(pwd -P)"
  59. ++ pwd -P
  60. + declare -r startdir=/home/keltere
  61.  
  62. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  63. + LIBRARY=/usr/share/makepkg
  64.  
  65. build_options=('ccache' 'distcc' 'buildflags' 'makeflags')
  66. + build_options=('ccache' 'distcc' 'buildflags' 'makeflags')
  67. splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends'
  68. 'optdepends' 'provides' 'conflicts' 'replaces' 'backup'
  69. 'options' 'install' 'changelog')
  70. + splitpkg_overrides=('pkgdesc' 'arch' 'url' 'license' 'groups' 'depends' 'optdepends' 'provides' 'conflicts' 'replaces' 'backup' 'options' 'install' 'changelog')
  71. readonly -a build_options splitpkg_overrides
  72. + readonly -a build_options splitpkg_overrides
  73.  
  74. known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512' 'whirlpool')
  75. + known_hash_algos=('md5' 'sha1' 'sha224' 'sha256' 'sha384' 'sha512' 'whirlpool')
  76.  
  77. # Options
  78. ASDEPS=0
  79. + ASDEPS=0
  80. BUILDFUNC=0
  81. + BUILDFUNC=0
  82. CHECKFUNC=0
  83. + CHECKFUNC=0
  84. CLEANBUILD=0
  85. + CLEANBUILD=0
  86. CLEANUP=0
  87. + CLEANUP=0
  88. DEP_BIN=0
  89. + DEP_BIN=0
  90. FORCE=0
  91. + FORCE=0
  92. GENINTEG=0
  93. + GENINTEG=0
  94. HOLDVER=0
  95. + HOLDVER=0
  96. IGNOREARCH=0
  97. + IGNOREARCH=0
  98. INFAKEROOT=0
  99. + INFAKEROOT=0
  100. INSTALL=0
  101. + INSTALL=0
  102. LOGGING=0
  103. + LOGGING=0
  104. NEEDED=0
  105. + NEEDED=0
  106. NOARCHIVE=0
  107. + NOARCHIVE=0
  108. NOBUILD=0
  109. + NOBUILD=0
  110. NODEPS=0
  111. + NODEPS=0
  112. NOEXTRACT=0
  113. + NOEXTRACT=0
  114. PKGFUNC=0
  115. + PKGFUNC=0
  116. PKGVERFUNC=0
  117. + PKGVERFUNC=0
  118. PREPAREFUNC=0
  119. + PREPAREFUNC=0
  120. REPKG=0
  121. + REPKG=0
  122. REPRODUCIBLE=0
  123. + REPRODUCIBLE=0
  124. RMDEPS=0
  125. + RMDEPS=0
  126. SKIPCHECKSUMS=0
  127. + SKIPCHECKSUMS=0
  128. SKIPPGPCHECK=0
  129. + SKIPPGPCHECK=0
  130. SIGNPKG=''
  131. + SIGNPKG=
  132. SPLITPKG=0
  133. + SPLITPKG=0
  134. SOURCEONLY=0
  135. + SOURCEONLY=0
  136. VERIFYSOURCE=0
  137. + VERIFYSOURCE=0
  138.  
  139. if [[ -n $SOURCE_DATE_EPOCH ]]; then
  140. REPRODUCIBLE=1
  141. else
  142. SOURCE_DATE_EPOCH=$(date +%s)
  143. fi
  144. + [[ -n '' ]]
  145. ++ date +%s
  146. + SOURCE_DATE_EPOCH=1534416503
  147. export SOURCE_DATE_EPOCH
  148. + export SOURCE_DATE_EPOCH
  149.  
  150. PACMAN_OPTS=()
  151. + PACMAN_OPTS=()
  152.  
  153. shopt -s extglob
  154. + shopt -s extglob
  155.  
  156. ### SUBROUTINES ###
  157.  
  158. # Import libmakepkg
  159. for lib in "$LIBRARY"/*.sh; do
  160. source "$lib"
  161. done
  162. + for lib in "$LIBRARY"/*.sh
  163. + source /usr/share/makepkg/integrity.sh
  164. #!/usr/bin/bash
  165. #
  166. # integrity.sh - functions relating to source integrity checking
  167. #
  168. # Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
  169. #
  170. # This program is free software; you can redistribute it and/or modify
  171. # it under the terms of the GNU General Public License as published by
  172. # the Free Software Foundation; either version 2 of the License, or
  173. # (at your option) any later version.
  174. #
  175. # This program is distributed in the hope that it will be useful,
  176. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  177. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  178. # GNU General Public License for more details.
  179. #
  180. # You should have received a copy of the GNU General Public License
  181. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  182. #
  183.  
  184. [[ -n "$LIBMAKEPKG_INTEGRITY_SH" ]] && return
  185. ++ [[ -n '' ]]
  186. LIBMAKEPKG_INTEGRITY_SH=1
  187. ++ LIBMAKEPKG_INTEGRITY_SH=1
  188.  
  189. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  190. ++ LIBRARY=/usr/share/makepkg
  191.  
  192. source "$LIBRARY/util/message.sh"
  193. ++ source /usr/share/makepkg/util/message.sh
  194. #!/usr/bin/bash
  195. #
  196. # message.sh - functions for outputting messages in makepkg
  197. #
  198. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  199. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  200. #
  201. # This program is free software; you can redistribute it and/or modify
  202. # it under the terms of the GNU General Public License as published by
  203. # the Free Software Foundation; either version 2 of the License, or
  204. # (at your option) any later version.
  205. #
  206. # This program is distributed in the hope that it will be useful,
  207. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  208. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  209. # GNU General Public License for more details.
  210. #
  211. # You should have received a copy of the GNU General Public License
  212. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  213. #
  214.  
  215. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  216. +++ [[ -n '' ]]
  217. LIBMAKEPKG_UTIL_MESSAGE_SH=1
  218. +++ LIBMAKEPKG_UTIL_MESSAGE_SH=1
  219.  
  220.  
  221. colorize() {
  222. # prefer terminal safe colored and bold text when tput is supported
  223. if tput setaf 0 &>/dev/null; then
  224. ALL_OFF="$(tput sgr0)"
  225. BOLD="$(tput bold)"
  226. BLUE="${BOLD}$(tput setaf 4)"
  227. GREEN="${BOLD}$(tput setaf 2)"
  228. RED="${BOLD}$(tput setaf 1)"
  229. YELLOW="${BOLD}$(tput setaf 3)"
  230. else
  231. ALL_OFF="\e[0m"
  232. BOLD="\e[1m"
  233. BLUE="${BOLD}\e[34m"
  234. GREEN="${BOLD}\e[32m"
  235. RED="${BOLD}\e[31m"
  236. YELLOW="${BOLD}\e[33m"
  237. fi
  238. readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
  239. }
  240.  
  241. plain() {
  242. local mesg=$1; shift
  243. printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  244. }
  245.  
  246. msg() {
  247. local mesg=$1; shift
  248. printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  249. }
  250.  
  251. msg2() {
  252. local mesg=$1; shift
  253. printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  254. }
  255.  
  256. warning() {
  257. local mesg=$1; shift
  258. printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  259. }
  260.  
  261. error() {
  262. local mesg=$1; shift
  263. printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  264. }
  265.  
  266. for lib in "$LIBRARY/integrity/"*.sh; do
  267. source "$lib"
  268. done
  269. ++ for lib in "$LIBRARY/integrity/"*.sh
  270. ++ source /usr/share/makepkg/integrity/generate_checksum.sh
  271. #!/usr/bin/bash
  272. #
  273. # generate_checksum.sh - functions for generating source checksums
  274. #
  275. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  276. #
  277. # This program is free software; you can redistribute it and/or modify
  278. # it under the terms of the GNU General Public License as published by
  279. # the Free Software Foundation; either version 2 of the License, or
  280. # (at your option) any later version.
  281. #
  282. # This program is distributed in the hope that it will be useful,
  283. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  284. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  285. # GNU General Public License for more details.
  286. #
  287. # You should have received a copy of the GNU General Public License
  288. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  289. #
  290.  
  291. [[ -n "$LIBMAKEPKG_INTEGRITY_GENERATE_CHECKSUM_SH" ]] && return
  292. +++ [[ -n '' ]]
  293. LIBMAKEPKG_INTEGRITY_GENERATE_CHECKSUM_SH=1
  294. +++ LIBMAKEPKG_INTEGRITY_GENERATE_CHECKSUM_SH=1
  295.  
  296. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  297. +++ LIBRARY=/usr/share/makepkg
  298.  
  299. source "$LIBRARY/util/message.sh"
  300. +++ source /usr/share/makepkg/util/message.sh
  301. #!/usr/bin/bash
  302. #
  303. # message.sh - functions for outputting messages in makepkg
  304. #
  305. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  306. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  307. #
  308. # This program is free software; you can redistribute it and/or modify
  309. # it under the terms of the GNU General Public License as published by
  310. # the Free Software Foundation; either version 2 of the License, or
  311. # (at your option) any later version.
  312. #
  313. # This program is distributed in the hope that it will be useful,
  314. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  315. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  316. # GNU General Public License for more details.
  317. #
  318. # You should have received a copy of the GNU General Public License
  319. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  320. #
  321.  
  322. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  323. ++++ [[ -n 1 ]]
  324. ++++ return
  325. source "$LIBRARY/util/pkgbuild.sh"
  326. +++ source /usr/share/makepkg/util/pkgbuild.sh
  327. #!/usr/bin/bash
  328. #
  329. # pkgbuild.sh - functions to extract information from PKGBUILD files
  330. #
  331. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  332. #
  333. # This program is free software; you can redistribute it and/or modify
  334. # it under the terms of the GNU General Public License as published by
  335. # the Free Software Foundation; either version 2 of the License, or
  336. # (at your option) any later version.
  337. #
  338. # This program is distributed in the hope that it will be useful,
  339. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  340. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  341. # GNU General Public License for more details.
  342. #
  343. # You should have received a copy of the GNU General Public License
  344. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  345. #
  346.  
  347. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  348. ++++ [[ -n '' ]]
  349. LIBMAKEPKG_UTIL_PKGBUILD_SH=1
  350. ++++ LIBMAKEPKG_UTIL_PKGBUILD_SH=1
  351.  
  352.  
  353. have_function() {
  354. declare -f "$1" >/dev/null
  355. }
  356.  
  357. grep_function() {
  358. { declare -f "$1" || declare -f package; } 2>/dev/null | grep -E "$2"
  359. }
  360.  
  361. array_build() {
  362. local dest=$1 src=$2 i keys values
  363.  
  364. # it's an error to try to copy a value which doesn't exist.
  365. declare -p "$2" &>/dev/null || return 1
  366.  
  367. # Build an array of the indicies of the source array.
  368. eval "keys=(\"\${!$2[@]}\")"
  369.  
  370. # Clear the destination array
  371. eval "$dest=()"
  372.  
  373. # Read values indirectly via their index. This approach gives us support
  374. # for associative arrays, sparse arrays, and empty strings as elements.
  375. for i in "${keys[@]}"; do
  376. values+=("printf -v '$dest[$i]' %s \"\${$src[$i]}\";")
  377. done
  378.  
  379. eval "${values[*]}"
  380. }
  381.  
  382. extract_global_variable() {
  383. # $1: variable name
  384. # $2: multivalued
  385. # $3: name of output var
  386.  
  387. local attr=$1 isarray=$2 outputvar=$3 ref
  388.  
  389. if (( isarray )); then
  390. array_build ref "$attr"
  391. [[ ${ref[@]} ]] && array_build "$outputvar" "$attr"
  392. else
  393. [[ ${!attr} ]] && printf -v "$outputvar" %s "${!attr}"
  394. fi
  395. }
  396.  
  397. extract_function_variable() {
  398. # $1: function name
  399. # $2: variable name
  400. # $3: multivalued
  401. # $4: name of output var
  402.  
  403. local funcname=$1 attr=$2 isarray=$3 outputvar=$4 attr_regex= decl= r=1
  404.  
  405. if (( isarray )); then
  406. printf -v attr_regex '^[[:space:]]* %s\+?=\(' "$2"
  407. else
  408. printf -v attr_regex '^[[:space:]]* %s\+?=[^(]' "$2"
  409. fi
  410.  
  411. # this function requires extglob - save current status to restore later
  412. local shellopts=$(shopt -p extglob)
  413. shopt -s extglob
  414.  
  415. while read -r; do
  416. # strip leading whitespace and any usage of declare
  417. decl=${REPLY##*([[:space:]])}
  418. eval "${decl/#$attr/$outputvar}"
  419.  
  420. # entering this loop at all means we found a match, so notify the caller.
  421. r=0
  422. done < <(grep_function "$funcname" "$attr_regex")
  423.  
  424. eval "$shellopts"
  425.  
  426. return $r
  427. }
  428.  
  429. get_pkgbuild_attribute() {
  430. # $1: package name
  431. # $2: attribute name
  432. # $3: multivalued
  433. # $4: name of output var
  434.  
  435. local pkgname=$1 attrname=$2 isarray=$3 outputvar=$4
  436.  
  437. if (( isarray )); then
  438. eval "$outputvar=()"
  439. else
  440. printf -v "$outputvar" %s ''
  441. fi
  442.  
  443. if [[ $pkgname ]]; then
  444. extract_global_variable "$attrname" "$isarray" "$outputvar"
  445. extract_function_variable "package_$pkgname" "$attrname" "$isarray" "$outputvar"
  446. else
  447. extract_global_variable "$attrname" "$isarray" "$outputvar"
  448. fi
  449. }
  450.  
  451. get_pkgbuild_all_split_attributes() {
  452. local attrname=$1 outputvar=$2 all_list list
  453.  
  454. if extract_global_variable "$attrname" 1 list; then
  455. all_list+=("${list[@]}")
  456. fi
  457. for a in "${arch[@]}"; do
  458. if extract_global_variable "${attrname}_$a" 1 list; then
  459. all_list+=("${list[@]}")
  460. fi
  461. done
  462.  
  463. for name in "${pkgname[@]}"; do
  464. if extract_function_variable "package_$name" "$attrname" 1 list; then
  465. all_list+=("${list[@]}")
  466. fi
  467.  
  468. for a in "${arch[@]}"; do
  469. if extract_function_variable "package_$name" "${attrname}_$a" 1 list; then
  470. all_list+=("${list[@]}")
  471. fi
  472. done
  473. done
  474.  
  475. [[ ${all_list[@]} ]] && array_build "$outputvar" all_list
  476. }
  477.  
  478. ##
  479. # usage : get_full_version()
  480. # return : full version spec, including epoch (if necessary), pkgver, pkgrel
  481. ##
  482. get_full_version() {
  483. if (( epoch > 0 )); then
  484. printf "%s\n" "$epoch:$pkgver-$pkgrel"
  485. else
  486. printf "%s\n" "$pkgver-$pkgrel"
  487. fi
  488. }
  489.  
  490. ##
  491. # usage : get_pkg_arch( [$pkgname] )
  492. # return : architecture of the package
  493. ##
  494. get_pkg_arch() {
  495. if [[ -z $1 ]]; then
  496. if [[ $arch = "any" ]]; then
  497. printf "%s\n" "any"
  498. else
  499. printf "%s\n" "$CARCH"
  500. fi
  501. else
  502. local arch_override
  503. get_pkgbuild_attribute "$1" arch 1 arch_override
  504. (( ${#arch_override[@]} == 0 )) && arch_override=("${arch[@]}")
  505. if [[ $arch_override = "any" ]]; then
  506. printf "%s\n" "any"
  507. else
  508. printf "%s\n" "$CARCH"
  509. fi
  510. fi
  511. }
  512.  
  513. print_all_package_names() {
  514. local version=$(get_full_version)
  515. local architecture pkg opts a
  516. for pkg in ${pkgname[@]}; do
  517. architecture=$(get_pkg_arch $pkg)
  518. printf "%s/%s-%s-%s%s\n" "$PKGDEST" "$pkg" "$version" "$architecture" "$PKGEXT"
  519. done
  520. if check_option "debug" "y" && check_option "strip" "y"; then
  521. architecture=$(get_pkg_arch)
  522. printf "%s/%s-%s-%s-%s%s\n" "$PKGDEST" "$pkgbase" "debug" "$version" "$architecture" "$PKGEXT"
  523. fi
  524. }
  525.  
  526. get_all_sources() {
  527. local aggregate l a
  528.  
  529. if array_build l 'source'; then
  530. aggregate+=("${l[@]}")
  531. fi
  532.  
  533. for a in "${arch[@]}"; do
  534. if array_build l "source_$a"; then
  535. aggregate+=("${l[@]}")
  536. fi
  537. done
  538.  
  539. array_build "$1" "aggregate"
  540. }
  541.  
  542. get_all_sources_for_arch() {
  543. local aggregate l
  544.  
  545. if array_build l 'source'; then
  546. aggregate+=("${l[@]}")
  547. fi
  548.  
  549. if array_build l "source_$CARCH"; then
  550. aggregate+=("${l[@]}")
  551. fi
  552.  
  553. array_build "$1" "aggregate"
  554. }
  555.  
  556. get_integlist() {
  557. local integ
  558. local integlist=()
  559.  
  560. for integ in "${known_hash_algos[@]}"; do
  561. # check for e.g. "sha256sums"
  562. local sumname="${integ}sums[@]"
  563. if [[ -n ${!sumname} ]]; then
  564. integlist+=("$integ")
  565. continue
  566. fi
  567.  
  568. # check for e.g. "sha256sums_x86_64"
  569. for a in "${arch[@]}"; do
  570. local sumname="${integ}sums_${a}[@]"
  571. if [[ -n ${!sumname} ]]; then
  572. integlist+=("$integ")
  573. break
  574. fi
  575. done
  576. done
  577.  
  578. if (( ${#integlist[@]} > 0 )); then
  579. printf "%s\n" "${integlist[@]}"
  580. else
  581. printf "%s\n" "${INTEGRITY_CHECK[@]}"
  582. fi
  583. }
  584.  
  585. generate_one_checksum() {
  586. local integ=$1 arch=$2 sources numsrc indentsz idx
  587.  
  588. if [[ $arch ]]; then
  589. array_build sources "source_$arch"
  590. else
  591. array_build sources 'source'
  592. fi
  593.  
  594. numsrc=${#sources[*]}
  595. if (( numsrc == 0 )); then
  596. return
  597. fi
  598.  
  599. if [[ $arch ]]; then
  600. printf "%ssums_%s=(%n" "$integ" "$arch" indentsz
  601. else
  602. printf "%ssums=(%n" "$integ" indentsz
  603. fi
  604.  
  605. for (( idx = 0; idx < numsrc; ++idx )); do
  606. local netfile=${sources[idx]}
  607. local proto sum
  608. proto="$(get_protocol "$netfile")"
  609.  
  610. case $proto in
  611. bzr*|git*|hg*|svn*)
  612. sum="SKIP"
  613. ;;
  614. *)
  615. if [[ ${netfile%%::*} != *.@(sig?(n)|asc) ]]; then
  616. local file
  617. file="$(get_filepath "$netfile")" || missing_source_file "$netfile"
  618. sum="$("${integ}sum" "$file")"
  619. sum=${sum%% *}
  620. else
  621. sum="SKIP"
  622. fi
  623. ;;
  624. esac
  625.  
  626. # indent checksum on lines after the first
  627. printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'"
  628.  
  629. # print a newline on lines before the last
  630. (( idx < (numsrc - 1) )) && echo
  631. done
  632.  
  633. echo ")"
  634. }
  635.  
  636. generate_checksums() {
  637. msg "$(gettext "Generating checksums for source files...")"
  638.  
  639. local integlist
  640. if (( $# == 0 )); then
  641. IFS=$'\n' read -rd '' -a integlist < <(get_integlist)
  642. else
  643. integlist=("$@")
  644. fi
  645.  
  646. local integ
  647. for integ in "${integlist[@]}"; do
  648. if ! in_array "$integ" "${known_hash_algos[@]}"; then
  649. error "$(gettext "Invalid integrity algorithm '%s' specified.")" "$integ"
  650. exit 1 # $E_CONFIG_ERROR
  651. fi
  652.  
  653. generate_one_checksum "$integ"
  654. for a in "${arch[@]}"; do
  655. generate_one_checksum "$integ" "$a"
  656. done
  657. done
  658. }
  659. ++ for lib in "$LIBRARY/integrity/"*.sh
  660. ++ source /usr/share/makepkg/integrity/generate_signature.sh
  661. #!/usr/bin/bash
  662. #
  663. # generate_signature.sh - functions for generating PGP signatures
  664. #
  665. # Copyright (c) 2008-2018 Pacman Development Team <pacman-dev@archlinux.org>
  666. #
  667. # This program is free software; you can redistribute it and/or modify
  668. # it under the terms of the GNU General Public License as published by
  669. # the Free Software Foundation; either version 2 of the License, or
  670. # (at your option) any later version.
  671. #
  672. # This program is distributed in the hope that it will be useful,
  673. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  674. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  675. # GNU General Public License for more details.
  676. #
  677. # You should have received a copy of the GNU General Public License
  678. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  679. #
  680.  
  681. [[ -n "$LIBMAKEPKG_INTEGRITY_GENERATE_SIGNATURE_SH" ]] && return
  682. +++ [[ -n '' ]]
  683. LIBMAKEPKG_INTEGRITY_GENERATE_SIGNATURE_SH=1
  684. +++ LIBMAKEPKG_INTEGRITY_GENERATE_SIGNATURE_SH=1
  685.  
  686. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  687. +++ LIBRARY=/usr/share/makepkg
  688.  
  689. source "$LIBRARY/util/message.sh"
  690. +++ source /usr/share/makepkg/util/message.sh
  691. #!/usr/bin/bash
  692. #
  693. # message.sh - functions for outputting messages in makepkg
  694. #
  695. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  696. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  697. #
  698. # This program is free software; you can redistribute it and/or modify
  699. # it under the terms of the GNU General Public License as published by
  700. # the Free Software Foundation; either version 2 of the License, or
  701. # (at your option) any later version.
  702. #
  703. # This program is distributed in the hope that it will be useful,
  704. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  705. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  706. # GNU General Public License for more details.
  707. #
  708. # You should have received a copy of the GNU General Public License
  709. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  710. #
  711.  
  712. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  713. ++++ [[ -n 1 ]]
  714. ++++ return
  715.  
  716. create_signature() {
  717. local ret=0
  718. local filename="$1"
  719.  
  720. local SIGNWITHKEY=""
  721. if [[ -n $GPGKEY ]]; then
  722. SIGNWITHKEY="-u ${GPGKEY}"
  723. fi
  724.  
  725. gpg --detach-sign --use-agent ${SIGNWITHKEY} --no-armor "$filename" &>/dev/null || ret=$?
  726.  
  727.  
  728. if (( ! ret )); then
  729. msg2 "$(gettext "Created signature file %s.")" "${filename##*/}.sig"
  730. else
  731. warning "$(gettext "Failed to sign package file.")"
  732. fi
  733.  
  734. return $ret
  735. }
  736.  
  737. create_package_signatures() {
  738. if [[ $SIGNPKG != 'y' ]]; then
  739. return 0
  740. fi
  741. local pkg pkgarch pkg_file
  742. local fullver=$(get_full_version)
  743.  
  744. msg "$(gettext "Signing package(s)...")"
  745.  
  746. for pkg in "${pkgname[@]}"; do
  747. pkgarch=$(get_pkg_arch $pkg)
  748. pkg_file="$PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT}"
  749.  
  750. create_signature "$pkg_file"
  751. done
  752.  
  753. # check if debug package needs a signature
  754. if check_option "debug" "y" && check_option "strip" "y"; then
  755. pkg=$pkgbase-debug
  756. pkgarch=$(get_pkg_arch)
  757. pkg_file="$PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT}"
  758. if [[ -f $pkg_file ]]; then
  759. create_signature "$pkg_file"
  760. fi
  761. fi
  762. }
  763. ++ for lib in "$LIBRARY/integrity/"*.sh
  764. ++ source /usr/share/makepkg/integrity/verify_checksum.sh
  765. #!/usr/bin/bash
  766. #
  767. # verify_checksum.sh - functions for checking source checksums
  768. #
  769. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  770. #
  771. # This program is free software; you can redistribute it and/or modify
  772. # it under the terms of the GNU General Public License as published by
  773. # the Free Software Foundation; either version 2 of the License, or
  774. # (at your option) any later version.
  775. #
  776. # This program is distributed in the hope that it will be useful,
  777. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  778. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  779. # GNU General Public License for more details.
  780. #
  781. # You should have received a copy of the GNU General Public License
  782. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  783. #
  784.  
  785. [[ -n "$LIBMAKEPKG_INTEGRITY_VERIFY_CHECKSUM_SH" ]] && return
  786. +++ [[ -n '' ]]
  787. LIBMAKEPKG_INTEGRITY_CHECKSUM_SH=1
  788. +++ LIBMAKEPKG_INTEGRITY_CHECKSUM_SH=1
  789.  
  790. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  791. +++ LIBRARY=/usr/share/makepkg
  792.  
  793. source "$LIBRARY/util/message.sh"
  794. +++ source /usr/share/makepkg/util/message.sh
  795. #!/usr/bin/bash
  796. #
  797. # message.sh - functions for outputting messages in makepkg
  798. #
  799. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  800. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  801. #
  802. # This program is free software; you can redistribute it and/or modify
  803. # it under the terms of the GNU General Public License as published by
  804. # the Free Software Foundation; either version 2 of the License, or
  805. # (at your option) any later version.
  806. #
  807. # This program is distributed in the hope that it will be useful,
  808. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  809. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  810. # GNU General Public License for more details.
  811. #
  812. # You should have received a copy of the GNU General Public License
  813. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  814. #
  815.  
  816. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  817. ++++ [[ -n 1 ]]
  818. ++++ return
  819. source "$LIBRARY/util/pkgbuild.sh"
  820. +++ source /usr/share/makepkg/util/pkgbuild.sh
  821. #!/usr/bin/bash
  822. #
  823. # pkgbuild.sh - functions to extract information from PKGBUILD files
  824. #
  825. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  826. #
  827. # This program is free software; you can redistribute it and/or modify
  828. # it under the terms of the GNU General Public License as published by
  829. # the Free Software Foundation; either version 2 of the License, or
  830. # (at your option) any later version.
  831. #
  832. # This program is distributed in the hope that it will be useful,
  833. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  834. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  835. # GNU General Public License for more details.
  836. #
  837. # You should have received a copy of the GNU General Public License
  838. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  839. #
  840.  
  841. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  842. ++++ [[ -n 1 ]]
  843. ++++ return
  844.  
  845. check_checksums() {
  846. local integ a
  847. declare -A correlation
  848. (( SKIPCHECKSUMS )) && return 0
  849.  
  850. # Initialize a map which we'll use to verify that every source array has at
  851. # least some kind of checksum array associated with it.
  852. (( ${#source[*]} )) && correlation['source']=1
  853. case $1 in
  854. all)
  855. for a in "${arch[@]}"; do
  856. array_build _ source_"$a" && correlation["source_$a"]=1
  857. done
  858. ;;
  859. *)
  860. array_build _ source_"$CARCH" && correlation["source_$CARCH"]=1
  861. ;;
  862. esac
  863.  
  864. for integ in "${known_hash_algos[@]}"; do
  865. verify_integrity_sums "$integ" && unset "correlation[source]"
  866.  
  867. case $1 in
  868. all)
  869. for a in "${arch[@]}"; do
  870. verify_integrity_sums "$integ" "$a" && unset "correlation[source_$a]"
  871. done
  872. ;;
  873. *)
  874. verify_integrity_sums "$integ" "$CARCH" && unset "correlation[source_$CARCH]"
  875. ;;
  876. esac
  877. done
  878.  
  879. if (( ${#correlation[*]} )); then
  880. error "$(gettext "Integrity checks are missing for: %s")" "${!correlation[*]}"
  881. exit 1 # TODO: error code
  882. fi
  883. }
  884.  
  885. verify_integrity_one() {
  886. local source_name=$1 integ=$2 expectedsum=$3
  887.  
  888. local file="$(get_filename "$source_name")"
  889. printf ' %s ... ' "$file" >&2
  890.  
  891. if [[ $expectedsum = 'SKIP' ]]; then
  892. printf '%s\n' "$(gettext "Skipped")" >&2
  893. return
  894. fi
  895.  
  896. if ! file="$(get_filepath "$file")"; then
  897. printf '%s\n' "$(gettext "NOT FOUND")" >&2
  898. return 1
  899. fi
  900.  
  901. local realsum="$("${integ}sum" "$file")"
  902. realsum="${realsum%% *}"
  903. if [[ ${expectedsum,,} = "$realsum" ]]; then
  904. printf '%s\n' "$(gettext "Passed")" >&2
  905. else
  906. printf '%s\n' "$(gettext "FAILED")" >&2
  907. return 1
  908. fi
  909.  
  910. return 0
  911. }
  912.  
  913. verify_integrity_sums() {
  914. local integ=$1 arch=$2 integrity_sums=() sources=() srcname
  915.  
  916. if [[ $arch ]]; then
  917. array_build integrity_sums "${integ}sums_$arch"
  918. srcname=source_$arch
  919. else
  920. array_build integrity_sums "${integ}sums"
  921. srcname=source
  922. fi
  923.  
  924. array_build sources "$srcname"
  925. if (( ${#integrity_sums[@]} == 0 && ${#sources[@]} == 0 )); then
  926. return 1
  927. fi
  928.  
  929. if (( ${#integrity_sums[@]} == ${#sources[@]} )); then
  930. msg "$(gettext "Validating %s files with %s...")" "$srcname" "${integ}sums"
  931. local idx errors=0
  932. for (( idx = 0; idx < ${#sources[*]}; idx++ )); do
  933. verify_integrity_one "${sources[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1
  934. done
  935.  
  936. if (( errors )); then
  937. error "$(gettext "One or more files did not pass the validity check!")"
  938. exit 1 # TODO: error code
  939. fi
  940. elif (( ${#integrity_sums[@]} )); then
  941. error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ"
  942. exit 1 # TODO: error code
  943. else
  944. return 1
  945. fi
  946. }
  947. ++ for lib in "$LIBRARY/integrity/"*.sh
  948. ++ source /usr/share/makepkg/integrity/verify_signature.sh
  949. #!/usr/bin/bash
  950. #
  951. # verify_signature.sh - functions for checking PGP signatures
  952. #
  953. # Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
  954. #
  955. # This program is free software; you can redistribute it and/or modify
  956. # it under the terms of the GNU General Public License as published by
  957. # the Free Software Foundation; either version 2 of the License, or
  958. # (at your option) any later version.
  959. #
  960. # This program is distributed in the hope that it will be useful,
  961. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  962. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  963. # GNU General Public License for more details.
  964. #
  965. # You should have received a copy of the GNU General Public License
  966. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  967. #
  968.  
  969. [[ -n "$LIBMAKEPKG_INTEGRITY_VERIFY_SIGNATURE_SH" ]] && return
  970. +++ [[ -n '' ]]
  971. LIBMAKEPKG_INTEGRITY_VERIFY_SIGNATURE_SH=1
  972. +++ LIBMAKEPKG_INTEGRITY_VERIFY_SIGNATURE_SH=1
  973.  
  974. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  975. +++ LIBRARY=/usr/share/makepkg
  976.  
  977. source "$LIBRARY/util/message.sh"
  978. +++ source /usr/share/makepkg/util/message.sh
  979. #!/usr/bin/bash
  980. #
  981. # message.sh - functions for outputting messages in makepkg
  982. #
  983. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  984. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  985. #
  986. # This program is free software; you can redistribute it and/or modify
  987. # it under the terms of the GNU General Public License as published by
  988. # the Free Software Foundation; either version 2 of the License, or
  989. # (at your option) any later version.
  990. #
  991. # This program is distributed in the hope that it will be useful,
  992. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  993. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  994. # GNU General Public License for more details.
  995. #
  996. # You should have received a copy of the GNU General Public License
  997. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  998. #
  999.  
  1000. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  1001. ++++ [[ -n 1 ]]
  1002. ++++ return
  1003. source "$LIBRARY/util/pkgbuild.sh"
  1004. +++ source /usr/share/makepkg/util/pkgbuild.sh
  1005. #!/usr/bin/bash
  1006. #
  1007. # pkgbuild.sh - functions to extract information from PKGBUILD files
  1008. #
  1009. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1010. #
  1011. # This program is free software; you can redistribute it and/or modify
  1012. # it under the terms of the GNU General Public License as published by
  1013. # the Free Software Foundation; either version 2 of the License, or
  1014. # (at your option) any later version.
  1015. #
  1016. # This program is distributed in the hope that it will be useful,
  1017. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1018. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1019. # GNU General Public License for more details.
  1020. #
  1021. # You should have received a copy of the GNU General Public License
  1022. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1023. #
  1024.  
  1025. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  1026. ++++ [[ -n 1 ]]
  1027. ++++ return
  1028.  
  1029. check_pgpsigs() {
  1030. (( SKIPPGPCHECK )) && return 0
  1031. ! source_has_signatures && return 0
  1032.  
  1033. msg "$(gettext "Verifying source file signatures with %s...")" "gpg"
  1034.  
  1035. local netfile proto pubkey success status fingerprint trusted
  1036. local warnings=0
  1037. local errors=0
  1038. local statusfile=$(mktemp)
  1039. local all_sources
  1040.  
  1041. case $1 in
  1042. all)
  1043. get_all_sources 'all_sources'
  1044. ;;
  1045. *)
  1046. get_all_sources_for_arch 'all_sources'
  1047. ;;
  1048. esac
  1049. for netfile in "${all_sources[@]}"; do
  1050. proto="$(get_protocol "$netfile")"
  1051.  
  1052. if [[ $proto = git* ]]; then
  1053. verify_git_signature "$netfile" "$statusfile" || continue
  1054. else
  1055. verify_file_signature "$netfile" "$statusfile" || continue
  1056. fi
  1057.  
  1058. # these variables are assigned values in parse_gpg_statusfile
  1059. success=0
  1060. status=
  1061. pubkey=
  1062. fingerprint=
  1063. trusted=
  1064. parse_gpg_statusfile "$statusfile"
  1065. if (( ! $success )); then
  1066. printf '%s' "$(gettext "FAILED")" >&2
  1067. case "$status" in
  1068. "missingkey")
  1069. printf ' (%s)' "$(gettext "unknown public key") $pubkey" >&2
  1070. ;;
  1071. "revokedkey")
  1072. printf " ($(gettext "public key %s has been revoked"))" "$pubkey" >&2
  1073. ;;
  1074. "bad")
  1075. printf ' (%s)' "$(gettext "bad signature from public key") $pubkey" >&2
  1076. ;;
  1077. "error")
  1078. printf ' (%s)' "$(gettext "error during signature verification")" >&2
  1079. ;;
  1080. esac
  1081. errors=1
  1082. else
  1083. if (( ${#validpgpkeys[@]} == 0 && !trusted )); then
  1084. printf "%s ($(gettext "the public key %s is not trusted"))" $(gettext "FAILED") "$fingerprint" >&2
  1085. errors=1
  1086. elif (( ${#validpgpkeys[@]} > 0 )) && ! in_array "$fingerprint" "${validpgpkeys[@]}"; then
  1087. printf "%s (%s %s)" "$(gettext "FAILED")" "$(gettext "invalid public key")" "$fingerprint" >&2
  1088. errors=1
  1089. else
  1090. printf '%s' "$(gettext "Passed")" >&2
  1091. case "$status" in
  1092. "expired")
  1093. printf ' (%s)' "$(gettext "WARNING:") $(gettext "the signature has expired.")" >&2
  1094. warnings=1
  1095. ;;
  1096. "expiredkey")
  1097. printf ' (%s)' "$(gettext "WARNING:") $(gettext "the key has expired.")" >&2
  1098. warnings=1
  1099. ;;
  1100. esac
  1101. fi
  1102. fi
  1103. printf '\n' >&2
  1104. done
  1105.  
  1106. rm -f "$statusfile"
  1107.  
  1108. if (( errors )); then
  1109. error "$(gettext "One or more PGP signatures could not be verified!")"
  1110. exit 1
  1111. fi
  1112.  
  1113. if (( warnings )); then
  1114. warning "$(gettext "Warnings have occurred while verifying the signatures.")"
  1115. plain "$(gettext "Please make sure you really trust them.")"
  1116. fi
  1117. }
  1118.  
  1119. verify_file_signature() {
  1120. local netfile="$1" statusfile="$2"
  1121. local file ext decompress found sourcefile
  1122.  
  1123. file="$(get_filename "$netfile")"
  1124. if [[ $file != *.@(sig?(n)|asc) ]]; then
  1125. return 1
  1126. fi
  1127.  
  1128. printf " %s ... " "${file%.*}" >&2
  1129.  
  1130. if ! file="$(get_filepath "$netfile")"; then
  1131. printf '%s\n' "$(gettext "SIGNATURE NOT FOUND")" >&2
  1132. errors=1
  1133. return 1
  1134. fi
  1135.  
  1136. found=0
  1137. for ext in "" gz bz2 xz lrz lzo Z; do
  1138. if sourcefile="$(get_filepath "${file%.*}${ext:+.$ext}")"; then
  1139. found=1
  1140. break;
  1141. fi
  1142. done
  1143. if (( ! found )); then
  1144. printf '%s\n' "$(gettext "SOURCE FILE NOT FOUND")" >&2
  1145. errors=1
  1146. return 1
  1147. fi
  1148.  
  1149. case "$ext" in
  1150. gz) decompress="gzip -c -d -f" ;;
  1151. bz2) decompress="bzip2 -c -d -f" ;;
  1152. xz) decompress="xz -c -d" ;;
  1153. lrz) decompress="lrzip -q -d" ;;
  1154. lzo) decompress="lzop -c -d -q" ;;
  1155. Z) decompress="uncompress -c -f" ;;
  1156. "") decompress="cat" ;;
  1157. esac
  1158.  
  1159. $decompress < "$sourcefile" | gpg --quiet --batch --status-file "$statusfile" --verify "$file" - 2> /dev/null
  1160. return 0
  1161. }
  1162.  
  1163. verify_git_signature() {
  1164. local netfile=$1 statusfile=$2
  1165. local dir fragment query fragtype fragval
  1166.  
  1167. dir=$(get_filepath "$netfile")
  1168. fragment=$(get_uri_fragment "$netfile")
  1169. query=$(get_uri_query "$netfile")
  1170.  
  1171. if [[ $query != signed ]]; then
  1172. return 1
  1173. fi
  1174.  
  1175. case ${fragment%%=*} in
  1176. tag)
  1177. fragtype=tag
  1178. fragval=${fragment##*=}
  1179. ;;
  1180. commit|branch)
  1181. fragtype=commit
  1182. fragval=${fragment##*=}
  1183. ;;
  1184. '')
  1185. fragtype=commit
  1186. fragval=HEAD
  1187. esac
  1188.  
  1189. printf " %s git repo ... " "${dir##*/}" >&2
  1190.  
  1191. git -C "$dir" verify-$fragtype --raw "$fragval" > "$statusfile" 2>&1
  1192. if ! grep -qs NEWSIG "$statusfile"; then
  1193. printf '%s\n' "$(gettext "SIGNATURE NOT FOUND")" >&2
  1194. errors=1
  1195. return 1
  1196. fi
  1197. return 0
  1198. }
  1199.  
  1200. parse_gpg_statusfile() {
  1201. local type arg1 arg6 arg10
  1202.  
  1203. while read -r _ type arg1 _ _ _ _ arg6 _ _ _ arg10 _; do
  1204. case "$type" in
  1205. GOODSIG)
  1206. pubkey=$arg1
  1207. success=1
  1208. status="good"
  1209. ;;
  1210. EXPSIG)
  1211. pubkey=$arg1
  1212. success=1
  1213. status="expired"
  1214. ;;
  1215. EXPKEYSIG)
  1216. pubkey=$arg1
  1217. success=1
  1218. status="expiredkey"
  1219. ;;
  1220. REVKEYSIG)
  1221. pubkey=$arg1
  1222. success=0
  1223. status="revokedkey"
  1224. ;;
  1225. BADSIG)
  1226. pubkey=$arg1
  1227. success=0
  1228. status="bad"
  1229. ;;
  1230. ERRSIG)
  1231. pubkey=$arg1
  1232. success=0
  1233. if [[ $arg6 == 9 ]]; then
  1234. status="missingkey"
  1235. else
  1236. status="error"
  1237. fi
  1238. ;;
  1239. VALIDSIG)
  1240. if [[ $arg10 ]]; then
  1241. # If the file was signed with a subkey, arg10 contains
  1242. # the fingerprint of the primary key
  1243. fingerprint=$arg10
  1244. else
  1245. fingerprint=$arg1
  1246. fi
  1247. ;;
  1248. TRUST_UNDEFINED|TRUST_NEVER)
  1249. trusted=0
  1250. ;;
  1251. TRUST_MARGINAL|TRUST_FULLY|TRUST_ULTIMATE)
  1252. trusted=1
  1253. ;;
  1254. esac
  1255. done < "$1"
  1256. }
  1257.  
  1258. source_has_signatures() {
  1259. local netfile all_sources proto
  1260.  
  1261. get_all_sources_for_arch 'all_sources'
  1262. for netfile in "${all_sources[@]}"; do
  1263. proto="$(get_protocol "$netfile")"
  1264. query=$(get_uri_query "$netfile")
  1265.  
  1266. if [[ ${netfile%%::*} = *.@(sig?(n)|asc) || ( $proto = git* && $query = signed ) ]]; then
  1267. return 0
  1268. fi
  1269. done
  1270. return 1
  1271. }
  1272.  
  1273. check_source_integrity() {
  1274. if (( SKIPCHECKSUMS && SKIPPGPCHECK )); then
  1275. warning "$(gettext "Skipping all source file integrity checks.")"
  1276. elif (( SKIPCHECKSUMS )); then
  1277. warning "$(gettext "Skipping verification of source file checksums.")"
  1278. check_pgpsigs "$@"
  1279. elif (( SKIPPGPCHECK )); then
  1280. warning "$(gettext "Skipping verification of source file PGP signatures.")"
  1281. check_checksums "$@"
  1282. else
  1283. check_checksums "$@"
  1284. check_pgpsigs "$@"
  1285. fi
  1286. }
  1287. + for lib in "$LIBRARY"/*.sh
  1288. + source /usr/share/makepkg/lint_config.sh
  1289. #!/usr/bin/bash
  1290. #
  1291. # lint_config.sh - functions for checking for makepkg.conf errors
  1292. #
  1293. # Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
  1294. #
  1295. # This program is free software; you can redistribute it and/or modify
  1296. # it under the terms of the GNU General Public License as published by
  1297. # the Free Software Foundation; either version 2 of the License, or
  1298. # (at your option) any later version.
  1299. #
  1300. # This program is distributed in the hope that it will be useful,
  1301. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1302. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1303. # GNU General Public License for more details.
  1304. #
  1305. # You should have received a copy of the GNU General Public License
  1306. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1307. #
  1308.  
  1309. [[ -n "$LIBMAKEPKG_LINT_CONFIG_SH" ]] && return
  1310. ++ [[ -n '' ]]
  1311. LIBMAKEPKG_LINT_CONFIG_SH=1
  1312. ++ LIBMAKEPKG_LINT_CONFIG_SH=1
  1313.  
  1314. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  1315. ++ LIBRARY=/usr/share/makepkg
  1316.  
  1317. source "$LIBRARY/util/message.sh"
  1318. ++ source /usr/share/makepkg/util/message.sh
  1319. #!/usr/bin/bash
  1320. #
  1321. # message.sh - functions for outputting messages in makepkg
  1322. #
  1323. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1324. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  1325. #
  1326. # This program is free software; you can redistribute it and/or modify
  1327. # it under the terms of the GNU General Public License as published by
  1328. # the Free Software Foundation; either version 2 of the License, or
  1329. # (at your option) any later version.
  1330. #
  1331. # This program is distributed in the hope that it will be useful,
  1332. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1333. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1334. # GNU General Public License for more details.
  1335. #
  1336. # You should have received a copy of the GNU General Public License
  1337. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1338. #
  1339.  
  1340. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  1341. +++ [[ -n 1 ]]
  1342. +++ return
  1343. source "$LIBRARY/util/util.sh"
  1344. ++ source /usr/share/makepkg/util/util.sh
  1345. #!/usr/bin/bash
  1346. #
  1347. # util.sh - general utility functions
  1348. #
  1349. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1350. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  1351. #
  1352. # This program is free software; you can redistribute it and/or modify
  1353. # it under the terms of the GNU General Public License as published by
  1354. # the Free Software Foundation; either version 2 of the License, or
  1355. # (at your option) any later version.
  1356. #
  1357. # This program is distributed in the hope that it will be useful,
  1358. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1359. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1360. # GNU General Public License for more details.
  1361. #
  1362. # You should have received a copy of the GNU General Public License
  1363. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1364. #
  1365.  
  1366. [[ -n "$LIBMAKEPKG_UTIL_UTIL_SH" ]] && return
  1367. +++ [[ -n '' ]]
  1368. LIBMAKEPKG_UTIL_UTIL_SH=1
  1369. +++ LIBMAKEPKG_UTIL_UTIL_SH=1
  1370.  
  1371.  
  1372. ##
  1373. # usage : in_array( $needle, $haystack )
  1374. # return : 0 - found
  1375. # 1 - not found
  1376. ##
  1377. in_array() {
  1378. local needle=$1; shift
  1379. local item
  1380. for item in "$@"; do
  1381. [[ $item = "$needle" ]] && return 0 # Found
  1382. done
  1383. return 1 # Not Found
  1384. }
  1385.  
  1386. # tests if a variable is an array
  1387. is_array() {
  1388. local v=$1
  1389. local ret=1
  1390.  
  1391. if [[ $(declare -p "$v") == declare\ -*([[:alnum:]])a*([[:alnum:]])\ * ]]; then
  1392. ret=0
  1393. fi
  1394.  
  1395. return $ret
  1396. }
  1397.  
  1398. # Canonicalize a directory path if it exists
  1399. canonicalize_path() {
  1400. local path="$1";
  1401.  
  1402. if [[ -d $path ]]; then
  1403. (
  1404. cd_safe "$path"
  1405. pwd -P
  1406. )
  1407. else
  1408. printf "%s\n" "$path"
  1409. fi
  1410. }
  1411.  
  1412. dir_is_empty() {
  1413. (
  1414. shopt -s dotglob nullglob
  1415. files=("$1"/*)
  1416. (( ${#files} == 0 ))
  1417. )
  1418. }
  1419.  
  1420. cd_safe() {
  1421. if ! cd "$1"; then
  1422. error "$(gettext "Failed to change to directory %s")" "$1"
  1423. plain "$(gettext "Aborting...")"
  1424. exit 1
  1425. fi
  1426. }
  1427.  
  1428. # Try to create directory if one does not yet exist. Fails if the directory
  1429. # exists but has no write permissions, or if there is an existing file with
  1430. # the same name.
  1431. ensure_writable_dir() {
  1432. local dirtype="$1" dirpath="$2"
  1433.  
  1434. if ! mkdir -p "$dirpath" 2>/dev/null; then
  1435. error "$(gettext "Failed to create the directory \$%s (%s).")" "$dirtype" "$dirpath"
  1436. return 1
  1437. elif [[ ! -w $dirpath ]]; then
  1438. error "$(gettext "You do not have write permission for the directory \$%s (%s).")" "$dirtype" "$dirpath"
  1439. return 1
  1440. fi
  1441.  
  1442. return 0
  1443. }
  1444.  
  1445.  
  1446. declare -a lint_config_functions
  1447. ++ declare -a lint_config_functions
  1448.  
  1449. for lib in "$LIBRARY/lint_config/"*.sh; do
  1450. source "$lib"
  1451. done
  1452. ++ for lib in "$LIBRARY/lint_config/"*.sh
  1453. ++ source /usr/share/makepkg/lint_config/paths.sh
  1454. #!/usr/bin/bash
  1455. #
  1456. # paths.sh - Check that pathname components do not contain odd characters
  1457. #
  1458. # Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
  1459. #
  1460. # This program is free software; you can redistribute it and/or modify
  1461. # it under the terms of the GNU General Public License as published by
  1462. # the Free Software Foundation; either version 2 of the License, or
  1463. # (at your option) any later version.
  1464. #
  1465. # This program is distributed in the hope that it will be useful,
  1466. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1467. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1468. # GNU General Public License for more details.
  1469. #
  1470. # You should have received a copy of the GNU General Public License
  1471. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1472. #
  1473.  
  1474. [[ -n "$LIBMAKEPKG_LINT_CONFIG_PATHS_SH" ]] && return
  1475. +++ [[ -n '' ]]
  1476. LIBMAKEPKG_LINT_CONFIG_PATHS_SH=1
  1477. +++ LIBMAKEPKG_LINT_CONFIG_PATHS_SH=1
  1478.  
  1479. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  1480. +++ LIBRARY=/usr/share/makepkg
  1481.  
  1482. source "$LIBRARY/util/message.sh"
  1483. +++ source /usr/share/makepkg/util/message.sh
  1484. #!/usr/bin/bash
  1485. #
  1486. # message.sh - functions for outputting messages in makepkg
  1487. #
  1488. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1489. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  1490. #
  1491. # This program is free software; you can redistribute it and/or modify
  1492. # it under the terms of the GNU General Public License as published by
  1493. # the Free Software Foundation; either version 2 of the License, or
  1494. # (at your option) any later version.
  1495. #
  1496. # This program is distributed in the hope that it will be useful,
  1497. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1498. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1499. # GNU General Public License for more details.
  1500. #
  1501. # You should have received a copy of the GNU General Public License
  1502. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1503. #
  1504.  
  1505. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  1506. ++++ [[ -n 1 ]]
  1507. ++++ return
  1508. source "$LIBRARY/util/pkgbuild.sh"
  1509. +++ source /usr/share/makepkg/util/pkgbuild.sh
  1510. #!/usr/bin/bash
  1511. #
  1512. # pkgbuild.sh - functions to extract information from PKGBUILD files
  1513. #
  1514. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1515. #
  1516. # This program is free software; you can redistribute it and/or modify
  1517. # it under the terms of the GNU General Public License as published by
  1518. # the Free Software Foundation; either version 2 of the License, or
  1519. # (at your option) any later version.
  1520. #
  1521. # This program is distributed in the hope that it will be useful,
  1522. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1523. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1524. # GNU General Public License for more details.
  1525. #
  1526. # You should have received a copy of the GNU General Public License
  1527. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1528. #
  1529.  
  1530. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  1531. ++++ [[ -n 1 ]]
  1532. ++++ return
  1533.  
  1534. lint_config_functions+=('lint_paths')
  1535. +++ lint_config_functions+=('lint_paths')
  1536.  
  1537.  
  1538. lint_paths() {
  1539. local pathvars=(BUILDDIR PKGDEST SRCDEST SRCPKGDEST LOGDEST PKGEXT SRCEXT)
  1540.  
  1541. local i ret=0
  1542.  
  1543. for i in ${pathvars[@]}; do
  1544. if [[ ${!i} = *$'\n'* ]]; then
  1545. error "$(gettext "%s contains invalid characters: '%s'")" \
  1546. "$i" "${!i//[^$'\n']}"
  1547. ret=1
  1548. fi
  1549. done
  1550.  
  1551. return $ret
  1552. }
  1553. ++ for lib in "$LIBRARY/lint_config/"*.sh
  1554. ++ source /usr/share/makepkg/lint_config/variable.sh
  1555. #!/usr/bin/bash
  1556. #
  1557. # variable.sh - Check that variables are or are not arrays as appropriate
  1558. #
  1559. # Copyright (c) 2018 Pacman Development Team <pacman-dev@archlinux.org>
  1560. #
  1561. # This program is free software; you can redistribute it and/or modify
  1562. # it under the terms of the GNU General Public License as published by
  1563. # the Free Software Foundation; either version 2 of the License, or
  1564. # (at your option) any later version.
  1565. #
  1566. # This program is distributed in the hope that it will be useful,
  1567. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1568. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1569. # GNU General Public License for more details.
  1570. #
  1571. # You should have received a copy of the GNU General Public License
  1572. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1573. #
  1574.  
  1575. [[ -n "$LIBMAKEPKG_LINT_CONFIG_VARIABLE_SH" ]] && return
  1576. +++ [[ -n '' ]]
  1577. LIBMAKEPKG_LINT_CONFIG_VARIABLE_SH=1
  1578. +++ LIBMAKEPKG_LINT_CONFIG_VARIABLE_SH=1
  1579.  
  1580. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  1581. +++ LIBRARY=/usr/share/makepkg
  1582.  
  1583. source "$LIBRARY/util/message.sh"
  1584. +++ source /usr/share/makepkg/util/message.sh
  1585. #!/usr/bin/bash
  1586. #
  1587. # message.sh - functions for outputting messages in makepkg
  1588. #
  1589. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1590. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  1591. #
  1592. # This program is free software; you can redistribute it and/or modify
  1593. # it under the terms of the GNU General Public License as published by
  1594. # the Free Software Foundation; either version 2 of the License, or
  1595. # (at your option) any later version.
  1596. #
  1597. # This program is distributed in the hope that it will be useful,
  1598. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1599. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1600. # GNU General Public License for more details.
  1601. #
  1602. # You should have received a copy of the GNU General Public License
  1603. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1604. #
  1605.  
  1606. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  1607. ++++ [[ -n 1 ]]
  1608. ++++ return
  1609.  
  1610. lint_config_functions+=('lint_variable')
  1611. +++ lint_config_functions+=('lint_variable')
  1612.  
  1613.  
  1614. lint_variable() {
  1615. local array=(DLAGENTS VCSCLIENTS BUILDENV OPTIONS INTEGRITY_CHECK MAN_DIRS
  1616. DOC_DIRS PURGE_TARGETS COMPRESSGZ COMPRESSBZ2 COMPRESSXZ
  1617. COMPRESSLRZ COMPRESSLZO COMPRESSZ)
  1618. local string=(CARCH CHOST CPPFLAGS CFLAGS CXXFLAGS LDFLAGS DEBUG_CFLAGS
  1619. DEBUG_CXXFLAGS DISTCC_HOSTS BUILDDIR STRIP_BINARIES STRIP_SHARED
  1620. STRIP_STATIC PKGDEST SRCDEST SRCPKGDEST LOGDEST PACKAGER GPGKEY
  1621. PKGEXT SRCEXT)
  1622.  
  1623. local i keys ret=0
  1624.  
  1625. # global variables
  1626. for i in ${array[@]}; do
  1627. eval "keys=(\"\${!$i[@]}\")"
  1628. if (( ${#keys[*]} > 0 )); then
  1629. if ! is_array $i; then
  1630. error "$(gettext "%s should be an array")" "$i"
  1631. ret=1
  1632. fi
  1633. fi
  1634. done
  1635.  
  1636. for i in ${string[@]}; do
  1637. eval "keys=(\"\${!$i[@]}\")"
  1638. if (( ${#keys[*]} > 0 )); then
  1639. if is_array $i; then
  1640. error "$(gettext "%s should not be an array")" "$i"
  1641. ret=1
  1642. fi
  1643. fi
  1644. done
  1645.  
  1646. return $ret
  1647. }
  1648.  
  1649. readonly -a lint_config_functions
  1650. ++ readonly -a lint_config_functions
  1651.  
  1652.  
  1653. lint_config() {
  1654. local ret=0
  1655.  
  1656. for func in ${lint_config_functions[@]}; do
  1657. $func || ret=1
  1658. done
  1659. return $ret
  1660. }
  1661. + for lib in "$LIBRARY"/*.sh
  1662. + source /usr/share/makepkg/lint_package.sh
  1663. #!/usr/bin/bash
  1664. #
  1665. # lint_package.sh - functions for checking for packaging errors
  1666. #
  1667. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1668. #
  1669. # This program is free software; you can redistribute it and/or modify
  1670. # it under the terms of the GNU General Public License as published by
  1671. # the Free Software Foundation; either version 2 of the License, or
  1672. # (at your option) any later version.
  1673. #
  1674. # This program is distributed in the hope that it will be useful,
  1675. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1676. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1677. # GNU General Public License for more details.
  1678. #
  1679. # You should have received a copy of the GNU General Public License
  1680. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1681. #
  1682.  
  1683. [[ -n "$LIBMAKEPKG_LINT_PACKAGE_SH" ]] && return
  1684. ++ [[ -n '' ]]
  1685. LIBMAKEPKG_LINT_PACKAGE_SH=1
  1686. ++ LIBMAKEPKG_LINT_PACKAGE_SH=1
  1687.  
  1688. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  1689. ++ LIBRARY=/usr/share/makepkg
  1690.  
  1691. source "$LIBRARY/util/message.sh"
  1692. ++ source /usr/share/makepkg/util/message.sh
  1693. #!/usr/bin/bash
  1694. #
  1695. # message.sh - functions for outputting messages in makepkg
  1696. #
  1697. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1698. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  1699. #
  1700. # This program is free software; you can redistribute it and/or modify
  1701. # it under the terms of the GNU General Public License as published by
  1702. # the Free Software Foundation; either version 2 of the License, or
  1703. # (at your option) any later version.
  1704. #
  1705. # This program is distributed in the hope that it will be useful,
  1706. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1707. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1708. # GNU General Public License for more details.
  1709. #
  1710. # You should have received a copy of the GNU General Public License
  1711. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1712. #
  1713.  
  1714. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  1715. +++ [[ -n 1 ]]
  1716. +++ return
  1717. source "$LIBRARY/util/util.sh"
  1718. ++ source /usr/share/makepkg/util/util.sh
  1719. #!/usr/bin/bash
  1720. #
  1721. # util.sh - general utility functions
  1722. #
  1723. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1724. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  1725. #
  1726. # This program is free software; you can redistribute it and/or modify
  1727. # it under the terms of the GNU General Public License as published by
  1728. # the Free Software Foundation; either version 2 of the License, or
  1729. # (at your option) any later version.
  1730. #
  1731. # This program is distributed in the hope that it will be useful,
  1732. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1733. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1734. # GNU General Public License for more details.
  1735. #
  1736. # You should have received a copy of the GNU General Public License
  1737. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1738. #
  1739.  
  1740. [[ -n "$LIBMAKEPKG_UTIL_UTIL_SH" ]] && return
  1741. +++ [[ -n 1 ]]
  1742. +++ return
  1743.  
  1744.  
  1745. declare -a lint_package_functions
  1746. ++ declare -a lint_package_functions
  1747.  
  1748. for lib in "$LIBRARY/lint_package/"*.sh; do
  1749. source "$lib"
  1750. done
  1751. ++ for lib in "$LIBRARY/lint_package/"*.sh
  1752. ++ source /usr/share/makepkg/lint_package/build_references.sh
  1753. #!/usr/bin/bash
  1754. #
  1755. # build_references.sh - Warn about files containing references to build directories
  1756. #
  1757. # Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1758. #
  1759. # This program is free software; you can redistribute it and/or modify
  1760. # it under the terms of the GNU General Public License as published by
  1761. # the Free Software Foundation; either version 2 of the License, or
  1762. # (at your option) any later version.
  1763. #
  1764. # This program is distributed in the hope that it will be useful,
  1765. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1766. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1767. # GNU General Public License for more details.
  1768. #
  1769. # You should have received a copy of the GNU General Public License
  1770. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1771. #
  1772.  
  1773. [[ -n "$LIBMAKEPKG_LINT_PACKAGE_BUILD_REFERENCES_SH" ]] && return
  1774. +++ [[ -n '' ]]
  1775. LIBMAKEPKG_LINT_PACKAGE_BUILD_REFERENCES_SH=1
  1776. +++ LIBMAKEPKG_LINT_PACKAGE_BUILD_REFERENCES_SH=1
  1777.  
  1778. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  1779. +++ LIBRARY=/usr/share/makepkg
  1780.  
  1781. source "$LIBRARY/util/message.sh"
  1782. +++ source /usr/share/makepkg/util/message.sh
  1783. #!/usr/bin/bash
  1784. #
  1785. # message.sh - functions for outputting messages in makepkg
  1786. #
  1787. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1788. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  1789. #
  1790. # This program is free software; you can redistribute it and/or modify
  1791. # it under the terms of the GNU General Public License as published by
  1792. # the Free Software Foundation; either version 2 of the License, or
  1793. # (at your option) any later version.
  1794. #
  1795. # This program is distributed in the hope that it will be useful,
  1796. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1797. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1798. # GNU General Public License for more details.
  1799. #
  1800. # You should have received a copy of the GNU General Public License
  1801. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1802. #
  1803.  
  1804. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  1805. ++++ [[ -n 1 ]]
  1806. ++++ return
  1807.  
  1808. lint_package_functions+=('warn_build_references')
  1809. +++ lint_package_functions+=('warn_build_references')
  1810.  
  1811. warn_build_references() {
  1812. local refs
  1813.  
  1814. for var in srcdir pkgdir; do
  1815. mapfile -t refs < <(find "$pkgdir" -type f -exec grep -l "${!var}" {} +)
  1816. if (( ${#refs} > 0 )); then
  1817. warning "$(gettext 'Package contains reference to %s')" "\$$var"
  1818. printf '%s\n' "${refs[@]#"$pkgdir/"}" >&2
  1819. fi
  1820. done
  1821. return 0
  1822. }
  1823. ++ for lib in "$LIBRARY/lint_package/"*.sh
  1824. ++ source /usr/share/makepkg/lint_package/dotfiles.sh
  1825. #!/usr/bin/bash
  1826. #
  1827. # dotfiles.sh - check for dotfiles in the package root
  1828. #
  1829. # Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1830. #
  1831. # This program is free software; you can redistribute it and/or modify
  1832. # it under the terms of the GNU General Public License as published by
  1833. # the Free Software Foundation; either version 2 of the License, or
  1834. # (at your option) any later version.
  1835. #
  1836. # This program is distributed in the hope that it will be useful,
  1837. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1838. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1839. # GNU General Public License for more details.
  1840. #
  1841. # You should have received a copy of the GNU General Public License
  1842. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1843. #
  1844.  
  1845. [[ -n "$LIBMAKEPKG_LINT_PACKAGE_DOTFILES_SH" ]] && return
  1846. +++ [[ -n '' ]]
  1847. LIBMAKEPKG_LINT_PACKAGE_DOTFILES_SH=1
  1848. +++ LIBMAKEPKG_LINT_PACKAGE_DOTFILES_SH=1
  1849.  
  1850. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  1851. +++ LIBRARY=/usr/share/makepkg
  1852.  
  1853. source "$LIBRARY/util/message.sh"
  1854. +++ source /usr/share/makepkg/util/message.sh
  1855. #!/usr/bin/bash
  1856. #
  1857. # message.sh - functions for outputting messages in makepkg
  1858. #
  1859. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1860. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  1861. #
  1862. # This program is free software; you can redistribute it and/or modify
  1863. # it under the terms of the GNU General Public License as published by
  1864. # the Free Software Foundation; either version 2 of the License, or
  1865. # (at your option) any later version.
  1866. #
  1867. # This program is distributed in the hope that it will be useful,
  1868. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1869. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1870. # GNU General Public License for more details.
  1871. #
  1872. # You should have received a copy of the GNU General Public License
  1873. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1874. #
  1875.  
  1876. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  1877. ++++ [[ -n 1 ]]
  1878. ++++ return
  1879.  
  1880. lint_package_functions+=('check_dotfiles')
  1881. +++ lint_package_functions+=('check_dotfiles')
  1882.  
  1883. check_dotfiles() {
  1884. local ret=0
  1885. for f in "$pkgdir"/.*; do
  1886. [[ ${f##*/} == . || ${f##*/} == .. ]] && continue
  1887. error "$(gettext "Dotfile found in package root '%s'")" "$f"
  1888. ret=1
  1889. done
  1890. return $ret
  1891. }
  1892. ++ for lib in "$LIBRARY/lint_package/"*.sh
  1893. ++ source /usr/share/makepkg/lint_package/file_names.sh
  1894. #!/usr/bin/bash
  1895. #
  1896. # file_names.sh - check package file names
  1897. #
  1898. # Copyright (c) 2016-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1899. #
  1900. # This program is free software; you can redistribute it and/or modify
  1901. # it under the terms of the GNU General Public License as published by
  1902. # the Free Software Foundation; either version 2 of the License, or
  1903. # (at your option) any later version.
  1904. #
  1905. # This program is distributed in the hope that it will be useful,
  1906. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1907. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1908. # GNU General Public License for more details.
  1909. #
  1910. # You should have received a copy of the GNU General Public License
  1911. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1912. #
  1913.  
  1914. [[ -n "$LIBMAKEPKG_LINT_PACKAGE_FILE_NAMES_SH" ]] && return
  1915. +++ [[ -n '' ]]
  1916. LIBMAKEPKG_LINT_PACKAGE_FILE_NAMES_SH=1
  1917. +++ LIBMAKEPKG_LINT_PACKAGE_FILE_NAMES_SH=1
  1918.  
  1919. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  1920. +++ LIBRARY=/usr/share/makepkg
  1921.  
  1922. source "$LIBRARY/util/message.sh"
  1923. +++ source /usr/share/makepkg/util/message.sh
  1924. #!/usr/bin/bash
  1925. #
  1926. # message.sh - functions for outputting messages in makepkg
  1927. #
  1928. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1929. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  1930. #
  1931. # This program is free software; you can redistribute it and/or modify
  1932. # it under the terms of the GNU General Public License as published by
  1933. # the Free Software Foundation; either version 2 of the License, or
  1934. # (at your option) any later version.
  1935. #
  1936. # This program is distributed in the hope that it will be useful,
  1937. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1938. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1939. # GNU General Public License for more details.
  1940. #
  1941. # You should have received a copy of the GNU General Public License
  1942. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1943. #
  1944.  
  1945. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  1946. ++++ [[ -n 1 ]]
  1947. ++++ return
  1948.  
  1949. lint_package_functions+=('lint_file_names')
  1950. +++ lint_package_functions+=('lint_file_names')
  1951.  
  1952. lint_file_names() {
  1953. local ret=0 paths
  1954.  
  1955. # alpm's local database format does not support newlines in paths
  1956. mapfile -t paths < <(find "$pkgdir" -name \*$'\n'\*)
  1957. if (( ${#paths} > 0 )); then
  1958. error "$(gettext 'Package contains paths with newlines')"
  1959. printf '%s\n' "${paths[@]}" >&2
  1960. ret=1
  1961. fi
  1962.  
  1963. return $ret
  1964. }
  1965. ++ for lib in "$LIBRARY/lint_package/"*.sh
  1966. ++ source /usr/share/makepkg/lint_package/missing_backup.sh
  1967. #!/usr/bin/bash
  1968. #
  1969. # missing_backup.sh - Warn about missing files in the backup array
  1970. #
  1971. # Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
  1972. #
  1973. # This program is free software; you can redistribute it and/or modify
  1974. # it under the terms of the GNU General Public License as published by
  1975. # the Free Software Foundation; either version 2 of the License, or
  1976. # (at your option) any later version.
  1977. #
  1978. # This program is distributed in the hope that it will be useful,
  1979. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1980. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1981. # GNU General Public License for more details.
  1982. #
  1983. # You should have received a copy of the GNU General Public License
  1984. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1985. #
  1986.  
  1987. [[ -n "$LIBMAKEPKG_LINT_PACKAGE_MISSING_BACKUP_SH" ]] && return
  1988. +++ [[ -n '' ]]
  1989. LIBMAKEPKG_LINT_PACKAGE_MISSING_BACKUP_SH=1
  1990. +++ LIBMAKEPKG_LINT_PACKAGE_MISSING_BACKUP_SH=1
  1991.  
  1992. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  1993. +++ LIBRARY=/usr/share/makepkg
  1994.  
  1995. source "$LIBRARY/util/message.sh"
  1996. +++ source /usr/share/makepkg/util/message.sh
  1997. #!/usr/bin/bash
  1998. #
  1999. # message.sh - functions for outputting messages in makepkg
  2000. #
  2001. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2002. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2003. #
  2004. # This program is free software; you can redistribute it and/or modify
  2005. # it under the terms of the GNU General Public License as published by
  2006. # the Free Software Foundation; either version 2 of the License, or
  2007. # (at your option) any later version.
  2008. #
  2009. # This program is distributed in the hope that it will be useful,
  2010. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2011. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2012. # GNU General Public License for more details.
  2013. #
  2014. # You should have received a copy of the GNU General Public License
  2015. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2016. #
  2017.  
  2018. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2019. ++++ [[ -n 1 ]]
  2020. ++++ return
  2021.  
  2022.  
  2023. lint_package_functions+=('warn_missing_backup')
  2024. +++ lint_package_functions+=('warn_missing_backup')
  2025.  
  2026. warn_missing_backup() {
  2027. local file
  2028. for file in "${backup[@]}"; do
  2029. if [[ ! -f $file ]]; then
  2030. warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
  2031. fi
  2032. done
  2033. return 0
  2034. }
  2035.  
  2036. readonly -a lint_package_functions
  2037. ++ readonly -a lint_package_functions
  2038.  
  2039.  
  2040. lint_package() {
  2041. cd_safe "$pkgdir"
  2042. msg "$(gettext "Checking for packaging issues...")"
  2043.  
  2044. local ret=0
  2045. for func in ${lint_package_functions[@]}; do
  2046. $func || ret=1
  2047. done
  2048. return $ret
  2049. }
  2050. + for lib in "$LIBRARY"/*.sh
  2051. + source /usr/share/makepkg/lint_pkgbuild.sh
  2052. #!/usr/bin/bash
  2053. #
  2054. # lint_pkgbuild.sh - functions for detecting PKGBUILD errors
  2055. #
  2056. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2057. #
  2058. # This program is free software; you can redistribute it and/or modify
  2059. # it under the terms of the GNU General Public License as published by
  2060. # the Free Software Foundation; either version 2 of the License, or
  2061. # (at your option) any later version.
  2062. #
  2063. # This program is distributed in the hope that it will be useful,
  2064. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2065. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2066. # GNU General Public License for more details.
  2067. #
  2068. # You should have received a copy of the GNU General Public License
  2069. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2070. #
  2071.  
  2072. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_SH" ]] && return
  2073. ++ [[ -n '' ]]
  2074. LIBMAKEPKG_LINT_PKGBUILD_SH=1
  2075. ++ LIBMAKEPKG_LINT_PKGBUILD_SH=1
  2076.  
  2077. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2078. ++ LIBRARY=/usr/share/makepkg
  2079.  
  2080. source "$LIBRARY/util/message.sh"
  2081. ++ source /usr/share/makepkg/util/message.sh
  2082. #!/usr/bin/bash
  2083. #
  2084. # message.sh - functions for outputting messages in makepkg
  2085. #
  2086. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2087. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2088. #
  2089. # This program is free software; you can redistribute it and/or modify
  2090. # it under the terms of the GNU General Public License as published by
  2091. # the Free Software Foundation; either version 2 of the License, or
  2092. # (at your option) any later version.
  2093. #
  2094. # This program is distributed in the hope that it will be useful,
  2095. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2096. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2097. # GNU General Public License for more details.
  2098. #
  2099. # You should have received a copy of the GNU General Public License
  2100. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2101. #
  2102.  
  2103. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2104. +++ [[ -n 1 ]]
  2105. +++ return
  2106.  
  2107.  
  2108. declare -a lint_pkgbuild_functions
  2109. ++ declare -a lint_pkgbuild_functions
  2110.  
  2111. for lib in "$LIBRARY/lint_pkgbuild/"*.sh; do
  2112. source "$lib"
  2113. done
  2114. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  2115. ++ source /usr/share/makepkg/lint_pkgbuild/arch.sh
  2116. #!/usr/bin/bash
  2117. #
  2118. # arch.sh - Check the 'arch' array conforms to requirements.
  2119. #
  2120. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2121. #
  2122. # This program is free software; you can redistribute it and/or modify
  2123. # it under the terms of the GNU General Public License as published by
  2124. # the Free Software Foundation; either version 2 of the License, or
  2125. # (at your option) any later version.
  2126. #
  2127. # This program is distributed in the hope that it will be useful,
  2128. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2129. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2130. # GNU General Public License for more details.
  2131. #
  2132. # You should have received a copy of the GNU General Public License
  2133. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2134. #
  2135.  
  2136. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_ARCH_SH" ]] && return
  2137. +++ [[ -n '' ]]
  2138. LIBMAKEPKG_LINT_PKGBUILD_ARCH_SH=1
  2139. +++ LIBMAKEPKG_LINT_PKGBUILD_ARCH_SH=1
  2140.  
  2141. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2142. +++ LIBRARY=/usr/share/makepkg
  2143.  
  2144. source "$LIBRARY/util/message.sh"
  2145. +++ source /usr/share/makepkg/util/message.sh
  2146. #!/usr/bin/bash
  2147. #
  2148. # message.sh - functions for outputting messages in makepkg
  2149. #
  2150. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2151. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2152. #
  2153. # This program is free software; you can redistribute it and/or modify
  2154. # it under the terms of the GNU General Public License as published by
  2155. # the Free Software Foundation; either version 2 of the License, or
  2156. # (at your option) any later version.
  2157. #
  2158. # This program is distributed in the hope that it will be useful,
  2159. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2160. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2161. # GNU General Public License for more details.
  2162. #
  2163. # You should have received a copy of the GNU General Public License
  2164. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2165. #
  2166.  
  2167. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2168. ++++ [[ -n 1 ]]
  2169. ++++ return
  2170. source "$LIBRARY/util/pkgbuild.sh"
  2171. +++ source /usr/share/makepkg/util/pkgbuild.sh
  2172. #!/usr/bin/bash
  2173. #
  2174. # pkgbuild.sh - functions to extract information from PKGBUILD files
  2175. #
  2176. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2177. #
  2178. # This program is free software; you can redistribute it and/or modify
  2179. # it under the terms of the GNU General Public License as published by
  2180. # the Free Software Foundation; either version 2 of the License, or
  2181. # (at your option) any later version.
  2182. #
  2183. # This program is distributed in the hope that it will be useful,
  2184. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2185. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2186. # GNU General Public License for more details.
  2187. #
  2188. # You should have received a copy of the GNU General Public License
  2189. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2190. #
  2191.  
  2192. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  2193. ++++ [[ -n 1 ]]
  2194. ++++ return
  2195.  
  2196.  
  2197. lint_pkgbuild_functions+=('lint_arch')
  2198. +++ lint_pkgbuild_functions+=('lint_arch')
  2199.  
  2200.  
  2201. lint_arch() {
  2202. local a name list ret=0
  2203.  
  2204. if [[ $arch == 'any' ]]; then
  2205. return 0
  2206. fi
  2207.  
  2208. for a in "${arch[@]}"; do
  2209. if [[ $a = *[![:alnum:]_]* ]]; then
  2210. error "$(gettext "%s contains invalid characters: '%s'")" \
  2211. 'arch' "${a//[[:alnum:]_]}"
  2212. ret=1
  2213. fi
  2214. done
  2215.  
  2216. if (( ! IGNOREARCH )) && ! in_array "$CARCH" "${arch[@]}"; then
  2217. error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgbase" "$CARCH"
  2218. return 1
  2219. fi
  2220.  
  2221. for name in "${pkgname[@]}"; do
  2222. get_pkgbuild_attribute "$name" 'arch' 1 list
  2223. if [[ $list && $list != 'any' ]] && ! in_array $CARCH "${list[@]}"; then
  2224. if (( ! IGNOREARCH )); then
  2225. error "$(gettext "%s is not available for the '%s' architecture.")" "$name" "$CARCH"
  2226. ret=1
  2227. fi
  2228. fi
  2229. done
  2230.  
  2231. return $ret
  2232. }
  2233. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  2234. ++ source /usr/share/makepkg/lint_pkgbuild/backup.sh
  2235. #!/usr/bin/bash
  2236. #
  2237. # backup.sh - Check the 'backup' array conforms to requirements.
  2238. #
  2239. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2240. #
  2241. # This program is free software; you can redistribute it and/or modify
  2242. # it under the terms of the GNU General Public License as published by
  2243. # the Free Software Foundation; either version 2 of the License, or
  2244. # (at your option) any later version.
  2245. #
  2246. # This program is distributed in the hope that it will be useful,
  2247. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2248. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2249. # GNU General Public License for more details.
  2250. #
  2251. # You should have received a copy of the GNU General Public License
  2252. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2253. #
  2254.  
  2255. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_BACKUP_SH" ]] && return
  2256. +++ [[ -n '' ]]
  2257. LIBMAKEPKG_LINT_PKGBUILD_BACKUP_SH=1
  2258. +++ LIBMAKEPKG_LINT_PKGBUILD_BACKUP_SH=1
  2259.  
  2260. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2261. +++ LIBRARY=/usr/share/makepkg
  2262.  
  2263. source "$LIBRARY/util/message.sh"
  2264. +++ source /usr/share/makepkg/util/message.sh
  2265. #!/usr/bin/bash
  2266. #
  2267. # message.sh - functions for outputting messages in makepkg
  2268. #
  2269. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2270. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2271. #
  2272. # This program is free software; you can redistribute it and/or modify
  2273. # it under the terms of the GNU General Public License as published by
  2274. # the Free Software Foundation; either version 2 of the License, or
  2275. # (at your option) any later version.
  2276. #
  2277. # This program is distributed in the hope that it will be useful,
  2278. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2279. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2280. # GNU General Public License for more details.
  2281. #
  2282. # You should have received a copy of the GNU General Public License
  2283. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2284. #
  2285.  
  2286. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2287. ++++ [[ -n 1 ]]
  2288. ++++ return
  2289. source "$LIBRARY/util/pkgbuild.sh"
  2290. +++ source /usr/share/makepkg/util/pkgbuild.sh
  2291. #!/usr/bin/bash
  2292. #
  2293. # pkgbuild.sh - functions to extract information from PKGBUILD files
  2294. #
  2295. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2296. #
  2297. # This program is free software; you can redistribute it and/or modify
  2298. # it under the terms of the GNU General Public License as published by
  2299. # the Free Software Foundation; either version 2 of the License, or
  2300. # (at your option) any later version.
  2301. #
  2302. # This program is distributed in the hope that it will be useful,
  2303. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2304. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2305. # GNU General Public License for more details.
  2306. #
  2307. # You should have received a copy of the GNU General Public License
  2308. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2309. #
  2310.  
  2311. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  2312. ++++ [[ -n 1 ]]
  2313. ++++ return
  2314.  
  2315.  
  2316. lint_pkgbuild_functions+=('lint_backup')
  2317. +++ lint_pkgbuild_functions+=('lint_backup')
  2318.  
  2319.  
  2320. lint_backup() {
  2321. local list name backup_list ret=0
  2322.  
  2323. backup_list=("${backup[@]}")
  2324. for name in "${pkgname[@]}"; do
  2325. if extract_function_variable "package_$name" backup 1 list; then
  2326. backup_list+=("${list[@]}")
  2327. fi
  2328. done
  2329.  
  2330. for name in "${backup_list[@]}"; do
  2331. if [[ ${name:0:1} = "/" ]]; then
  2332. error "$(gettext "%s entry should not contain leading slash : %s")" "backup" "$name"
  2333. ret=1
  2334. fi
  2335. done
  2336.  
  2337. return $ret
  2338. }
  2339. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  2340. ++ source /usr/share/makepkg/lint_pkgbuild/changelog.sh
  2341. #!/usr/bin/bash
  2342. #
  2343. # changelog.sh - Check the files in the 'changelog' array exist.
  2344. #
  2345. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2346. #
  2347. # This program is free software; you can redistribute it and/or modify
  2348. # it under the terms of the GNU General Public License as published by
  2349. # the Free Software Foundation; either version 2 of the License, or
  2350. # (at your option) any later version.
  2351. #
  2352. # This program is distributed in the hope that it will be useful,
  2353. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2354. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2355. # GNU General Public License for more details.
  2356. #
  2357. # You should have received a copy of the GNU General Public License
  2358. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2359. #
  2360.  
  2361. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_CHANGELOG_SH" ]] && return
  2362. +++ [[ -n '' ]]
  2363. LIBMAKEPKG_LINT_PKGBUILD_CHANGELOG_SH=1
  2364. +++ LIBMAKEPKG_LINT_PKGBUILD_CHANGELOG_SH=1
  2365.  
  2366. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2367. +++ LIBRARY=/usr/share/makepkg
  2368.  
  2369. source "$LIBRARY/util/message.sh"
  2370. +++ source /usr/share/makepkg/util/message.sh
  2371. #!/usr/bin/bash
  2372. #
  2373. # message.sh - functions for outputting messages in makepkg
  2374. #
  2375. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2376. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2377. #
  2378. # This program is free software; you can redistribute it and/or modify
  2379. # it under the terms of the GNU General Public License as published by
  2380. # the Free Software Foundation; either version 2 of the License, or
  2381. # (at your option) any later version.
  2382. #
  2383. # This program is distributed in the hope that it will be useful,
  2384. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2385. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2386. # GNU General Public License for more details.
  2387. #
  2388. # You should have received a copy of the GNU General Public License
  2389. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2390. #
  2391.  
  2392. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2393. ++++ [[ -n 1 ]]
  2394. ++++ return
  2395. source "$LIBRARY/util/pkgbuild.sh"
  2396. +++ source /usr/share/makepkg/util/pkgbuild.sh
  2397. #!/usr/bin/bash
  2398. #
  2399. # pkgbuild.sh - functions to extract information from PKGBUILD files
  2400. #
  2401. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2402. #
  2403. # This program is free software; you can redistribute it and/or modify
  2404. # it under the terms of the GNU General Public License as published by
  2405. # the Free Software Foundation; either version 2 of the License, or
  2406. # (at your option) any later version.
  2407. #
  2408. # This program is distributed in the hope that it will be useful,
  2409. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2410. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2411. # GNU General Public License for more details.
  2412. #
  2413. # You should have received a copy of the GNU General Public License
  2414. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2415. #
  2416.  
  2417. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  2418. ++++ [[ -n 1 ]]
  2419. ++++ return
  2420. source "$LIBRARY/lint_pkgbuild/util.sh"
  2421. +++ source /usr/share/makepkg/lint_pkgbuild/util.sh
  2422. #!/usr/bin/bash
  2423. #
  2424. # util.sh - utility functions for pkgbuild linting.
  2425. #
  2426. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2427. #
  2428. # This program is free software; you can redistribute it and/or modify
  2429. # it under the terms of the GNU General Public License as published by
  2430. # the Free Software Foundation; either version 2 of the License, or
  2431. # (at your option) any later version.
  2432. #
  2433. # This program is distributed in the hope that it will be useful,
  2434. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2435. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2436. # GNU General Public License for more details.
  2437. #
  2438. # You should have received a copy of the GNU General Public License
  2439. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2440. #
  2441.  
  2442. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_UTIL_SH" ]] && return
  2443. ++++ [[ -n '' ]]
  2444. LIBMAKEPKG_LINT_PKGBUILD_UTIL_SH=1
  2445. ++++ LIBMAKEPKG_LINT_PKGBUILD_UTIL_SH=1
  2446.  
  2447. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2448. ++++ LIBRARY=/usr/share/makepkg
  2449.  
  2450. source "$LIBRARY/util/message.sh"
  2451. ++++ source /usr/share/makepkg/util/message.sh
  2452. #!/usr/bin/bash
  2453. #
  2454. # message.sh - functions for outputting messages in makepkg
  2455. #
  2456. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2457. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2458. #
  2459. # This program is free software; you can redistribute it and/or modify
  2460. # it under the terms of the GNU General Public License as published by
  2461. # the Free Software Foundation; either version 2 of the License, or
  2462. # (at your option) any later version.
  2463. #
  2464. # This program is distributed in the hope that it will be useful,
  2465. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2466. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2467. # GNU General Public License for more details.
  2468. #
  2469. # You should have received a copy of the GNU General Public License
  2470. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2471. #
  2472.  
  2473. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2474. +++++ [[ -n 1 ]]
  2475. +++++ return
  2476.  
  2477.  
  2478. check_files_exist() {
  2479. local kind=$1 files=("${@:2}") file ret=0
  2480.  
  2481. for file in "${files[@]}"; do
  2482. if [[ $file && ! -f $file ]]; then
  2483. error "$(gettext "%s file (%s) does not exist or is not a regular file.")" \
  2484. "$kind" "$file"
  2485. ret=1
  2486. fi
  2487. done
  2488.  
  2489. return $ret
  2490. }
  2491.  
  2492.  
  2493. lint_pkgbuild_functions+=('lint_changelog')
  2494. +++ lint_pkgbuild_functions+=('lint_changelog')
  2495.  
  2496.  
  2497. lint_changelog() {
  2498. local name file changelog_list
  2499.  
  2500. changelog_list=("${changelog[@]}")
  2501. for name in "${pkgname[@]}"; do
  2502. if extract_function_variable "package_$name" changelog 0 file; then
  2503. changelog_list+=("$file")
  2504. fi
  2505. done
  2506.  
  2507. check_files_exist 'changelog' "${changelog_list[@]}" || ret=1
  2508.  
  2509. return $ret
  2510. }
  2511. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  2512. ++ source /usr/share/makepkg/lint_pkgbuild/checkdepends.sh
  2513. #!/usr/bin/bash
  2514. #
  2515. # checkdepends.sh - Check the 'checkdepends' array conforms to requirements.
  2516. #
  2517. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2518. #
  2519. # This program is free software; you can redistribute it and/or modify
  2520. # it under the terms of the GNU General Public License as published by
  2521. # the Free Software Foundation; either version 2 of the License, or
  2522. # (at your option) any later version.
  2523. #
  2524. # This program is distributed in the hope that it will be useful,
  2525. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2526. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2527. # GNU General Public License for more details.
  2528. #
  2529. # You should have received a copy of the GNU General Public License
  2530. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2531. #
  2532.  
  2533. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_CHECKDEPENDS_SH" ]] && return
  2534. +++ [[ -n '' ]]
  2535. LIBMAKEPKG_LINT_PKGBUILD_CHECKDEPENDS_SH=1
  2536. +++ LIBMAKEPKG_LINT_PKGBUILD_CHECKDEPENDS_SH=1
  2537.  
  2538. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2539. +++ LIBRARY=/usr/share/makepkg
  2540.  
  2541. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  2542. +++ source /usr/share/makepkg/lint_pkgbuild/pkgname.sh
  2543. #!/usr/bin/bash
  2544. #
  2545. # pkgname.sh - Check the 'pkgname' variable conforms to requirements.
  2546. #
  2547. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2548. #
  2549. # This program is free software; you can redistribute it and/or modify
  2550. # it under the terms of the GNU General Public License as published by
  2551. # the Free Software Foundation; either version 2 of the License, or
  2552. # (at your option) any later version.
  2553. #
  2554. # This program is distributed in the hope that it will be useful,
  2555. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2556. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2557. # GNU General Public License for more details.
  2558. #
  2559. # You should have received a copy of the GNU General Public License
  2560. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2561. #
  2562.  
  2563. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH" ]] && return
  2564. ++++ [[ -n '' ]]
  2565. LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH=1
  2566. ++++ LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH=1
  2567.  
  2568. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2569. ++++ LIBRARY=/usr/share/makepkg
  2570.  
  2571. source "$LIBRARY/util/message.sh"
  2572. ++++ source /usr/share/makepkg/util/message.sh
  2573. #!/usr/bin/bash
  2574. #
  2575. # message.sh - functions for outputting messages in makepkg
  2576. #
  2577. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2578. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2579. #
  2580. # This program is free software; you can redistribute it and/or modify
  2581. # it under the terms of the GNU General Public License as published by
  2582. # the Free Software Foundation; either version 2 of the License, or
  2583. # (at your option) any later version.
  2584. #
  2585. # This program is distributed in the hope that it will be useful,
  2586. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2587. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2588. # GNU General Public License for more details.
  2589. #
  2590. # You should have received a copy of the GNU General Public License
  2591. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2592. #
  2593.  
  2594. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2595. +++++ [[ -n 1 ]]
  2596. +++++ return
  2597.  
  2598.  
  2599. lint_pkgbuild_functions+=('lint_pkgname')
  2600. ++++ lint_pkgbuild_functions+=('lint_pkgname')
  2601.  
  2602.  
  2603. lint_one_pkgname() {
  2604. local type=$1 name=$2 ret=0
  2605.  
  2606.  
  2607. if [[ -z $name ]]; then
  2608. error "$(gettext "%s is not allowed to be empty.")" "$type"
  2609. return 1
  2610. fi
  2611. if [[ ${name:0:1} = "-" ]]; then
  2612. error "$(gettext "%s is not allowed to start with a hyphen.")" "$type"
  2613. ret=1
  2614. fi
  2615. if [[ ${name:0:1} = "." ]]; then
  2616. error "$(gettext "%s is not allowed to start with a dot.")" "$type"
  2617. ret=1
  2618. fi
  2619. if [[ $name = *[^[:alnum:]+_.@-]* ]]; then
  2620. error "$(gettext "%s contains invalid characters: '%s'")" \
  2621. "$type" "${name//[[:alnum:]+_.@-]}"
  2622. ret=1
  2623. fi
  2624.  
  2625. return $ret
  2626. }
  2627.  
  2628. lint_pkgname() {
  2629. local ret=0 i
  2630.  
  2631. if [[ -z ${pkgname[@]} ]]; then
  2632. error "$(gettext "%s is not allowed to be empty.")" "pkgname"
  2633. ret=1
  2634. else
  2635. for i in "${pkgname[@]}"; do
  2636. lint_one_pkgname "pkgname" "$i" || ret=1
  2637. done
  2638. fi
  2639.  
  2640. return $ret
  2641. }
  2642. source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  2643. +++ source /usr/share/makepkg/lint_pkgbuild/pkgver.sh
  2644. #!/usr/bin/bash
  2645. #
  2646. # pkgver.sh - Check the 'pkgver' variable conforms to requirements.
  2647. #
  2648. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2649. #
  2650. # This program is free software; you can redistribute it and/or modify
  2651. # it under the terms of the GNU General Public License as published by
  2652. # the Free Software Foundation; either version 2 of the License, or
  2653. # (at your option) any later version.
  2654. #
  2655. # This program is distributed in the hope that it will be useful,
  2656. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2657. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2658. # GNU General Public License for more details.
  2659. #
  2660. # You should have received a copy of the GNU General Public License
  2661. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2662. #
  2663.  
  2664. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH" ]] && return
  2665. ++++ [[ -n '' ]]
  2666. LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH=1
  2667. ++++ LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH=1
  2668.  
  2669. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2670. ++++ LIBRARY=/usr/share/makepkg
  2671.  
  2672. source "$LIBRARY/util/message.sh"
  2673. ++++ source /usr/share/makepkg/util/message.sh
  2674. #!/usr/bin/bash
  2675. #
  2676. # message.sh - functions for outputting messages in makepkg
  2677. #
  2678. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2679. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2680. #
  2681. # This program is free software; you can redistribute it and/or modify
  2682. # it under the terms of the GNU General Public License as published by
  2683. # the Free Software Foundation; either version 2 of the License, or
  2684. # (at your option) any later version.
  2685. #
  2686. # This program is distributed in the hope that it will be useful,
  2687. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2688. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2689. # GNU General Public License for more details.
  2690. #
  2691. # You should have received a copy of the GNU General Public License
  2692. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2693. #
  2694.  
  2695. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2696. +++++ [[ -n 1 ]]
  2697. +++++ return
  2698.  
  2699.  
  2700. lint_pkgbuild_functions+=('lint_pkgver')
  2701. ++++ lint_pkgbuild_functions+=('lint_pkgver')
  2702.  
  2703.  
  2704. check_pkgver() {
  2705. local ver=$1 type=$2
  2706.  
  2707. if [[ -z $ver ]]; then
  2708. error "$(gettext "%s is not allowed to be empty.")" "pkgver${type:+ in $type}"
  2709. return 1
  2710. fi
  2711.  
  2712. if [[ $ver = *[[:space:]/:-]* ]]; then
  2713. error "$(gettext "%s is not allowed to contain colons, forward slashes, hyphens or whitespace.")" "pkgver${type:+ in $type}"
  2714. return 1
  2715. fi
  2716. }
  2717.  
  2718. lint_pkgver() {
  2719. if (( PKGVERFUNC )); then
  2720. # defer check to after getting version from pkgver function
  2721. return 0
  2722. fi
  2723.  
  2724. check_pkgver "$pkgver"
  2725. }
  2726. source "$LIBRARY/util/message.sh"
  2727. +++ source /usr/share/makepkg/util/message.sh
  2728. #!/usr/bin/bash
  2729. #
  2730. # message.sh - functions for outputting messages in makepkg
  2731. #
  2732. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2733. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2734. #
  2735. # This program is free software; you can redistribute it and/or modify
  2736. # it under the terms of the GNU General Public License as published by
  2737. # the Free Software Foundation; either version 2 of the License, or
  2738. # (at your option) any later version.
  2739. #
  2740. # This program is distributed in the hope that it will be useful,
  2741. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2742. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2743. # GNU General Public License for more details.
  2744. #
  2745. # You should have received a copy of the GNU General Public License
  2746. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2747. #
  2748.  
  2749. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2750. ++++ [[ -n 1 ]]
  2751. ++++ return
  2752. source "$LIBRARY/util/pkgbuild.sh"
  2753. +++ source /usr/share/makepkg/util/pkgbuild.sh
  2754. #!/usr/bin/bash
  2755. #
  2756. # pkgbuild.sh - functions to extract information from PKGBUILD files
  2757. #
  2758. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2759. #
  2760. # This program is free software; you can redistribute it and/or modify
  2761. # it under the terms of the GNU General Public License as published by
  2762. # the Free Software Foundation; either version 2 of the License, or
  2763. # (at your option) any later version.
  2764. #
  2765. # This program is distributed in the hope that it will be useful,
  2766. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2767. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2768. # GNU General Public License for more details.
  2769. #
  2770. # You should have received a copy of the GNU General Public License
  2771. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2772. #
  2773.  
  2774. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  2775. ++++ [[ -n 1 ]]
  2776. ++++ return
  2777.  
  2778.  
  2779. lint_pkgbuild_functions+=('lint_checkdepends')
  2780. +++ lint_pkgbuild_functions+=('lint_checkdepends')
  2781.  
  2782.  
  2783. lint_checkdepends() {
  2784. local checkdepends_list checkdepend name ver ret=0
  2785.  
  2786. get_pkgbuild_all_split_attributes checkdepends checkdepends_list
  2787.  
  2788. # this function requires extglob - save current status to restore later
  2789. local shellopts=$(shopt -p extglob)
  2790. shopt -s extglob
  2791.  
  2792. for checkdepend in "${checkdepends_list[@]}"; do
  2793. name=${checkdepend%%@(<|>|=|>=|<=)*}
  2794. # remove optional epoch in version specifier
  2795. ver=${checkdepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  2796. lint_one_pkgname checkdepends "$name" || ret=1
  2797. if [[ $ver != $checkdepend ]]; then
  2798. # remove optional pkgrel in version specifier
  2799. check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" checkdepends || ret=1
  2800. fi
  2801. done
  2802.  
  2803. eval "$shellopts"
  2804.  
  2805. return $ret
  2806. }
  2807. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  2808. ++ source /usr/share/makepkg/lint_pkgbuild/conflicts.sh
  2809. #!/usr/bin/bash
  2810. #
  2811. # conflicts.sh - Check the 'conflicts' array conforms to requirements.
  2812. #
  2813. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2814. #
  2815. # This program is free software; you can redistribute it and/or modify
  2816. # it under the terms of the GNU General Public License as published by
  2817. # the Free Software Foundation; either version 2 of the License, or
  2818. # (at your option) any later version.
  2819. #
  2820. # This program is distributed in the hope that it will be useful,
  2821. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2822. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2823. # GNU General Public License for more details.
  2824. #
  2825. # You should have received a copy of the GNU General Public License
  2826. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2827. #
  2828.  
  2829. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_CONFLICTS_SH" ]] && return
  2830. +++ [[ -n '' ]]
  2831. LIBMAKEPKG_LINT_PKGBUILD_CONFLICTS_SH=1
  2832. +++ LIBMAKEPKG_LINT_PKGBUILD_CONFLICTS_SH=1
  2833.  
  2834. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2835. +++ LIBRARY=/usr/share/makepkg
  2836.  
  2837. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  2838. +++ source /usr/share/makepkg/lint_pkgbuild/pkgname.sh
  2839. #!/usr/bin/bash
  2840. #
  2841. # pkgname.sh - Check the 'pkgname' variable conforms to requirements.
  2842. #
  2843. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2844. #
  2845. # This program is free software; you can redistribute it and/or modify
  2846. # it under the terms of the GNU General Public License as published by
  2847. # the Free Software Foundation; either version 2 of the License, or
  2848. # (at your option) any later version.
  2849. #
  2850. # This program is distributed in the hope that it will be useful,
  2851. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2852. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2853. # GNU General Public License for more details.
  2854. #
  2855. # You should have received a copy of the GNU General Public License
  2856. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2857. #
  2858.  
  2859. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH" ]] && return
  2860. ++++ [[ -n 1 ]]
  2861. ++++ return
  2862. source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  2863. +++ source /usr/share/makepkg/lint_pkgbuild/pkgver.sh
  2864. #!/usr/bin/bash
  2865. #
  2866. # pkgver.sh - Check the 'pkgver' variable conforms to requirements.
  2867. #
  2868. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2869. #
  2870. # This program is free software; you can redistribute it and/or modify
  2871. # it under the terms of the GNU General Public License as published by
  2872. # the Free Software Foundation; either version 2 of the License, or
  2873. # (at your option) any later version.
  2874. #
  2875. # This program is distributed in the hope that it will be useful,
  2876. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2877. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2878. # GNU General Public License for more details.
  2879. #
  2880. # You should have received a copy of the GNU General Public License
  2881. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2882. #
  2883.  
  2884. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH" ]] && return
  2885. ++++ [[ -n 1 ]]
  2886. ++++ return
  2887. source "$LIBRARY/util/message.sh"
  2888. +++ source /usr/share/makepkg/util/message.sh
  2889. #!/usr/bin/bash
  2890. #
  2891. # message.sh - functions for outputting messages in makepkg
  2892. #
  2893. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2894. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  2895. #
  2896. # This program is free software; you can redistribute it and/or modify
  2897. # it under the terms of the GNU General Public License as published by
  2898. # the Free Software Foundation; either version 2 of the License, or
  2899. # (at your option) any later version.
  2900. #
  2901. # This program is distributed in the hope that it will be useful,
  2902. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2903. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2904. # GNU General Public License for more details.
  2905. #
  2906. # You should have received a copy of the GNU General Public License
  2907. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2908. #
  2909.  
  2910. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  2911. ++++ [[ -n 1 ]]
  2912. ++++ return
  2913. source "$LIBRARY/util/pkgbuild.sh"
  2914. +++ source /usr/share/makepkg/util/pkgbuild.sh
  2915. #!/usr/bin/bash
  2916. #
  2917. # pkgbuild.sh - functions to extract information from PKGBUILD files
  2918. #
  2919. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2920. #
  2921. # This program is free software; you can redistribute it and/or modify
  2922. # it under the terms of the GNU General Public License as published by
  2923. # the Free Software Foundation; either version 2 of the License, or
  2924. # (at your option) any later version.
  2925. #
  2926. # This program is distributed in the hope that it will be useful,
  2927. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2928. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2929. # GNU General Public License for more details.
  2930. #
  2931. # You should have received a copy of the GNU General Public License
  2932. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2933. #
  2934.  
  2935. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  2936. ++++ [[ -n 1 ]]
  2937. ++++ return
  2938.  
  2939.  
  2940. lint_pkgbuild_functions+=('lint_conflicts')
  2941. +++ lint_pkgbuild_functions+=('lint_conflicts')
  2942.  
  2943.  
  2944. lint_conflicts() {
  2945. local conflicts_list conflict name ver ret=0
  2946.  
  2947. get_pkgbuild_all_split_attributes conflicts conflicts_list
  2948.  
  2949. # this function requires extglob - save current status to restore later
  2950. local shellopts=$(shopt -p extglob)
  2951. shopt -s extglob
  2952.  
  2953. for conflict in "${conflicts_list[@]}"; do
  2954. name=${conflict%%@(<|>|=|>=|<=)*}
  2955. # remove optional epoch in version specifier
  2956. ver=${conflict##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  2957. lint_one_pkgname conflicts "$name" || ret=1
  2958. if [[ $ver != $conflict ]]; then
  2959. # remove optional pkgrel in version specifier
  2960. check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" conflicts || ret=1
  2961. fi
  2962. done
  2963.  
  2964. eval "$shellopts"
  2965.  
  2966. return $ret
  2967. }
  2968. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  2969. ++ source /usr/share/makepkg/lint_pkgbuild/depends.sh
  2970. #!/usr/bin/bash
  2971. #
  2972. # depends.sh - Check the 'depends' array conforms to requirements.
  2973. #
  2974. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  2975. #
  2976. # This program is free software; you can redistribute it and/or modify
  2977. # it under the terms of the GNU General Public License as published by
  2978. # the Free Software Foundation; either version 2 of the License, or
  2979. # (at your option) any later version.
  2980. #
  2981. # This program is distributed in the hope that it will be useful,
  2982. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  2983. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  2984. # GNU General Public License for more details.
  2985. #
  2986. # You should have received a copy of the GNU General Public License
  2987. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2988. #
  2989.  
  2990. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_DEPENDS_SH" ]] && return
  2991. +++ [[ -n '' ]]
  2992. LIBMAKEPKG_LINT_PKGBUILD_DEPENDS_SH=1
  2993. +++ LIBMAKEPKG_LINT_PKGBUILD_DEPENDS_SH=1
  2994.  
  2995. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  2996. +++ LIBRARY=/usr/share/makepkg
  2997.  
  2998. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  2999. +++ source /usr/share/makepkg/lint_pkgbuild/pkgname.sh
  3000. #!/usr/bin/bash
  3001. #
  3002. # pkgname.sh - Check the 'pkgname' variable conforms to requirements.
  3003. #
  3004. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3005. #
  3006. # This program is free software; you can redistribute it and/or modify
  3007. # it under the terms of the GNU General Public License as published by
  3008. # the Free Software Foundation; either version 2 of the License, or
  3009. # (at your option) any later version.
  3010. #
  3011. # This program is distributed in the hope that it will be useful,
  3012. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3013. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3014. # GNU General Public License for more details.
  3015. #
  3016. # You should have received a copy of the GNU General Public License
  3017. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3018. #
  3019.  
  3020. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH" ]] && return
  3021. ++++ [[ -n 1 ]]
  3022. ++++ return
  3023. source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  3024. +++ source /usr/share/makepkg/lint_pkgbuild/pkgver.sh
  3025. #!/usr/bin/bash
  3026. #
  3027. # pkgver.sh - Check the 'pkgver' variable conforms to requirements.
  3028. #
  3029. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3030. #
  3031. # This program is free software; you can redistribute it and/or modify
  3032. # it under the terms of the GNU General Public License as published by
  3033. # the Free Software Foundation; either version 2 of the License, or
  3034. # (at your option) any later version.
  3035. #
  3036. # This program is distributed in the hope that it will be useful,
  3037. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3038. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3039. # GNU General Public License for more details.
  3040. #
  3041. # You should have received a copy of the GNU General Public License
  3042. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3043. #
  3044.  
  3045. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH" ]] && return
  3046. ++++ [[ -n 1 ]]
  3047. ++++ return
  3048. source "$LIBRARY/util/message.sh"
  3049. +++ source /usr/share/makepkg/util/message.sh
  3050. #!/usr/bin/bash
  3051. #
  3052. # message.sh - functions for outputting messages in makepkg
  3053. #
  3054. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3055. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3056. #
  3057. # This program is free software; you can redistribute it and/or modify
  3058. # it under the terms of the GNU General Public License as published by
  3059. # the Free Software Foundation; either version 2 of the License, or
  3060. # (at your option) any later version.
  3061. #
  3062. # This program is distributed in the hope that it will be useful,
  3063. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3064. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3065. # GNU General Public License for more details.
  3066. #
  3067. # You should have received a copy of the GNU General Public License
  3068. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3069. #
  3070.  
  3071. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  3072. ++++ [[ -n 1 ]]
  3073. ++++ return
  3074. source "$LIBRARY/util/pkgbuild.sh"
  3075. +++ source /usr/share/makepkg/util/pkgbuild.sh
  3076. #!/usr/bin/bash
  3077. #
  3078. # pkgbuild.sh - functions to extract information from PKGBUILD files
  3079. #
  3080. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3081. #
  3082. # This program is free software; you can redistribute it and/or modify
  3083. # it under the terms of the GNU General Public License as published by
  3084. # the Free Software Foundation; either version 2 of the License, or
  3085. # (at your option) any later version.
  3086. #
  3087. # This program is distributed in the hope that it will be useful,
  3088. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3089. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3090. # GNU General Public License for more details.
  3091. #
  3092. # You should have received a copy of the GNU General Public License
  3093. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3094. #
  3095.  
  3096. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  3097. ++++ [[ -n 1 ]]
  3098. ++++ return
  3099.  
  3100.  
  3101. lint_pkgbuild_functions+=('lint_depends')
  3102. +++ lint_pkgbuild_functions+=('lint_depends')
  3103.  
  3104.  
  3105. lint_depends() {
  3106. local depends_list depend name ver ret=0
  3107.  
  3108. get_pkgbuild_all_split_attributes depends depends_list
  3109.  
  3110. # this function requires extglob - save current status to restore later
  3111. local shellopts=$(shopt -p extglob)
  3112. shopt -s extglob
  3113.  
  3114. for depend in "${depends_list[@]}"; do
  3115. name=${depend%%@(<|>|=|>=|<=)*}
  3116. # remove optional epoch in version specifier
  3117. ver=${depend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  3118. lint_one_pkgname depends "$name" || ret=1
  3119. # Don't validate empty version because of https://bugs.archlinux.org/task/58776
  3120. if [[ $ver != $depend && -n $ver ]]; then
  3121. # remove optional pkgrel in version specifier
  3122. check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" depends || ret=1
  3123. fi
  3124. done
  3125.  
  3126. eval "$shellopts"
  3127.  
  3128. return $ret
  3129. }
  3130. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  3131. ++ source /usr/share/makepkg/lint_pkgbuild/epoch.sh
  3132. #!/usr/bin/bash
  3133. #
  3134. # epoch.sh - Check the 'epoch' variable conforms to requirements.
  3135. #
  3136. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3137. #
  3138. # This program is free software; you can redistribute it and/or modify
  3139. # it under the terms of the GNU General Public License as published by
  3140. # the Free Software Foundation; either version 2 of the License, or
  3141. # (at your option) any later version.
  3142. #
  3143. # This program is distributed in the hope that it will be useful,
  3144. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3145. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3146. # GNU General Public License for more details.
  3147. #
  3148. # You should have received a copy of the GNU General Public License
  3149. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3150. #
  3151.  
  3152. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_EPOCH_SH" ]] && return
  3153. +++ [[ -n '' ]]
  3154. LIBMAKEPKG_LINT_PKGBUILD_EPOCH_SH=1
  3155. +++ LIBMAKEPKG_LINT_PKGBUILD_EPOCH_SH=1
  3156.  
  3157. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  3158. +++ LIBRARY=/usr/share/makepkg
  3159.  
  3160. source "$LIBRARY/util/message.sh"
  3161. +++ source /usr/share/makepkg/util/message.sh
  3162. #!/usr/bin/bash
  3163. #
  3164. # message.sh - functions for outputting messages in makepkg
  3165. #
  3166. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3167. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3168. #
  3169. # This program is free software; you can redistribute it and/or modify
  3170. # it under the terms of the GNU General Public License as published by
  3171. # the Free Software Foundation; either version 2 of the License, or
  3172. # (at your option) any later version.
  3173. #
  3174. # This program is distributed in the hope that it will be useful,
  3175. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3176. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3177. # GNU General Public License for more details.
  3178. #
  3179. # You should have received a copy of the GNU General Public License
  3180. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3181. #
  3182.  
  3183. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  3184. ++++ [[ -n 1 ]]
  3185. ++++ return
  3186.  
  3187.  
  3188. lint_pkgbuild_functions+=('lint_epoch')
  3189. +++ lint_pkgbuild_functions+=('lint_epoch')
  3190.  
  3191.  
  3192. lint_epoch() {
  3193. if [[ $epoch != *([[:digit:]]) ]]; then
  3194. error "$(gettext "%s must be an integer, not %s.")" "epoch" "$epoch"
  3195. return 1
  3196. fi
  3197. }
  3198. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  3199. ++ source /usr/share/makepkg/lint_pkgbuild/install.sh
  3200. #!/usr/bin/bash
  3201. #
  3202. # install.sh - Check the files in the 'install' array exist.
  3203. #
  3204. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3205. #
  3206. # This program is free software; you can redistribute it and/or modify
  3207. # it under the terms of the GNU General Public License as published by
  3208. # the Free Software Foundation; either version 2 of the License, or
  3209. # (at your option) any later version.
  3210. #
  3211. # This program is distributed in the hope that it will be useful,
  3212. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3213. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3214. # GNU General Public License for more details.
  3215. #
  3216. # You should have received a copy of the GNU General Public License
  3217. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3218. #
  3219.  
  3220. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_INSTALL_SH" ]] && return
  3221. +++ [[ -n '' ]]
  3222. LIBMAKEPKG_LINT_PKGBUILD_INSTALL_SH=1
  3223. +++ LIBMAKEPKG_LINT_PKGBUILD_INSTALL_SH=1
  3224.  
  3225. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  3226. +++ LIBRARY=/usr/share/makepkg
  3227.  
  3228. source "$LIBRARY/util/message.sh"
  3229. +++ source /usr/share/makepkg/util/message.sh
  3230. #!/usr/bin/bash
  3231. #
  3232. # message.sh - functions for outputting messages in makepkg
  3233. #
  3234. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3235. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3236. #
  3237. # This program is free software; you can redistribute it and/or modify
  3238. # it under the terms of the GNU General Public License as published by
  3239. # the Free Software Foundation; either version 2 of the License, or
  3240. # (at your option) any later version.
  3241. #
  3242. # This program is distributed in the hope that it will be useful,
  3243. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3244. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3245. # GNU General Public License for more details.
  3246. #
  3247. # You should have received a copy of the GNU General Public License
  3248. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3249. #
  3250.  
  3251. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  3252. ++++ [[ -n 1 ]]
  3253. ++++ return
  3254. source "$LIBRARY/util/pkgbuild.sh"
  3255. +++ source /usr/share/makepkg/util/pkgbuild.sh
  3256. #!/usr/bin/bash
  3257. #
  3258. # pkgbuild.sh - functions to extract information from PKGBUILD files
  3259. #
  3260. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3261. #
  3262. # This program is free software; you can redistribute it and/or modify
  3263. # it under the terms of the GNU General Public License as published by
  3264. # the Free Software Foundation; either version 2 of the License, or
  3265. # (at your option) any later version.
  3266. #
  3267. # This program is distributed in the hope that it will be useful,
  3268. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3269. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3270. # GNU General Public License for more details.
  3271. #
  3272. # You should have received a copy of the GNU General Public License
  3273. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3274. #
  3275.  
  3276. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  3277. ++++ [[ -n 1 ]]
  3278. ++++ return
  3279. source "$LIBRARY/lint_pkgbuild/util.sh"
  3280. +++ source /usr/share/makepkg/lint_pkgbuild/util.sh
  3281. #!/usr/bin/bash
  3282. #
  3283. # util.sh - utility functions for pkgbuild linting.
  3284. #
  3285. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3286. #
  3287. # This program is free software; you can redistribute it and/or modify
  3288. # it under the terms of the GNU General Public License as published by
  3289. # the Free Software Foundation; either version 2 of the License, or
  3290. # (at your option) any later version.
  3291. #
  3292. # This program is distributed in the hope that it will be useful,
  3293. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3294. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3295. # GNU General Public License for more details.
  3296. #
  3297. # You should have received a copy of the GNU General Public License
  3298. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3299. #
  3300.  
  3301. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_UTIL_SH" ]] && return
  3302. ++++ [[ -n 1 ]]
  3303. ++++ return
  3304.  
  3305.  
  3306. lint_pkgbuild_functions+=('lint_install')
  3307. +++ lint_pkgbuild_functions+=('lint_install')
  3308.  
  3309.  
  3310. lint_install() {
  3311. local list file name install_list ret=0
  3312.  
  3313. install_list=("${install[@]}")
  3314. for name in "${pkgname[@]}"; do
  3315. extract_function_variable "package_$name" install 0 file
  3316. install_list+=("$file")
  3317. done
  3318.  
  3319. check_files_exist 'install' "${install_list[@]}" || ret=1
  3320.  
  3321. return $ret
  3322. }
  3323. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  3324. ++ source /usr/share/makepkg/lint_pkgbuild/makedepends.sh
  3325. #!/usr/bin/bash
  3326. #
  3327. # makedepends.sh - Check the 'makedepends' array conforms to requirements.
  3328. #
  3329. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3330. #
  3331. # This program is free software; you can redistribute it and/or modify
  3332. # it under the terms of the GNU General Public License as published by
  3333. # the Free Software Foundation; either version 2 of the License, or
  3334. # (at your option) any later version.
  3335. #
  3336. # This program is distributed in the hope that it will be useful,
  3337. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3338. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3339. # GNU General Public License for more details.
  3340. #
  3341. # You should have received a copy of the GNU General Public License
  3342. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3343. #
  3344.  
  3345. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_MAKEDEPENDS_SH" ]] && return
  3346. +++ [[ -n '' ]]
  3347. LIBMAKEPKG_LINT_PKGBUILD_MAKEDEPENDS_SH=1
  3348. +++ LIBMAKEPKG_LINT_PKGBUILD_MAKEDEPENDS_SH=1
  3349.  
  3350. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  3351. +++ LIBRARY=/usr/share/makepkg
  3352.  
  3353. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  3354. +++ source /usr/share/makepkg/lint_pkgbuild/pkgname.sh
  3355. #!/usr/bin/bash
  3356. #
  3357. # pkgname.sh - Check the 'pkgname' variable conforms to requirements.
  3358. #
  3359. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3360. #
  3361. # This program is free software; you can redistribute it and/or modify
  3362. # it under the terms of the GNU General Public License as published by
  3363. # the Free Software Foundation; either version 2 of the License, or
  3364. # (at your option) any later version.
  3365. #
  3366. # This program is distributed in the hope that it will be useful,
  3367. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3368. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3369. # GNU General Public License for more details.
  3370. #
  3371. # You should have received a copy of the GNU General Public License
  3372. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3373. #
  3374.  
  3375. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH" ]] && return
  3376. ++++ [[ -n 1 ]]
  3377. ++++ return
  3378. source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  3379. +++ source /usr/share/makepkg/lint_pkgbuild/pkgver.sh
  3380. #!/usr/bin/bash
  3381. #
  3382. # pkgver.sh - Check the 'pkgver' variable conforms to requirements.
  3383. #
  3384. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3385. #
  3386. # This program is free software; you can redistribute it and/or modify
  3387. # it under the terms of the GNU General Public License as published by
  3388. # the Free Software Foundation; either version 2 of the License, or
  3389. # (at your option) any later version.
  3390. #
  3391. # This program is distributed in the hope that it will be useful,
  3392. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3393. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3394. # GNU General Public License for more details.
  3395. #
  3396. # You should have received a copy of the GNU General Public License
  3397. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3398. #
  3399.  
  3400. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH" ]] && return
  3401. ++++ [[ -n 1 ]]
  3402. ++++ return
  3403. source "$LIBRARY/util/message.sh"
  3404. +++ source /usr/share/makepkg/util/message.sh
  3405. #!/usr/bin/bash
  3406. #
  3407. # message.sh - functions for outputting messages in makepkg
  3408. #
  3409. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3410. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3411. #
  3412. # This program is free software; you can redistribute it and/or modify
  3413. # it under the terms of the GNU General Public License as published by
  3414. # the Free Software Foundation; either version 2 of the License, or
  3415. # (at your option) any later version.
  3416. #
  3417. # This program is distributed in the hope that it will be useful,
  3418. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3419. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3420. # GNU General Public License for more details.
  3421. #
  3422. # You should have received a copy of the GNU General Public License
  3423. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3424. #
  3425.  
  3426. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  3427. ++++ [[ -n 1 ]]
  3428. ++++ return
  3429. source "$LIBRARY/util/pkgbuild.sh"
  3430. +++ source /usr/share/makepkg/util/pkgbuild.sh
  3431. #!/usr/bin/bash
  3432. #
  3433. # pkgbuild.sh - functions to extract information from PKGBUILD files
  3434. #
  3435. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3436. #
  3437. # This program is free software; you can redistribute it and/or modify
  3438. # it under the terms of the GNU General Public License as published by
  3439. # the Free Software Foundation; either version 2 of the License, or
  3440. # (at your option) any later version.
  3441. #
  3442. # This program is distributed in the hope that it will be useful,
  3443. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3444. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3445. # GNU General Public License for more details.
  3446. #
  3447. # You should have received a copy of the GNU General Public License
  3448. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3449. #
  3450.  
  3451. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  3452. ++++ [[ -n 1 ]]
  3453. ++++ return
  3454.  
  3455.  
  3456. lint_pkgbuild_functions+=('lint_makedepends')
  3457. +++ lint_pkgbuild_functions+=('lint_makedepends')
  3458.  
  3459.  
  3460. lint_makedepends() {
  3461. local makedepends_list makedepend name ver ret=0
  3462.  
  3463. get_pkgbuild_all_split_attributes makedepends makedepends_list
  3464.  
  3465. # this function requires extglob - save current status to restore later
  3466. local shellopts=$(shopt -p extglob)
  3467. shopt -s extglob
  3468.  
  3469. for makedepend in "${makedepends_list[@]}"; do
  3470. name=${makedepend%%@(<|>|=|>=|<=)*}
  3471. # remove optional epoch in version specifier
  3472. ver=${makedepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  3473. lint_one_pkgname makedepends "$name" || ret=1
  3474. if [[ $ver != $makedepend ]]; then
  3475. # remove optional pkgrel in version specifier
  3476. check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" makedepends || ret=1
  3477. fi
  3478. done
  3479.  
  3480. eval "$shellopts"
  3481.  
  3482. return $ret
  3483. }
  3484. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  3485. ++ source /usr/share/makepkg/lint_pkgbuild/optdepends.sh
  3486. #!/usr/bin/bash
  3487. #
  3488. # optdepends.sh - Check the 'optdepends' array conforms to requirements.
  3489. #
  3490. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3491. #
  3492. # This program is free software; you can redistribute it and/or modify
  3493. # it under the terms of the GNU General Public License as published by
  3494. # the Free Software Foundation; either version 2 of the License, or
  3495. # (at your option) any later version.
  3496. #
  3497. # This program is distributed in the hope that it will be useful,
  3498. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3499. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3500. # GNU General Public License for more details.
  3501. #
  3502. # You should have received a copy of the GNU General Public License
  3503. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3504. #
  3505.  
  3506. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_OPTDEPENDS_SH" ]] && return
  3507. +++ [[ -n '' ]]
  3508. LIBMAKEPKG_LINT_PKGBUILD_OPTDEPENDS_SH=1
  3509. +++ LIBMAKEPKG_LINT_PKGBUILD_OPTDEPENDS_SH=1
  3510.  
  3511. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  3512. +++ LIBRARY=/usr/share/makepkg
  3513.  
  3514. source "$LIBRARY/util/message.sh"
  3515. +++ source /usr/share/makepkg/util/message.sh
  3516. #!/usr/bin/bash
  3517. #
  3518. # message.sh - functions for outputting messages in makepkg
  3519. #
  3520. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3521. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3522. #
  3523. # This program is free software; you can redistribute it and/or modify
  3524. # it under the terms of the GNU General Public License as published by
  3525. # the Free Software Foundation; either version 2 of the License, or
  3526. # (at your option) any later version.
  3527. #
  3528. # This program is distributed in the hope that it will be useful,
  3529. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3530. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3531. # GNU General Public License for more details.
  3532. #
  3533. # You should have received a copy of the GNU General Public License
  3534. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3535. #
  3536.  
  3537. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  3538. ++++ [[ -n 1 ]]
  3539. ++++ return
  3540. source "$LIBRARY/util/pkgbuild.sh"
  3541. +++ source /usr/share/makepkg/util/pkgbuild.sh
  3542. #!/usr/bin/bash
  3543. #
  3544. # pkgbuild.sh - functions to extract information from PKGBUILD files
  3545. #
  3546. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3547. #
  3548. # This program is free software; you can redistribute it and/or modify
  3549. # it under the terms of the GNU General Public License as published by
  3550. # the Free Software Foundation; either version 2 of the License, or
  3551. # (at your option) any later version.
  3552. #
  3553. # This program is distributed in the hope that it will be useful,
  3554. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3555. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3556. # GNU General Public License for more details.
  3557. #
  3558. # You should have received a copy of the GNU General Public License
  3559. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3560. #
  3561.  
  3562. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  3563. ++++ [[ -n 1 ]]
  3564. ++++ return
  3565.  
  3566.  
  3567. lint_pkgbuild_functions+=('lint_optdepends')
  3568. +++ lint_pkgbuild_functions+=('lint_optdepends')
  3569.  
  3570.  
  3571. lint_optdepends() {
  3572. local optdepends_list optdepend name ver ret=0
  3573.  
  3574. get_pkgbuild_all_split_attributes optdepends optdepends_list
  3575.  
  3576. # this function requires extglob - save current status to restore later
  3577. local shellopts=$(shopt -p extglob)
  3578. shopt -s extglob
  3579.  
  3580. for optdepend in "${optdepends_list[@]%%:[[:space:]]*}"; do
  3581. name=${optdepend%%@(<|>|=|>=|<=)*}
  3582. # remove optional epoch in version specifier
  3583. ver=${optdepend##$name@(<|>|=|>=|<=)?(+([0-9]):)}
  3584. lint_one_pkgname optdepends "$name" || ret=1
  3585. if [[ $ver != $optdepend ]]; then
  3586. # remove optional pkgrel in version specifier
  3587. check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" optdepends || ret=1
  3588. fi
  3589. done
  3590.  
  3591. return $ret
  3592. }
  3593. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  3594. ++ source /usr/share/makepkg/lint_pkgbuild/options.sh
  3595. #!/usr/bin/bash
  3596. #
  3597. # options.sh - Check the 'options' array conforms to requirements.
  3598. #
  3599. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3600. #
  3601. # This program is free software; you can redistribute it and/or modify
  3602. # it under the terms of the GNU General Public License as published by
  3603. # the Free Software Foundation; either version 2 of the License, or
  3604. # (at your option) any later version.
  3605. #
  3606. # This program is distributed in the hope that it will be useful,
  3607. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3608. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3609. # GNU General Public License for more details.
  3610. #
  3611. # You should have received a copy of the GNU General Public License
  3612. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3613. #
  3614.  
  3615. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_OPTIONS_SH" ]] && return
  3616. +++ [[ -n '' ]]
  3617. LIBMAKEPKG_LINT_PKGBUILD_OPTIONS_SH=1
  3618. +++ LIBMAKEPKG_LINT_PKGBUILD_OPTIONS_SH=1
  3619.  
  3620. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  3621. +++ LIBRARY=/usr/share/makepkg
  3622.  
  3623. source "$LIBRARY/util/message.sh"
  3624. +++ source /usr/share/makepkg/util/message.sh
  3625. #!/usr/bin/bash
  3626. #
  3627. # message.sh - functions for outputting messages in makepkg
  3628. #
  3629. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3630. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3631. #
  3632. # This program is free software; you can redistribute it and/or modify
  3633. # it under the terms of the GNU General Public License as published by
  3634. # the Free Software Foundation; either version 2 of the License, or
  3635. # (at your option) any later version.
  3636. #
  3637. # This program is distributed in the hope that it will be useful,
  3638. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3639. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3640. # GNU General Public License for more details.
  3641. #
  3642. # You should have received a copy of the GNU General Public License
  3643. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3644. #
  3645.  
  3646. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  3647. ++++ [[ -n 1 ]]
  3648. ++++ return
  3649. source "$LIBRARY/util/pkgbuild.sh"
  3650. +++ source /usr/share/makepkg/util/pkgbuild.sh
  3651. #!/usr/bin/bash
  3652. #
  3653. # pkgbuild.sh - functions to extract information from PKGBUILD files
  3654. #
  3655. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3656. #
  3657. # This program is free software; you can redistribute it and/or modify
  3658. # it under the terms of the GNU General Public License as published by
  3659. # the Free Software Foundation; either version 2 of the License, or
  3660. # (at your option) any later version.
  3661. #
  3662. # This program is distributed in the hope that it will be useful,
  3663. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3664. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3665. # GNU General Public License for more details.
  3666. #
  3667. # You should have received a copy of the GNU General Public License
  3668. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3669. #
  3670.  
  3671. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  3672. ++++ [[ -n 1 ]]
  3673. ++++ return
  3674.  
  3675.  
  3676. lint_pkgbuild_functions+=('lint_options')
  3677. +++ lint_pkgbuild_functions+=('lint_options')
  3678.  
  3679.  
  3680. lint_options() {
  3681. local ret=0 list name kopt options_list
  3682.  
  3683. options_list=("${options[@]}")
  3684. for name in "${pkgname[@]}"; do
  3685. if extract_function_variable "package_$name" options 1 list; then
  3686. options_list+=("${list[@]}")
  3687. fi
  3688. done
  3689.  
  3690. for i in "${options_list[@]}"; do
  3691. # check if option matches a known option or its inverse
  3692. for kopt in "${packaging_options[@]}" "${build_options[@]}"; do
  3693. if [[ $i = "$kopt" || $i = "!$kopt" ]]; then
  3694. # continue to the next $i
  3695. continue 2
  3696. fi
  3697. done
  3698.  
  3699. error "$(gettext "%s array contains unknown option '%s'")" "options" "$i"
  3700. ret=1
  3701. done
  3702.  
  3703. return $ret
  3704. }
  3705. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  3706. ++ source /usr/share/makepkg/lint_pkgbuild/package_function.sh
  3707. #!/usr/bin/bash
  3708. #
  3709. # package_function.sh - Check that required package functions exist.
  3710. #
  3711. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3712. #
  3713. # This program is free software; you can redistribute it and/or modify
  3714. # it under the terms of the GNU General Public License as published by
  3715. # the Free Software Foundation; either version 2 of the License, or
  3716. # (at your option) any later version.
  3717. #
  3718. # This program is distributed in the hope that it will be useful,
  3719. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3720. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3721. # GNU General Public License for more details.
  3722. #
  3723. # You should have received a copy of the GNU General Public License
  3724. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3725. #
  3726.  
  3727. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PACKAGE_FUNCTION_SH" ]] && return
  3728. +++ [[ -n '' ]]
  3729. LIBMAKEPKG_LINT_PKGBUILD_PACKAGE_FUNCTION_SH=1
  3730. +++ LIBMAKEPKG_LINT_PKGBUILD_PACKAGE_FUNCTION_SH=1
  3731.  
  3732. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  3733. +++ LIBRARY=/usr/share/makepkg
  3734.  
  3735. source "$LIBRARY/util/message.sh"
  3736. +++ source /usr/share/makepkg/util/message.sh
  3737. #!/usr/bin/bash
  3738. #
  3739. # message.sh - functions for outputting messages in makepkg
  3740. #
  3741. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3742. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3743. #
  3744. # This program is free software; you can redistribute it and/or modify
  3745. # it under the terms of the GNU General Public License as published by
  3746. # the Free Software Foundation; either version 2 of the License, or
  3747. # (at your option) any later version.
  3748. #
  3749. # This program is distributed in the hope that it will be useful,
  3750. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3751. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3752. # GNU General Public License for more details.
  3753. #
  3754. # You should have received a copy of the GNU General Public License
  3755. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3756. #
  3757.  
  3758. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  3759. ++++ [[ -n 1 ]]
  3760. ++++ return
  3761. source "$LIBRARY/util/pkgbuild.sh"
  3762. +++ source /usr/share/makepkg/util/pkgbuild.sh
  3763. #!/usr/bin/bash
  3764. #
  3765. # pkgbuild.sh - functions to extract information from PKGBUILD files
  3766. #
  3767. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3768. #
  3769. # This program is free software; you can redistribute it and/or modify
  3770. # it under the terms of the GNU General Public License as published by
  3771. # the Free Software Foundation; either version 2 of the License, or
  3772. # (at your option) any later version.
  3773. #
  3774. # This program is distributed in the hope that it will be useful,
  3775. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3776. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3777. # GNU General Public License for more details.
  3778. #
  3779. # You should have received a copy of the GNU General Public License
  3780. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3781. #
  3782.  
  3783. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  3784. ++++ [[ -n 1 ]]
  3785. ++++ return
  3786.  
  3787.  
  3788. lint_pkgbuild_functions+=('lint_package_function')
  3789. +++ lint_pkgbuild_functions+=('lint_package_function')
  3790.  
  3791.  
  3792. lint_package_function() {
  3793. local i ret=0
  3794.  
  3795. if (( ${#pkgname[@]} == 1 )); then
  3796. if have_function 'build' && ! { have_function 'package' || have_function "package_$pkgname"; }; then
  3797. error "$(gettext "Missing %s function in %s")" "package()" "$BUILDFILE"
  3798. ret=1
  3799. fi
  3800. else
  3801. for i in "${pkgname[@]}"; do
  3802. if ! have_function "package_$i"; then
  3803. error "$(gettext "Missing %s function for split package '%s'")" "package_$i()" "$i"
  3804. ret=1
  3805. fi
  3806. done
  3807. fi
  3808.  
  3809. return $ret
  3810. }
  3811. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  3812. ++ source /usr/share/makepkg/lint_pkgbuild/pkgbase.sh
  3813. #!/usr/bin/bash
  3814. #
  3815. # pkgbase.sh - Check the 'pkgbase' variable conforms to requirements.
  3816. #
  3817. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3818. #
  3819. # This program is free software; you can redistribute it and/or modify
  3820. # it under the terms of the GNU General Public License as published by
  3821. # the Free Software Foundation; either version 2 of the License, or
  3822. # (at your option) any later version.
  3823. #
  3824. # This program is distributed in the hope that it will be useful,
  3825. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3826. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3827. # GNU General Public License for more details.
  3828. #
  3829. # You should have received a copy of the GNU General Public License
  3830. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3831. #
  3832.  
  3833. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGBASE_SH" ]] && return
  3834. +++ [[ -n '' ]]
  3835. LIBMAKEPKG_LINT_PKGBUILD_PKGBASE_SH=1
  3836. +++ LIBMAKEPKG_LINT_PKGBUILD_PKGBASE_SH=1
  3837.  
  3838. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  3839. +++ LIBRARY=/usr/share/makepkg
  3840.  
  3841. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  3842. +++ source /usr/share/makepkg/lint_pkgbuild/pkgname.sh
  3843. #!/usr/bin/bash
  3844. #
  3845. # pkgname.sh - Check the 'pkgname' variable conforms to requirements.
  3846. #
  3847. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3848. #
  3849. # This program is free software; you can redistribute it and/or modify
  3850. # it under the terms of the GNU General Public License as published by
  3851. # the Free Software Foundation; either version 2 of the License, or
  3852. # (at your option) any later version.
  3853. #
  3854. # This program is distributed in the hope that it will be useful,
  3855. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3856. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3857. # GNU General Public License for more details.
  3858. #
  3859. # You should have received a copy of the GNU General Public License
  3860. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3861. #
  3862.  
  3863. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH" ]] && return
  3864. ++++ [[ -n 1 ]]
  3865. ++++ return
  3866. source "$LIBRARY/util/message.sh"
  3867. +++ source /usr/share/makepkg/util/message.sh
  3868. #!/usr/bin/bash
  3869. #
  3870. # message.sh - functions for outputting messages in makepkg
  3871. #
  3872. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3873. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3874. #
  3875. # This program is free software; you can redistribute it and/or modify
  3876. # it under the terms of the GNU General Public License as published by
  3877. # the Free Software Foundation; either version 2 of the License, or
  3878. # (at your option) any later version.
  3879. #
  3880. # This program is distributed in the hope that it will be useful,
  3881. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3882. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3883. # GNU General Public License for more details.
  3884. #
  3885. # You should have received a copy of the GNU General Public License
  3886. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3887. #
  3888.  
  3889. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  3890. ++++ [[ -n 1 ]]
  3891. ++++ return
  3892.  
  3893.  
  3894. lint_pkgbuild_functions+=('lint_pkgbase')
  3895. +++ lint_pkgbuild_functions+=('lint_pkgbase')
  3896.  
  3897.  
  3898. lint_pkgbase() {
  3899. if [[ -z $pkgbase ]]; then
  3900. return 0
  3901. fi
  3902.  
  3903. lint_one_pkgname "pkgbase" "$pkgbase"
  3904. }
  3905. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  3906. ++ source /usr/share/makepkg/lint_pkgbuild/pkglist.sh
  3907. #!/usr/bin/bash
  3908. #
  3909. # pkglist.sh - Check the packages selected to build exist.
  3910. #
  3911. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3912. #
  3913. # This program is free software; you can redistribute it and/or modify
  3914. # it under the terms of the GNU General Public License as published by
  3915. # the Free Software Foundation; either version 2 of the License, or
  3916. # (at your option) any later version.
  3917. #
  3918. # This program is distributed in the hope that it will be useful,
  3919. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3920. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3921. # GNU General Public License for more details.
  3922. #
  3923. # You should have received a copy of the GNU General Public License
  3924. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3925. #
  3926.  
  3927. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGLIST_SH" ]] && return
  3928. +++ [[ -n '' ]]
  3929. LIBMAKEPKG_LINT_PKGBUILD_PKGLIST_SH=1
  3930. +++ LIBMAKEPKG_LINT_PKGBUILD_PKGLIST_SH=1
  3931.  
  3932. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  3933. +++ LIBRARY=/usr/share/makepkg
  3934.  
  3935. source "$LIBRARY/util/message.sh"
  3936. +++ source /usr/share/makepkg/util/message.sh
  3937. #!/usr/bin/bash
  3938. #
  3939. # message.sh - functions for outputting messages in makepkg
  3940. #
  3941. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3942. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3943. #
  3944. # This program is free software; you can redistribute it and/or modify
  3945. # it under the terms of the GNU General Public License as published by
  3946. # the Free Software Foundation; either version 2 of the License, or
  3947. # (at your option) any later version.
  3948. #
  3949. # This program is distributed in the hope that it will be useful,
  3950. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3951. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3952. # GNU General Public License for more details.
  3953. #
  3954. # You should have received a copy of the GNU General Public License
  3955. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3956. #
  3957.  
  3958. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  3959. ++++ [[ -n 1 ]]
  3960. ++++ return
  3961. source "$LIBRARY/util/util.sh"
  3962. +++ source /usr/share/makepkg/util/util.sh
  3963. #!/usr/bin/bash
  3964. #
  3965. # util.sh - general utility functions
  3966. #
  3967. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  3968. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  3969. #
  3970. # This program is free software; you can redistribute it and/or modify
  3971. # it under the terms of the GNU General Public License as published by
  3972. # the Free Software Foundation; either version 2 of the License, or
  3973. # (at your option) any later version.
  3974. #
  3975. # This program is distributed in the hope that it will be useful,
  3976. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  3977. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3978. # GNU General Public License for more details.
  3979. #
  3980. # You should have received a copy of the GNU General Public License
  3981. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  3982. #
  3983.  
  3984. [[ -n "$LIBMAKEPKG_UTIL_UTIL_SH" ]] && return
  3985. ++++ [[ -n 1 ]]
  3986. ++++ return
  3987.  
  3988.  
  3989. lint_pkgbuild_functions+=('lint_pkglist')
  3990. +++ lint_pkgbuild_functions+=('lint_pkglist')
  3991.  
  3992.  
  3993. lint_pkglist() {
  3994. local i ret=0
  3995.  
  3996. for i in "${PKGLIST[@]}"; do
  3997. if ! in_array "$i" "${pkgname[@]}"; then
  3998. error "$(gettext "Requested package %s is not provided in %s")" "$i" "$BUILDFILE"
  3999. ret=1
  4000. fi
  4001. done
  4002.  
  4003. return $ret
  4004. }
  4005. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  4006. ++ source /usr/share/makepkg/lint_pkgbuild/pkgname.sh
  4007. #!/usr/bin/bash
  4008. #
  4009. # pkgname.sh - Check the 'pkgname' variable conforms to requirements.
  4010. #
  4011. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4012. #
  4013. # This program is free software; you can redistribute it and/or modify
  4014. # it under the terms of the GNU General Public License as published by
  4015. # the Free Software Foundation; either version 2 of the License, or
  4016. # (at your option) any later version.
  4017. #
  4018. # This program is distributed in the hope that it will be useful,
  4019. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4020. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4021. # GNU General Public License for more details.
  4022. #
  4023. # You should have received a copy of the GNU General Public License
  4024. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4025. #
  4026.  
  4027. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH" ]] && return
  4028. +++ [[ -n 1 ]]
  4029. +++ return
  4030. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  4031. ++ source /usr/share/makepkg/lint_pkgbuild/pkgrel.sh
  4032. #!/usr/bin/bash
  4033. #
  4034. # pkgrel.sh - Check the 'pkgrel' variable conforms to requirements.
  4035. #
  4036. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4037. #
  4038. # This program is free software; you can redistribute it and/or modify
  4039. # it under the terms of the GNU General Public License as published by
  4040. # the Free Software Foundation; either version 2 of the License, or
  4041. # (at your option) any later version.
  4042. #
  4043. # This program is distributed in the hope that it will be useful,
  4044. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4045. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4046. # GNU General Public License for more details.
  4047. #
  4048. # You should have received a copy of the GNU General Public License
  4049. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4050. #
  4051.  
  4052. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGREL_SH" ]] && return
  4053. +++ [[ -n '' ]]
  4054. LIBMAKEPKG_LINT_PKGBUILD_PKGREL_SH=1
  4055. +++ LIBMAKEPKG_LINT_PKGBUILD_PKGREL_SH=1
  4056.  
  4057. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  4058. +++ LIBRARY=/usr/share/makepkg
  4059.  
  4060. source "$LIBRARY/util/message.sh"
  4061. +++ source /usr/share/makepkg/util/message.sh
  4062. #!/usr/bin/bash
  4063. #
  4064. # message.sh - functions for outputting messages in makepkg
  4065. #
  4066. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4067. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  4068. #
  4069. # This program is free software; you can redistribute it and/or modify
  4070. # it under the terms of the GNU General Public License as published by
  4071. # the Free Software Foundation; either version 2 of the License, or
  4072. # (at your option) any later version.
  4073. #
  4074. # This program is distributed in the hope that it will be useful,
  4075. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4076. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4077. # GNU General Public License for more details.
  4078. #
  4079. # You should have received a copy of the GNU General Public License
  4080. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4081. #
  4082.  
  4083. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  4084. ++++ [[ -n 1 ]]
  4085. ++++ return
  4086.  
  4087.  
  4088. lint_pkgbuild_functions+=('lint_pkgrel')
  4089. +++ lint_pkgbuild_functions+=('lint_pkgrel')
  4090.  
  4091.  
  4092. lint_pkgrel() {
  4093. if [[ -z $pkgrel ]]; then
  4094. error "$(gettext "%s is not allowed to be empty.")" "pkgrel"
  4095. return 1
  4096. fi
  4097.  
  4098. if [[ $pkgrel != +([0-9])?(.+([0-9])) ]]; then
  4099. error "$(gettext "%s must be a decimal, not %s.")" "pkgrel" "$pkgrel"
  4100. return 1
  4101. fi
  4102. }
  4103. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  4104. ++ source /usr/share/makepkg/lint_pkgbuild/pkgver.sh
  4105. #!/usr/bin/bash
  4106. #
  4107. # pkgver.sh - Check the 'pkgver' variable conforms to requirements.
  4108. #
  4109. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4110. #
  4111. # This program is free software; you can redistribute it and/or modify
  4112. # it under the terms of the GNU General Public License as published by
  4113. # the Free Software Foundation; either version 2 of the License, or
  4114. # (at your option) any later version.
  4115. #
  4116. # This program is distributed in the hope that it will be useful,
  4117. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4118. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4119. # GNU General Public License for more details.
  4120. #
  4121. # You should have received a copy of the GNU General Public License
  4122. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4123. #
  4124.  
  4125. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH" ]] && return
  4126. +++ [[ -n 1 ]]
  4127. +++ return
  4128. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  4129. ++ source /usr/share/makepkg/lint_pkgbuild/provides.sh
  4130. #!/usr/bin/bash
  4131. #
  4132. # provides.sh - Check the 'provides' array conforms to requirements.
  4133. #
  4134. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4135. #
  4136. # This program is free software; you can redistribute it and/or modify
  4137. # it under the terms of the GNU General Public License as published by
  4138. # the Free Software Foundation; either version 2 of the License, or
  4139. # (at your option) any later version.
  4140. #
  4141. # This program is distributed in the hope that it will be useful,
  4142. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4143. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4144. # GNU General Public License for more details.
  4145. #
  4146. # You should have received a copy of the GNU General Public License
  4147. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4148. #
  4149.  
  4150. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH" ]] && return
  4151. +++ [[ -n '' ]]
  4152. LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH=1
  4153. +++ LIBMAKEPKG_LINT_PKGBUILD_PROVIDES_SH=1
  4154.  
  4155. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  4156. +++ LIBRARY=/usr/share/makepkg
  4157.  
  4158. source "$LIBRARY/lint_pkgbuild/pkgname.sh"
  4159. +++ source /usr/share/makepkg/lint_pkgbuild/pkgname.sh
  4160. #!/usr/bin/bash
  4161. #
  4162. # pkgname.sh - Check the 'pkgname' variable conforms to requirements.
  4163. #
  4164. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4165. #
  4166. # This program is free software; you can redistribute it and/or modify
  4167. # it under the terms of the GNU General Public License as published by
  4168. # the Free Software Foundation; either version 2 of the License, or
  4169. # (at your option) any later version.
  4170. #
  4171. # This program is distributed in the hope that it will be useful,
  4172. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4173. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4174. # GNU General Public License for more details.
  4175. #
  4176. # You should have received a copy of the GNU General Public License
  4177. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4178. #
  4179.  
  4180. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGNAME_SH" ]] && return
  4181. ++++ [[ -n 1 ]]
  4182. ++++ return
  4183. source "$LIBRARY/lint_pkgbuild/pkgver.sh"
  4184. +++ source /usr/share/makepkg/lint_pkgbuild/pkgver.sh
  4185. #!/usr/bin/bash
  4186. #
  4187. # pkgver.sh - Check the 'pkgver' variable conforms to requirements.
  4188. #
  4189. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4190. #
  4191. # This program is free software; you can redistribute it and/or modify
  4192. # it under the terms of the GNU General Public License as published by
  4193. # the Free Software Foundation; either version 2 of the License, or
  4194. # (at your option) any later version.
  4195. #
  4196. # This program is distributed in the hope that it will be useful,
  4197. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4198. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4199. # GNU General Public License for more details.
  4200. #
  4201. # You should have received a copy of the GNU General Public License
  4202. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4203. #
  4204.  
  4205. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_PKGVER_SH" ]] && return
  4206. ++++ [[ -n 1 ]]
  4207. ++++ return
  4208. source "$LIBRARY/util/message.sh"
  4209. +++ source /usr/share/makepkg/util/message.sh
  4210. #!/usr/bin/bash
  4211. #
  4212. # message.sh - functions for outputting messages in makepkg
  4213. #
  4214. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4215. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  4216. #
  4217. # This program is free software; you can redistribute it and/or modify
  4218. # it under the terms of the GNU General Public License as published by
  4219. # the Free Software Foundation; either version 2 of the License, or
  4220. # (at your option) any later version.
  4221. #
  4222. # This program is distributed in the hope that it will be useful,
  4223. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4224. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4225. # GNU General Public License for more details.
  4226. #
  4227. # You should have received a copy of the GNU General Public License
  4228. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4229. #
  4230.  
  4231. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  4232. ++++ [[ -n 1 ]]
  4233. ++++ return
  4234. source "$LIBRARY/util/pkgbuild.sh"
  4235. +++ source /usr/share/makepkg/util/pkgbuild.sh
  4236. #!/usr/bin/bash
  4237. #
  4238. # pkgbuild.sh - functions to extract information from PKGBUILD files
  4239. #
  4240. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4241. #
  4242. # This program is free software; you can redistribute it and/or modify
  4243. # it under the terms of the GNU General Public License as published by
  4244. # the Free Software Foundation; either version 2 of the License, or
  4245. # (at your option) any later version.
  4246. #
  4247. # This program is distributed in the hope that it will be useful,
  4248. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4249. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4250. # GNU General Public License for more details.
  4251. #
  4252. # You should have received a copy of the GNU General Public License
  4253. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4254. #
  4255.  
  4256. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  4257. ++++ [[ -n 1 ]]
  4258. ++++ return
  4259.  
  4260.  
  4261. lint_pkgbuild_functions+=('lint_provides')
  4262. +++ lint_pkgbuild_functions+=('lint_provides')
  4263.  
  4264.  
  4265. lint_provides() {
  4266. local provides_list provide name ver ret=0
  4267.  
  4268. get_pkgbuild_all_split_attributes provides provides_list
  4269.  
  4270. # this function requires extglob - save current status to restore later
  4271. local shellopts=$(shopt -p extglob)
  4272. shopt -s extglob
  4273.  
  4274. for provide in "${provides_list[@]}"; do
  4275. if [[ $provide == *['<>']* ]]; then
  4276. error "$(gettext "%s array cannot contain comparison (< or >) operators.")" "provides"
  4277. ret=1
  4278. continue
  4279. fi
  4280. name=${provide%=*}
  4281. # remove optional epoch in version specifier
  4282. ver=${provide##$name=?(+([0-9]):)}
  4283. lint_one_pkgname provides "$name" || ret=1
  4284. if [[ $ver != $provide ]]; then
  4285. # remove optional pkgrel in version specifier
  4286. check_pkgver "${ver%-+([0-9])?(.+([0-9]))}" provides || ret=1
  4287. fi
  4288. done
  4289.  
  4290. eval "$shellopts"
  4291.  
  4292. return $ret
  4293. }
  4294. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  4295. ++ source /usr/share/makepkg/lint_pkgbuild/source.sh
  4296. #!/usr/bin/bash
  4297. #
  4298. # source.sh - Check the 'source' array is not sparse.
  4299. #
  4300. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4301. #
  4302. # This program is free software; you can redistribute it and/or modify
  4303. # it under the terms of the GNU General Public License as published by
  4304. # the Free Software Foundation; either version 2 of the License, or
  4305. # (at your option) any later version.
  4306. #
  4307. # This program is distributed in the hope that it will be useful,
  4308. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4309. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4310. # GNU General Public License for more details.
  4311. #
  4312. # You should have received a copy of the GNU General Public License
  4313. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4314. #
  4315.  
  4316. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_SOURCE_SH" ]] && return
  4317. +++ [[ -n '' ]]
  4318. LIBMAKEPKG_LINT_PKGBUILD_SOURCE_SH=1
  4319. +++ LIBMAKEPKG_LINT_PKGBUILD_SOURCE_SH=1
  4320.  
  4321. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  4322. +++ LIBRARY=/usr/share/makepkg
  4323.  
  4324. source "$LIBRARY/util/message.sh"
  4325. +++ source /usr/share/makepkg/util/message.sh
  4326. #!/usr/bin/bash
  4327. #
  4328. # message.sh - functions for outputting messages in makepkg
  4329. #
  4330. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4331. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  4332. #
  4333. # This program is free software; you can redistribute it and/or modify
  4334. # it under the terms of the GNU General Public License as published by
  4335. # the Free Software Foundation; either version 2 of the License, or
  4336. # (at your option) any later version.
  4337. #
  4338. # This program is distributed in the hope that it will be useful,
  4339. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4340. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4341. # GNU General Public License for more details.
  4342. #
  4343. # You should have received a copy of the GNU General Public License
  4344. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4345. #
  4346.  
  4347. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  4348. ++++ [[ -n 1 ]]
  4349. ++++ return
  4350.  
  4351.  
  4352. lint_pkgbuild_functions+=('lint_source')
  4353. +++ lint_pkgbuild_functions+=('lint_source')
  4354.  
  4355.  
  4356. lint_source() {
  4357. local idx=("${!source[@]}")
  4358.  
  4359. if (( ${#source[*]} > 0 && (${idx[@]: -1} + 1) != ${#source[*]} )); then
  4360. error "$(gettext "Sparse arrays are not allowed for source")"
  4361. return 1
  4362. fi
  4363. }
  4364. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  4365. ++ source /usr/share/makepkg/lint_pkgbuild/util.sh
  4366. #!/usr/bin/bash
  4367. #
  4368. # util.sh - utility functions for pkgbuild linting.
  4369. #
  4370. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4371. #
  4372. # This program is free software; you can redistribute it and/or modify
  4373. # it under the terms of the GNU General Public License as published by
  4374. # the Free Software Foundation; either version 2 of the License, or
  4375. # (at your option) any later version.
  4376. #
  4377. # This program is distributed in the hope that it will be useful,
  4378. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4379. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4380. # GNU General Public License for more details.
  4381. #
  4382. # You should have received a copy of the GNU General Public License
  4383. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4384. #
  4385.  
  4386. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_UTIL_SH" ]] && return
  4387. +++ [[ -n 1 ]]
  4388. +++ return
  4389. ++ for lib in "$LIBRARY/lint_pkgbuild/"*.sh
  4390. ++ source /usr/share/makepkg/lint_pkgbuild/variable.sh
  4391. #!/usr/bin/bash
  4392. #
  4393. # variable.sh - Check that variables are or are not arrays as appropriate
  4394. #
  4395. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4396. #
  4397. # This program is free software; you can redistribute it and/or modify
  4398. # it under the terms of the GNU General Public License as published by
  4399. # the Free Software Foundation; either version 2 of the License, or
  4400. # (at your option) any later version.
  4401. #
  4402. # This program is distributed in the hope that it will be useful,
  4403. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4404. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4405. # GNU General Public License for more details.
  4406. #
  4407. # You should have received a copy of the GNU General Public License
  4408. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4409. #
  4410.  
  4411. [[ -n "$LIBMAKEPKG_LINT_PKGBUILD_VARIABLE_SH" ]] && return
  4412. +++ [[ -n '' ]]
  4413. LIBMAKEPKG_LINT_PKGBUILD_VARIABLE_SH=1
  4414. +++ LIBMAKEPKG_LINT_PKGBUILD_VARIABLE_SH=1
  4415.  
  4416. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  4417. +++ LIBRARY=/usr/share/makepkg
  4418.  
  4419. source "$LIBRARY/util/message.sh"
  4420. +++ source /usr/share/makepkg/util/message.sh
  4421. #!/usr/bin/bash
  4422. #
  4423. # message.sh - functions for outputting messages in makepkg
  4424. #
  4425. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4426. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  4427. #
  4428. # This program is free software; you can redistribute it and/or modify
  4429. # it under the terms of the GNU General Public License as published by
  4430. # the Free Software Foundation; either version 2 of the License, or
  4431. # (at your option) any later version.
  4432. #
  4433. # This program is distributed in the hope that it will be useful,
  4434. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4435. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4436. # GNU General Public License for more details.
  4437. #
  4438. # You should have received a copy of the GNU General Public License
  4439. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4440. #
  4441.  
  4442. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  4443. ++++ [[ -n 1 ]]
  4444. ++++ return
  4445. source "$LIBRARY/util/pkgbuild.sh"
  4446. +++ source /usr/share/makepkg/util/pkgbuild.sh
  4447. #!/usr/bin/bash
  4448. #
  4449. # pkgbuild.sh - functions to extract information from PKGBUILD files
  4450. #
  4451. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4452. #
  4453. # This program is free software; you can redistribute it and/or modify
  4454. # it under the terms of the GNU General Public License as published by
  4455. # the Free Software Foundation; either version 2 of the License, or
  4456. # (at your option) any later version.
  4457. #
  4458. # This program is distributed in the hope that it will be useful,
  4459. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4460. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4461. # GNU General Public License for more details.
  4462. #
  4463. # You should have received a copy of the GNU General Public License
  4464. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4465. #
  4466.  
  4467. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  4468. ++++ [[ -n 1 ]]
  4469. ++++ return
  4470.  
  4471. lint_pkgbuild_functions+=('lint_variable')
  4472. +++ lint_pkgbuild_functions+=('lint_variable')
  4473.  
  4474.  
  4475. lint_variable() {
  4476. # TODO: refactor - similar arrays are used elsewhere
  4477. local array=(arch backup checkdepends groups license noextract options
  4478. validpgpkeys)
  4479. local arch_array=(conflicts depends makedepends md5sums optdepends provides
  4480. replaces sha1sums sha224sums sha256sums sha384sums sha512sums
  4481. source)
  4482. local string=(changelog epoch install pkgdesc pkgrel pkgver url)
  4483.  
  4484. local i a v pkg keys out bad ret=0
  4485.  
  4486. # global variables
  4487. for i in ${array[@]} ${arch_array[@]}; do
  4488. eval "keys=(\"\${!$i[@]}\")"
  4489. if (( ${#keys[*]} > 0 )); then
  4490. if ! is_array $i; then
  4491. error "$(gettext "%s should be an array")" "$i"
  4492. ret=1
  4493. fi
  4494. fi
  4495. done
  4496.  
  4497. for a in ${arch[@]}; do
  4498. [[ $a == "any" ]] && continue
  4499.  
  4500. for i in ${arch_array[@]}; do
  4501. v="${i}_${a}"
  4502. eval "keys=(\"\${!${v}[@]}\")"
  4503. if (( ${#keys[*]} > 0 )); then
  4504. if ! is_array $v; then
  4505. error "$(gettext "%s_%s should be an array")" "$i" "$a"
  4506. ret=1
  4507. fi
  4508. fi
  4509. done
  4510. done
  4511.  
  4512. for i in ${string[@]}; do
  4513. eval "keys=(\"\${!$i[@]}\")"
  4514. if (( ${#keys[*]} > 0 )); then
  4515. if is_array $i; then
  4516. error "$(gettext "%s should not be an array")" "$i"
  4517. ret=1
  4518. fi
  4519. fi
  4520. done
  4521.  
  4522. # package function variables
  4523. for pkg in ${pkgname[@]}; do
  4524. for i in ${array[@]} ${arch_array[@]}; do
  4525. if extract_function_variable "package_$pkg" $i 0 out; then
  4526. error "$(gettext "%s should be an array")" "$i"
  4527. ret=1
  4528. fi
  4529. done
  4530.  
  4531. for a in ${arch[@]}; do
  4532. [[ $a == "any" ]] && continue
  4533.  
  4534. for i in ${arch_array[@]}; do
  4535. if extract_function_variable "package_$pkg" "${i}_${a}" 0 out; then
  4536. error "$(gettext "%s_%s should be an array")" "$i" "$a"
  4537. ret=1
  4538. fi
  4539. done
  4540. done
  4541.  
  4542. for i in ${string[@]}; do
  4543. if extract_function_variable "package_$pkg" $i 1 out; then
  4544. error "$(gettext "%s should not be an array")" "$i"
  4545. ret=1
  4546. fi
  4547. done
  4548. done
  4549.  
  4550. return $ret
  4551. }
  4552.  
  4553. readonly -a lint_pkgbuild_functions
  4554. ++ readonly -a lint_pkgbuild_functions
  4555.  
  4556.  
  4557. lint_pkgbuild() {
  4558. local ret=0
  4559.  
  4560. for func in ${lint_pkgbuild_functions[@]}; do
  4561. $func || ret=1
  4562. done
  4563.  
  4564. return $ret
  4565. }
  4566. + for lib in "$LIBRARY"/*.sh
  4567. + source /usr/share/makepkg/source.sh
  4568. #!/usr/bin/bash
  4569. #
  4570. # source.sh - functions for downloading and extracting sources
  4571. #
  4572. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4573. #
  4574. # This program is free software; you can redistribute it and/or modify
  4575. # it under the terms of the GNU General Public License as published by
  4576. # the Free Software Foundation; either version 2 of the License, or
  4577. # (at your option) any later version.
  4578. #
  4579. # This program is distributed in the hope that it will be useful,
  4580. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4581. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4582. # GNU General Public License for more details.
  4583. #
  4584. # You should have received a copy of the GNU General Public License
  4585. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4586. #
  4587.  
  4588. [[ -n "$LIBMAKEPKG_SOURCE_SH" ]] && return
  4589. ++ [[ -n '' ]]
  4590. LIBMAKEPKG_SOURCE_SH=1
  4591. ++ LIBMAKEPKG_SOURCE_SH=1
  4592.  
  4593. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  4594. ++ LIBRARY=/usr/share/makepkg
  4595.  
  4596. source "$LIBRARY/util/message.sh"
  4597. ++ source /usr/share/makepkg/util/message.sh
  4598. #!/usr/bin/bash
  4599. #
  4600. # message.sh - functions for outputting messages in makepkg
  4601. #
  4602. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4603. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  4604. #
  4605. # This program is free software; you can redistribute it and/or modify
  4606. # it under the terms of the GNU General Public License as published by
  4607. # the Free Software Foundation; either version 2 of the License, or
  4608. # (at your option) any later version.
  4609. #
  4610. # This program is distributed in the hope that it will be useful,
  4611. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4612. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4613. # GNU General Public License for more details.
  4614. #
  4615. # You should have received a copy of the GNU General Public License
  4616. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4617. #
  4618.  
  4619. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  4620. +++ [[ -n 1 ]]
  4621. +++ return
  4622. source "$LIBRARY/util/pkgbuild.sh"
  4623. ++ source /usr/share/makepkg/util/pkgbuild.sh
  4624. #!/usr/bin/bash
  4625. #
  4626. # pkgbuild.sh - functions to extract information from PKGBUILD files
  4627. #
  4628. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4629. #
  4630. # This program is free software; you can redistribute it and/or modify
  4631. # it under the terms of the GNU General Public License as published by
  4632. # the Free Software Foundation; either version 2 of the License, or
  4633. # (at your option) any later version.
  4634. #
  4635. # This program is distributed in the hope that it will be useful,
  4636. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4637. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4638. # GNU General Public License for more details.
  4639. #
  4640. # You should have received a copy of the GNU General Public License
  4641. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4642. #
  4643.  
  4644. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  4645. +++ [[ -n 1 ]]
  4646. +++ return
  4647. source "$LIBRARY/util/source.sh"
  4648. ++ source /usr/share/makepkg/util/source.sh
  4649. #!/usr/bin/bash
  4650. #
  4651. # source.sh - functions to extract information from source URLs
  4652. #
  4653. # Copyright (c) 2010-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4654. #
  4655. # This program is free software; you can redistribute it and/or modify
  4656. # it under the terms of the GNU General Public License as published by
  4657. # the Free Software Foundation; either version 2 of the License, or
  4658. # (at your option) any later version.
  4659. #
  4660. # This program is distributed in the hope that it will be useful,
  4661. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4662. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4663. # GNU General Public License for more details.
  4664. #
  4665. # You should have received a copy of the GNU General Public License
  4666. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4667. #
  4668.  
  4669. [[ -n "$LIBMAKEPKG_UTIL_SOURCE_SH" ]] && return
  4670. +++ [[ -n '' ]]
  4671. LIBMAKEPKG_UTIL_SOURCE_SH=1
  4672. +++ LIBMAKEPKG_UTIL_SOURCE_SH=1
  4673.  
  4674. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  4675. +++ LIBRARY=/usr/share/makepkg
  4676.  
  4677. source "$LIBRARY/util/message.sh"
  4678. +++ source /usr/share/makepkg/util/message.sh
  4679. #!/usr/bin/bash
  4680. #
  4681. # message.sh - functions for outputting messages in makepkg
  4682. #
  4683. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4684. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  4685. #
  4686. # This program is free software; you can redistribute it and/or modify
  4687. # it under the terms of the GNU General Public License as published by
  4688. # the Free Software Foundation; either version 2 of the License, or
  4689. # (at your option) any later version.
  4690. #
  4691. # This program is distributed in the hope that it will be useful,
  4692. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4693. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4694. # GNU General Public License for more details.
  4695. #
  4696. # You should have received a copy of the GNU General Public License
  4697. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4698. #
  4699.  
  4700. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  4701. ++++ [[ -n 1 ]]
  4702. ++++ return
  4703.  
  4704.  
  4705. # a source entry can have two forms :
  4706. # 1) "filename::http://path/to/file"
  4707. # 2) "http://path/to/file"
  4708.  
  4709. # extract the URL from a source entry
  4710. get_url() {
  4711. # strip an eventual filename
  4712. printf "%s\n" "${1#*::}"
  4713. }
  4714.  
  4715. # extract the protocol from a source entry - return "local" for local sources
  4716. get_protocol() {
  4717. if [[ $1 = *://* ]]; then
  4718. # strip leading filename
  4719. local proto="${1#*::}"
  4720. printf "%s\n" "${proto%%://*}"
  4721. elif [[ $1 = *lp:* ]]; then
  4722. local proto="${1#*::}"
  4723. printf "%s\n" "${proto%%lp:*}"
  4724. else
  4725. printf "%s\n" local
  4726. fi
  4727. }
  4728.  
  4729. # extract the filename from a source entry
  4730. get_filename() {
  4731. local netfile=$1
  4732.  
  4733. # if a filename is specified, use it
  4734. if [[ $netfile = *::* ]]; then
  4735. printf "%s\n" ${netfile%%::*}
  4736. return
  4737. fi
  4738.  
  4739. local proto=$(get_protocol "$netfile")
  4740.  
  4741. case $proto in
  4742. bzr*|git*|hg*|svn*)
  4743. filename=${netfile%%#*}
  4744. filename=${filename%%\?*}
  4745. filename=${filename%/}
  4746. filename=${filename##*/}
  4747. if [[ $proto = bzr* ]]; then
  4748. filename=${filename#*lp:}
  4749. fi
  4750. if [[ $proto = git* ]]; then
  4751. filename=${filename%%.git*}
  4752. fi
  4753. ;;
  4754. *)
  4755. # if it is just an URL, we only keep the last component
  4756. filename="${netfile##*/}"
  4757. ;;
  4758. esac
  4759. printf "%s\n" "${filename}"
  4760. }
  4761.  
  4762. # Return the absolute filename of a source entry
  4763. get_filepath() {
  4764. local file="$(get_filename "$1")"
  4765. local proto="$(get_protocol "$1")"
  4766.  
  4767. case $proto in
  4768. bzr*|git*|hg*|svn*)
  4769. if [[ -d "$startdir/$file" ]]; then
  4770. file="$startdir/$file"
  4771. elif [[ -d "$SRCDEST/$file" ]]; then
  4772. file="$SRCDEST/$file"
  4773. else
  4774. return 1
  4775. fi
  4776. ;;
  4777. *)
  4778. if [[ -f "$startdir/$file" ]]; then
  4779. file="$startdir/$file"
  4780. elif [[ -f "$SRCDEST/$file" ]]; then
  4781. file="$SRCDEST/$file"
  4782. else
  4783. return 1
  4784. fi
  4785. ;;
  4786. esac
  4787.  
  4788. printf "%s\n" "$file"
  4789. }
  4790.  
  4791. # extract the VCS revision/branch specifier from a source entry
  4792. get_uri_fragment() {
  4793. local netfile=$1
  4794.  
  4795. local fragment=${netfile#*#}
  4796. if [[ $fragment = "$netfile" ]]; then
  4797. unset fragment
  4798. fi
  4799. fragment=${fragment%\?*}
  4800.  
  4801. printf "%s\n" "$fragment"
  4802. }
  4803.  
  4804. # extract the VCS "signed" status from a source entry
  4805. get_uri_query() {
  4806. local netfile=$1
  4807.  
  4808. local query=${netfile#*\?}
  4809. if [[ $query = "$netfile" ]]; then
  4810. unset query
  4811. fi
  4812. query=${query%#*}
  4813.  
  4814. printf "%s\n" "$query"
  4815. }
  4816.  
  4817. get_downloadclient() {
  4818. local proto=$1
  4819.  
  4820. # loop through DOWNLOAD_AGENTS variable looking for protocol
  4821. local i
  4822. for i in "${DLAGENTS[@]}"; do
  4823. local handler="${i%%::*}"
  4824. if [[ $proto = "$handler" ]]; then
  4825. local agent="${i#*::}"
  4826. break
  4827. fi
  4828. done
  4829.  
  4830. # if we didn't find an agent, return an error
  4831. if [[ -z $agent ]]; then
  4832. error "$(gettext "Unknown download protocol: %s")" "$proto"
  4833. plain "$(gettext "Aborting...")"
  4834. exit 1 # $E_CONFIG_ERROR
  4835. fi
  4836.  
  4837. # ensure specified program is installed
  4838. local program="${agent%% *}"
  4839. if [[ ! -x $program ]]; then
  4840. local baseprog="${program##*/}"
  4841. error "$(gettext "The download program %s is not installed.")" "$baseprog"
  4842. plain "$(gettext "Aborting...")"
  4843. exit 1 # $E_MISSING_PROGRAM
  4844. fi
  4845.  
  4846. printf "%s\n" "$agent"
  4847. }
  4848.  
  4849.  
  4850. for lib in "$LIBRARY/source/"*.sh; do
  4851. source "$lib"
  4852. done
  4853. ++ for lib in "$LIBRARY/source/"*.sh
  4854. ++ source /usr/share/makepkg/source/bzr.sh
  4855. #!/usr/bin/bash
  4856. #
  4857. # bzr.sh - function for handling the download and "extraction" of Bazaar sources
  4858. #
  4859. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4860. #
  4861. # This program is free software; you can redistribute it and/or modify
  4862. # it under the terms of the GNU General Public License as published by
  4863. # the Free Software Foundation; either version 2 of the License, or
  4864. # (at your option) any later version.
  4865. #
  4866. # This program is distributed in the hope that it will be useful,
  4867. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4868. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4869. # GNU General Public License for more details.
  4870. #
  4871. # You should have received a copy of the GNU General Public License
  4872. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4873. #
  4874.  
  4875. [[ -n "$LIBMAKEPKG_SOURCE_BZR_SH" ]] && return
  4876. +++ [[ -n '' ]]
  4877. LIBMAKEPKG_SOURCE_BZR_SH=1
  4878. +++ LIBMAKEPKG_SOURCE_BZR_SH=1
  4879.  
  4880.  
  4881. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  4882. +++ LIBRARY=/usr/share/makepkg
  4883.  
  4884. source "$LIBRARY/util/message.sh"
  4885. +++ source /usr/share/makepkg/util/message.sh
  4886. #!/usr/bin/bash
  4887. #
  4888. # message.sh - functions for outputting messages in makepkg
  4889. #
  4890. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4891. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  4892. #
  4893. # This program is free software; you can redistribute it and/or modify
  4894. # it under the terms of the GNU General Public License as published by
  4895. # the Free Software Foundation; either version 2 of the License, or
  4896. # (at your option) any later version.
  4897. #
  4898. # This program is distributed in the hope that it will be useful,
  4899. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4900. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4901. # GNU General Public License for more details.
  4902. #
  4903. # You should have received a copy of the GNU General Public License
  4904. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4905. #
  4906.  
  4907. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  4908. ++++ [[ -n 1 ]]
  4909. ++++ return
  4910. source "$LIBRARY/util/pkgbuild.sh"
  4911. +++ source /usr/share/makepkg/util/pkgbuild.sh
  4912. #!/usr/bin/bash
  4913. #
  4914. # pkgbuild.sh - functions to extract information from PKGBUILD files
  4915. #
  4916. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  4917. #
  4918. # This program is free software; you can redistribute it and/or modify
  4919. # it under the terms of the GNU General Public License as published by
  4920. # the Free Software Foundation; either version 2 of the License, or
  4921. # (at your option) any later version.
  4922. #
  4923. # This program is distributed in the hope that it will be useful,
  4924. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  4925. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4926. # GNU General Public License for more details.
  4927. #
  4928. # You should have received a copy of the GNU General Public License
  4929. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  4930. #
  4931.  
  4932. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  4933. ++++ [[ -n 1 ]]
  4934. ++++ return
  4935.  
  4936.  
  4937. download_bzr() {
  4938. local netfile=$1
  4939.  
  4940. local url=$(get_url "$netfile")
  4941. if [[ $url != bzr+ssh* ]]; then
  4942. url=${url#bzr+}
  4943. fi
  4944. url=${url%%#*}
  4945.  
  4946. local repo=$(get_filename "$netfile")
  4947. local displaylocation="$url"
  4948.  
  4949. local dir=$(get_filepath "$netfile")
  4950. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  4951.  
  4952. if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
  4953. msg2 "$(gettext "Branching %s...")" "${displaylocation}"
  4954. if ! bzr branch "$url" "$dir" --no-tree --use-existing-dir; then
  4955. error "$(gettext "Failure while branching %s")" "${displaylocation}"
  4956. plain "$(gettext "Aborting...")"
  4957. exit 1
  4958. fi
  4959. elif (( ! HOLDVER )); then
  4960. msg2 "$(gettext "Pulling %s...")" "${displaylocation}"
  4961. cd_safe "$dir"
  4962. if ! bzr pull "$url"; then
  4963. # only warn on failure to allow offline builds
  4964. warning "$(gettext "Failure while pulling %s")" "${displaylocation}"
  4965. fi
  4966. fi
  4967. }
  4968.  
  4969. extract_bzr() {
  4970. local netfile=$1
  4971.  
  4972. local repo=$(get_filename "$netfile")
  4973. local fragment=${netfile#*#}
  4974. if [[ $fragment = "$netfile" ]]; then
  4975. unset fragment
  4976. fi
  4977.  
  4978. rev="last:1"
  4979. if [[ -n $fragment ]]; then
  4980. case ${fragment%%=*} in
  4981. revision)
  4982. rev="${fragment#*=}"
  4983. displaylocation="$url -r ${fragment#*=}"
  4984. ;;
  4985. *)
  4986. error "$(gettext "Unrecognized reference: %s")" "${fragment}"
  4987. plain "$(gettext "Aborting...")"
  4988. exit 1
  4989. esac
  4990. fi
  4991.  
  4992. local dir=$(get_filepath "$netfile")
  4993. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  4994.  
  4995. msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "bzr"
  4996. pushd "$srcdir" &>/dev/null
  4997.  
  4998. if [[ -d "${dir##*/}" ]]; then
  4999. cd_safe "${dir##*/}"
  5000. if ! (bzr pull "$dir" -q --overwrite -r "$rev" && bzr clean-tree -q --detritus --force); then
  5001. error "$(gettext "Failure while updating working copy of %s %s repo")" "${repo}" "bzr"
  5002. plain "$(gettext "Aborting...")"
  5003. exit 1
  5004. fi
  5005. elif ! bzr checkout "$dir" -r "$rev"; then
  5006. error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "bzr"
  5007. plain "$(gettext "Aborting...")"
  5008. exit 1
  5009. fi
  5010.  
  5011. popd &>/dev/null
  5012. }
  5013. ++ for lib in "$LIBRARY/source/"*.sh
  5014. ++ source /usr/share/makepkg/source/file.sh
  5015. #!/usr/bin/bash
  5016. #
  5017. # file.sh - function for handling the download and extraction of source files
  5018. #
  5019. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5020. #
  5021. # This program is free software; you can redistribute it and/or modify
  5022. # it under the terms of the GNU General Public License as published by
  5023. # the Free Software Foundation; either version 2 of the License, or
  5024. # (at your option) any later version.
  5025. #
  5026. # This program is distributed in the hope that it will be useful,
  5027. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5028. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5029. # GNU General Public License for more details.
  5030. #
  5031. # You should have received a copy of the GNU General Public License
  5032. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5033. #
  5034.  
  5035. [[ -n "$LIBMAKEPKG_SOURCE_FILE_SH" ]] && return
  5036. +++ [[ -n '' ]]
  5037. LIBMAKEPKG_SOURCE_FILE_SH=1
  5038. +++ LIBMAKEPKG_SOURCE_FILE_SH=1
  5039.  
  5040.  
  5041. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  5042. +++ LIBRARY=/usr/share/makepkg
  5043.  
  5044. source "$LIBRARY/util/message.sh"
  5045. +++ source /usr/share/makepkg/util/message.sh
  5046. #!/usr/bin/bash
  5047. #
  5048. # message.sh - functions for outputting messages in makepkg
  5049. #
  5050. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5051. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  5052. #
  5053. # This program is free software; you can redistribute it and/or modify
  5054. # it under the terms of the GNU General Public License as published by
  5055. # the Free Software Foundation; either version 2 of the License, or
  5056. # (at your option) any later version.
  5057. #
  5058. # This program is distributed in the hope that it will be useful,
  5059. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5060. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5061. # GNU General Public License for more details.
  5062. #
  5063. # You should have received a copy of the GNU General Public License
  5064. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5065. #
  5066.  
  5067. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  5068. ++++ [[ -n 1 ]]
  5069. ++++ return
  5070. source "$LIBRARY/util/pkgbuild.sh"
  5071. +++ source /usr/share/makepkg/util/pkgbuild.sh
  5072. #!/usr/bin/bash
  5073. #
  5074. # pkgbuild.sh - functions to extract information from PKGBUILD files
  5075. #
  5076. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5077. #
  5078. # This program is free software; you can redistribute it and/or modify
  5079. # it under the terms of the GNU General Public License as published by
  5080. # the Free Software Foundation; either version 2 of the License, or
  5081. # (at your option) any later version.
  5082. #
  5083. # This program is distributed in the hope that it will be useful,
  5084. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5085. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5086. # GNU General Public License for more details.
  5087. #
  5088. # You should have received a copy of the GNU General Public License
  5089. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5090. #
  5091.  
  5092. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  5093. ++++ [[ -n 1 ]]
  5094. ++++ return
  5095.  
  5096.  
  5097. download_file() {
  5098. local netfile=$1
  5099.  
  5100. local filepath=$(get_filepath "$netfile")
  5101. if [[ -n "$filepath" ]]; then
  5102. msg2 "$(gettext "Found %s")" "${filepath##*/}"
  5103. return
  5104. fi
  5105.  
  5106. local proto=$(get_protocol "$netfile")
  5107.  
  5108. # find the client we should use for this URL
  5109. local -a cmdline
  5110. IFS=' ' read -a cmdline < <(get_downloadclient "$proto")
  5111. (( ${#cmdline[@]} )) || exit
  5112.  
  5113. local filename=$(get_filename "$netfile")
  5114. local url=$(get_url "$netfile")
  5115.  
  5116. if [[ $proto = "scp" ]]; then
  5117. # scp downloads should not pass the protocol in the url
  5118. url="${url##*://}"
  5119. fi
  5120.  
  5121. msg2 "$(gettext "Downloading %s...")" "$filename"
  5122.  
  5123. # temporary download file, default to last component of the URL
  5124. local dlfile="${url##*/}"
  5125.  
  5126. # replace %o by the temporary dlfile if it exists
  5127. if [[ ${cmdline[*]} = *%o* ]]; then
  5128. dlfile=$filename.part
  5129. cmdline=("${cmdline[@]//%o/$dlfile}")
  5130. fi
  5131. # add the URL, either in place of %u or at the end
  5132. if [[ ${cmdline[*]} = *%u* ]]; then
  5133. cmdline=("${cmdline[@]//%u/$url}")
  5134. else
  5135. cmdline+=("$url")
  5136. fi
  5137.  
  5138. if ! command -- "${cmdline[@]}" >&2; then
  5139. [[ ! -s $dlfile ]] && rm -f -- "$dlfile"
  5140. error "$(gettext "Failure while downloading %s")" "$url"
  5141. plain "$(gettext "Aborting...")"
  5142. exit 1
  5143. fi
  5144.  
  5145. # rename the temporary download file to the final destination
  5146. if [[ $dlfile != "$filename" ]]; then
  5147. mv -f "$SRCDEST/$dlfile" "$SRCDEST/$filename"
  5148. fi
  5149. }
  5150.  
  5151. extract_file() {
  5152. local file=$1
  5153.  
  5154. local filepath=$(get_filepath "$file")
  5155. rm -f "$srcdir/${file}"
  5156. ln -s "$filepath" "$srcdir/"
  5157.  
  5158. if in_array "$file" "${noextract[@]}"; then
  5159. # skip source files in the noextract=() array
  5160. # these are marked explicitly to NOT be extracted
  5161. return 0
  5162. fi
  5163.  
  5164. # do not rely on extension for file type
  5165. local file_type=$(file -bizL -- "$file")
  5166. local ext=${file##*.}
  5167. local cmd=''
  5168. case "$file_type" in
  5169. *application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*)
  5170. cmd="bsdtar" ;;
  5171. *application/x-gzip*)
  5172. case "$ext" in
  5173. gz|z|Z) cmd="gzip" ;;
  5174. *) return;;
  5175. esac ;;
  5176. *application/x-bzip*)
  5177. case "$ext" in
  5178. bz2|bz) cmd="bzip2" ;;
  5179. *) return;;
  5180. esac ;;
  5181. *application/x-xz*)
  5182. case "$ext" in
  5183. xz) cmd="xz" ;;
  5184. *) return;;
  5185. esac ;;
  5186. *)
  5187. # See if bsdtar can recognize the file
  5188. if bsdtar -tf "$file" -q '*' &>/dev/null; then
  5189. cmd="bsdtar"
  5190. else
  5191. return 0
  5192. fi ;;
  5193. esac
  5194.  
  5195. local ret=0
  5196. msg2 "$(gettext "Extracting %s with %s")" "$file" "$cmd"
  5197. if [[ $cmd = "bsdtar" ]]; then
  5198. $cmd -xf "$file" || ret=$?
  5199. else
  5200. rm -f -- "${file%.*}"
  5201. $cmd -dcf -- "$file" > "${file%.*}" || ret=$?
  5202. fi
  5203. if (( ret )); then
  5204. error "$(gettext "Failed to extract %s")" "$file"
  5205. plain "$(gettext "Aborting...")"
  5206. exit 1
  5207. fi
  5208.  
  5209. if (( EUID == 0 )); then
  5210. # change perms of all source files to root user & root group
  5211. chown -R 0:0 "$srcdir"
  5212. fi
  5213. }
  5214. ++ for lib in "$LIBRARY/source/"*.sh
  5215. ++ source /usr/share/makepkg/source/git.sh
  5216. #!/usr/bin/bash
  5217. #
  5218. # git.sh - function for handling the download and "extraction" of Git sources
  5219. #
  5220. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5221. #
  5222. # This program is free software; you can redistribute it and/or modify
  5223. # it under the terms of the GNU General Public License as published by
  5224. # the Free Software Foundation; either version 2 of the License, or
  5225. # (at your option) any later version.
  5226. #
  5227. # This program is distributed in the hope that it will be useful,
  5228. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5229. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5230. # GNU General Public License for more details.
  5231. #
  5232. # You should have received a copy of the GNU General Public License
  5233. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5234. #
  5235.  
  5236. [[ -n "$LIBMAKEPKG_SOURCE_GIT_SH" ]] && return
  5237. +++ [[ -n '' ]]
  5238. LIBMAKEPKG_SOURCE_GIT_SH=1
  5239. +++ LIBMAKEPKG_SOURCE_GIT_SH=1
  5240.  
  5241.  
  5242. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  5243. +++ LIBRARY=/usr/share/makepkg
  5244.  
  5245. source "$LIBRARY/util/message.sh"
  5246. +++ source /usr/share/makepkg/util/message.sh
  5247. #!/usr/bin/bash
  5248. #
  5249. # message.sh - functions for outputting messages in makepkg
  5250. #
  5251. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5252. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  5253. #
  5254. # This program is free software; you can redistribute it and/or modify
  5255. # it under the terms of the GNU General Public License as published by
  5256. # the Free Software Foundation; either version 2 of the License, or
  5257. # (at your option) any later version.
  5258. #
  5259. # This program is distributed in the hope that it will be useful,
  5260. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5261. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5262. # GNU General Public License for more details.
  5263. #
  5264. # You should have received a copy of the GNU General Public License
  5265. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5266. #
  5267.  
  5268. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  5269. ++++ [[ -n 1 ]]
  5270. ++++ return
  5271. source "$LIBRARY/util/pkgbuild.sh"
  5272. +++ source /usr/share/makepkg/util/pkgbuild.sh
  5273. #!/usr/bin/bash
  5274. #
  5275. # pkgbuild.sh - functions to extract information from PKGBUILD files
  5276. #
  5277. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5278. #
  5279. # This program is free software; you can redistribute it and/or modify
  5280. # it under the terms of the GNU General Public License as published by
  5281. # the Free Software Foundation; either version 2 of the License, or
  5282. # (at your option) any later version.
  5283. #
  5284. # This program is distributed in the hope that it will be useful,
  5285. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5286. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5287. # GNU General Public License for more details.
  5288. #
  5289. # You should have received a copy of the GNU General Public License
  5290. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5291. #
  5292.  
  5293. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  5294. ++++ [[ -n 1 ]]
  5295. ++++ return
  5296.  
  5297.  
  5298. download_git() {
  5299. local netfile=$1
  5300.  
  5301. local dir=$(get_filepath "$netfile")
  5302. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  5303.  
  5304. local repo=$(get_filename "$netfile")
  5305.  
  5306. local url=$(get_url "$netfile")
  5307. url=${url#git+}
  5308. url=${url%%#*}
  5309. url=${url%%\?*}
  5310.  
  5311. if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
  5312. msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
  5313. if ! git clone --mirror "$url" "$dir"; then
  5314. error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
  5315. plain "$(gettext "Aborting...")"
  5316. exit 1
  5317. fi
  5318. elif (( ! HOLDVER )); then
  5319. cd_safe "$dir"
  5320. # Make sure we are fetching the right repo
  5321. if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then
  5322. error "$(gettext "%s is not a clone of %s")" "$dir" "$url"
  5323. plain "$(gettext "Aborting...")"
  5324. exit 1
  5325. fi
  5326. msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
  5327. if ! git fetch --all -p; then
  5328. # only warn on failure to allow offline builds
  5329. warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
  5330. fi
  5331. fi
  5332. }
  5333.  
  5334. extract_git() {
  5335. local netfile=$1 tagname
  5336.  
  5337. local fragment=$(get_uri_fragment "$netfile")
  5338. local repo=$(get_filename "$netfile")
  5339.  
  5340. local dir=$(get_filepath "$netfile")
  5341. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  5342.  
  5343. msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git"
  5344. pushd "$srcdir" &>/dev/null
  5345.  
  5346. local updating=0
  5347. if [[ -d "${dir##*/}" ]]; then
  5348. updating=1
  5349. cd_safe "${dir##*/}"
  5350. if ! git fetch; then
  5351. error "$(gettext "Failure while updating working copy of %s %s repo")" "${repo}" "git"
  5352. plain "$(gettext "Aborting...")"
  5353. exit 1
  5354. fi
  5355. cd_safe "$srcdir"
  5356. elif ! git clone "$dir" "${dir##*/}"; then
  5357. error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
  5358. plain "$(gettext "Aborting...")"
  5359. exit 1
  5360. fi
  5361.  
  5362. cd_safe "${dir##*/}"
  5363.  
  5364. local ref=origin/HEAD
  5365. if [[ -n $fragment ]]; then
  5366. case ${fragment%%=*} in
  5367. commit|tag)
  5368. ref=${fragment##*=}
  5369. ;;
  5370. branch)
  5371. ref=origin/${fragment##*=}
  5372. ;;
  5373. *)
  5374. error "$(gettext "Unrecognized reference: %s")" "${fragment}"
  5375. plain "$(gettext "Aborting...")"
  5376. exit 1
  5377. esac
  5378. fi
  5379.  
  5380. if [[ ${fragment%%=*} = tag ]]; then
  5381. tagname="$(git tag -l --format='%(tag)' "$ref")"
  5382. if [[ -n $tagname && $tagname != $ref ]]; then
  5383. error "$(gettext "Failure while checking out version %s, the git tag has been forged")" "$ref"
  5384. plain "$(gettext "Aborting...")"
  5385. exit 1
  5386. fi
  5387. fi
  5388.  
  5389. if [[ $ref != "origin/HEAD" ]] || (( updating )) ; then
  5390. if ! git checkout --force --no-track -B makepkg $ref; then
  5391. error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
  5392. plain "$(gettext "Aborting...")"
  5393. exit 1
  5394. fi
  5395. fi
  5396.  
  5397. popd &>/dev/null
  5398. }
  5399. ++ for lib in "$LIBRARY/source/"*.sh
  5400. ++ source /usr/share/makepkg/source/hg.sh
  5401. #!/usr/bin/bash
  5402. #
  5403. # hg.sh - function for handling the download and "extraction" of Mercurial sources
  5404. #
  5405. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5406. #
  5407. # This program is free software; you can redistribute it and/or modify
  5408. # it under the terms of the GNU General Public License as published by
  5409. # the Free Software Foundation; either version 2 of the License, or
  5410. # (at your option) any later version.
  5411. #
  5412. # This program is distributed in the hope that it will be useful,
  5413. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5414. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5415. # GNU General Public License for more details.
  5416. #
  5417. # You should have received a copy of the GNU General Public License
  5418. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5419. #
  5420.  
  5421. [[ -n "$LIBMAKEPKG_SOURCE_HG_SH" ]] && return
  5422. +++ [[ -n '' ]]
  5423. LIBMAKEPKG_SOURCE_HG_SH=1
  5424. +++ LIBMAKEPKG_SOURCE_HG_SH=1
  5425.  
  5426.  
  5427. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  5428. +++ LIBRARY=/usr/share/makepkg
  5429.  
  5430. source "$LIBRARY/util/message.sh"
  5431. +++ source /usr/share/makepkg/util/message.sh
  5432. #!/usr/bin/bash
  5433. #
  5434. # message.sh - functions for outputting messages in makepkg
  5435. #
  5436. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5437. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  5438. #
  5439. # This program is free software; you can redistribute it and/or modify
  5440. # it under the terms of the GNU General Public License as published by
  5441. # the Free Software Foundation; either version 2 of the License, or
  5442. # (at your option) any later version.
  5443. #
  5444. # This program is distributed in the hope that it will be useful,
  5445. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5446. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5447. # GNU General Public License for more details.
  5448. #
  5449. # You should have received a copy of the GNU General Public License
  5450. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5451. #
  5452.  
  5453. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  5454. ++++ [[ -n 1 ]]
  5455. ++++ return
  5456. source "$LIBRARY/util/pkgbuild.sh"
  5457. +++ source /usr/share/makepkg/util/pkgbuild.sh
  5458. #!/usr/bin/bash
  5459. #
  5460. # pkgbuild.sh - functions to extract information from PKGBUILD files
  5461. #
  5462. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5463. #
  5464. # This program is free software; you can redistribute it and/or modify
  5465. # it under the terms of the GNU General Public License as published by
  5466. # the Free Software Foundation; either version 2 of the License, or
  5467. # (at your option) any later version.
  5468. #
  5469. # This program is distributed in the hope that it will be useful,
  5470. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5471. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5472. # GNU General Public License for more details.
  5473. #
  5474. # You should have received a copy of the GNU General Public License
  5475. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5476. #
  5477.  
  5478. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  5479. ++++ [[ -n 1 ]]
  5480. ++++ return
  5481.  
  5482.  
  5483. download_hg() {
  5484. local netfile=$1
  5485.  
  5486. local dir=$(get_filepath "$netfile")
  5487. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  5488.  
  5489. local repo=$(get_filename "$netfile")
  5490.  
  5491. local url=$(get_url "$netfile")
  5492. url=${url#hg+}
  5493. url=${url%%#*}
  5494.  
  5495. if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
  5496. msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg"
  5497. if ! hg clone -U "$url" "$dir"; then
  5498. error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg"
  5499. plain "$(gettext "Aborting...")"
  5500. exit 1
  5501. fi
  5502. elif (( ! HOLDVER )); then
  5503. msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "hg"
  5504. cd_safe "$dir"
  5505. if ! hg pull; then
  5506. # only warn on failure to allow offline builds
  5507. warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg"
  5508. fi
  5509. fi
  5510. }
  5511.  
  5512. extract_hg() {
  5513. local netfile=$1
  5514.  
  5515. local fragment=${netfile#*#}
  5516. if [[ $fragment = "$netfile" ]]; then
  5517. unset fragment
  5518. fi
  5519.  
  5520. local dir=$(get_filepath "$netfile")
  5521. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  5522.  
  5523. local repo=${netfile##*/}
  5524. repo=${repo%%#*}
  5525.  
  5526. msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg"
  5527. pushd "$srcdir" &>/dev/null
  5528.  
  5529. local ref=tip
  5530. if [[ -n $fragment ]]; then
  5531. case ${fragment%%=*} in
  5532. branch|revision|tag)
  5533. ref="${fragment##*=}"
  5534. ;;
  5535. *)
  5536. error "$(gettext "Unrecognized reference: %s")" "${fragment}"
  5537. plain "$(gettext "Aborting...")"
  5538. exit 1
  5539. esac
  5540. fi
  5541.  
  5542. if [[ -d "${dir##*/}" ]]; then
  5543. cd_safe "${dir##*/}"
  5544. if ! (hg pull && hg update -C -r "$ref"); then
  5545. error "$(gettext "Failure while updating working copy of %s %s repo")" "${repo}" "hg"
  5546. plain "$(gettext "Aborting...")"
  5547. exit 1
  5548. fi
  5549. elif ! hg clone -u "$ref" "$dir" "${dir##*/}"; then
  5550. error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "hg"
  5551. plain "$(gettext "Aborting...")"
  5552. exit 1
  5553. fi
  5554.  
  5555. popd &>/dev/null
  5556. }
  5557. ++ for lib in "$LIBRARY/source/"*.sh
  5558. ++ source /usr/share/makepkg/source/local.sh
  5559. #!/usr/bin/bash
  5560. #
  5561. # local.sh - function for handling the "download" of local sources
  5562. #
  5563. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5564. #
  5565. # This program is free software; you can redistribute it and/or modify
  5566. # it under the terms of the GNU General Public License as published by
  5567. # the Free Software Foundation; either version 2 of the License, or
  5568. # (at your option) any later version.
  5569. #
  5570. # This program is distributed in the hope that it will be useful,
  5571. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5572. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5573. # GNU General Public License for more details.
  5574. #
  5575. # You should have received a copy of the GNU General Public License
  5576. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5577. #
  5578.  
  5579. [[ -n "$LIBMAKEPKG_SOURCE_LOCAL_SH" ]] && return
  5580. +++ [[ -n '' ]]
  5581. LIBMAKEPKG_SOURCE_LOCAL_SH=1
  5582. +++ LIBMAKEPKG_SOURCE_LOCAL_SH=1
  5583.  
  5584.  
  5585. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  5586. +++ LIBRARY=/usr/share/makepkg
  5587.  
  5588. source "$LIBRARY/util/message.sh"
  5589. +++ source /usr/share/makepkg/util/message.sh
  5590. #!/usr/bin/bash
  5591. #
  5592. # message.sh - functions for outputting messages in makepkg
  5593. #
  5594. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5595. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  5596. #
  5597. # This program is free software; you can redistribute it and/or modify
  5598. # it under the terms of the GNU General Public License as published by
  5599. # the Free Software Foundation; either version 2 of the License, or
  5600. # (at your option) any later version.
  5601. #
  5602. # This program is distributed in the hope that it will be useful,
  5603. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5604. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5605. # GNU General Public License for more details.
  5606. #
  5607. # You should have received a copy of the GNU General Public License
  5608. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5609. #
  5610.  
  5611. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  5612. ++++ [[ -n 1 ]]
  5613. ++++ return
  5614. source "$LIBRARY/util/pkgbuild.sh"
  5615. +++ source /usr/share/makepkg/util/pkgbuild.sh
  5616. #!/usr/bin/bash
  5617. #
  5618. # pkgbuild.sh - functions to extract information from PKGBUILD files
  5619. #
  5620. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5621. #
  5622. # This program is free software; you can redistribute it and/or modify
  5623. # it under the terms of the GNU General Public License as published by
  5624. # the Free Software Foundation; either version 2 of the License, or
  5625. # (at your option) any later version.
  5626. #
  5627. # This program is distributed in the hope that it will be useful,
  5628. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5629. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5630. # GNU General Public License for more details.
  5631. #
  5632. # You should have received a copy of the GNU General Public License
  5633. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5634. #
  5635.  
  5636. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  5637. ++++ [[ -n 1 ]]
  5638. ++++ return
  5639.  
  5640.  
  5641. download_local() {
  5642. local netfile=$1
  5643. local filepath=$(get_filepath "$netfile")
  5644.  
  5645. if [[ -n "$filepath" ]]; then
  5646. msg2 "$(gettext "Found %s")" "${filepath##*/}"
  5647. else
  5648. local filename=$(get_filename "$netfile")
  5649. error "$(gettext "%s was not found in the build directory and is not a URL.")" "$filename"
  5650. exit 1 # $E_MISSING_FILE
  5651. fi
  5652. }
  5653. ++ for lib in "$LIBRARY/source/"*.sh
  5654. ++ source /usr/share/makepkg/source/svn.sh
  5655. #!/usr/bin/bash
  5656. #
  5657. # svn.sh - function for handling the download and "extraction" of Subversion sources
  5658. #
  5659. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5660. #
  5661. # This program is free software; you can redistribute it and/or modify
  5662. # it under the terms of the GNU General Public License as published by
  5663. # the Free Software Foundation; either version 2 of the License, or
  5664. # (at your option) any later version.
  5665. #
  5666. # This program is distributed in the hope that it will be useful,
  5667. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5668. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5669. # GNU General Public License for more details.
  5670. #
  5671. # You should have received a copy of the GNU General Public License
  5672. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5673. #
  5674.  
  5675. [[ -n "$LIBMAKEPKG_SOURCE_SVN_SH" ]] && return
  5676. +++ [[ -n '' ]]
  5677. LIBMAKEPKG_SOURCE_SVN_SH=1
  5678. +++ LIBMAKEPKG_SOURCE_SVN_SH=1
  5679.  
  5680.  
  5681. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  5682. +++ LIBRARY=/usr/share/makepkg
  5683.  
  5684. source "$LIBRARY/util/message.sh"
  5685. +++ source /usr/share/makepkg/util/message.sh
  5686. #!/usr/bin/bash
  5687. #
  5688. # message.sh - functions for outputting messages in makepkg
  5689. #
  5690. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5691. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  5692. #
  5693. # This program is free software; you can redistribute it and/or modify
  5694. # it under the terms of the GNU General Public License as published by
  5695. # the Free Software Foundation; either version 2 of the License, or
  5696. # (at your option) any later version.
  5697. #
  5698. # This program is distributed in the hope that it will be useful,
  5699. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5700. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5701. # GNU General Public License for more details.
  5702. #
  5703. # You should have received a copy of the GNU General Public License
  5704. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5705. #
  5706.  
  5707. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  5708. ++++ [[ -n 1 ]]
  5709. ++++ return
  5710. source "$LIBRARY/util/pkgbuild.sh"
  5711. +++ source /usr/share/makepkg/util/pkgbuild.sh
  5712. #!/usr/bin/bash
  5713. #
  5714. # pkgbuild.sh - functions to extract information from PKGBUILD files
  5715. #
  5716. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5717. #
  5718. # This program is free software; you can redistribute it and/or modify
  5719. # it under the terms of the GNU General Public License as published by
  5720. # the Free Software Foundation; either version 2 of the License, or
  5721. # (at your option) any later version.
  5722. #
  5723. # This program is distributed in the hope that it will be useful,
  5724. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5725. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5726. # GNU General Public License for more details.
  5727. #
  5728. # You should have received a copy of the GNU General Public License
  5729. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5730. #
  5731.  
  5732. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  5733. ++++ [[ -n 1 ]]
  5734. ++++ return
  5735.  
  5736.  
  5737. download_svn() {
  5738. local netfile=$1
  5739.  
  5740. local fragment=${netfile#*#}
  5741. if [[ $fragment = "$netfile" ]]; then
  5742. unset fragment
  5743. fi
  5744.  
  5745. local dir=$(get_filepath "$netfile")
  5746. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  5747.  
  5748. local repo=$(get_filename "$netfile")
  5749.  
  5750. local url=$(get_url "$netfile")
  5751. if [[ $url != svn+ssh* ]]; then
  5752. url=${url#svn+}
  5753. fi
  5754. url=${url%%#*}
  5755.  
  5756. local ref=HEAD
  5757. if [[ -n $fragment ]]; then
  5758. case ${fragment%%=*} in
  5759. revision)
  5760. ref="${fragment##*=}"
  5761. ;;
  5762. *)
  5763. error "$(gettext "Unrecognized reference: %s")" "${fragment}"
  5764. plain "$(gettext "Aborting...")"
  5765. exit 1
  5766. esac
  5767. fi
  5768.  
  5769. if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
  5770. msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "svn"
  5771. mkdir -p "$dir/.makepkg"
  5772. if ! svn checkout -r ${ref} --config-dir "$dir/.makepkg" "$url" "$dir"; then
  5773. error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "svn"
  5774. plain "$(gettext "Aborting...")"
  5775. exit 1
  5776. fi
  5777. elif (( ! HOLDVER )); then
  5778. msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "svn"
  5779. cd_safe "$dir"
  5780. if ! svn update -r ${ref}; then
  5781. # only warn on failure to allow offline builds
  5782. warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn"
  5783. fi
  5784. fi
  5785. }
  5786.  
  5787. extract_svn() {
  5788. local netfile=$1
  5789.  
  5790. local dir=$(get_filepath "$netfile")
  5791. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  5792.  
  5793. local repo=${netfile##*/}
  5794. repo=${repo%%#*}
  5795.  
  5796. msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn"
  5797.  
  5798. cp -au "$dir" "$srcdir"
  5799. }
  5800.  
  5801.  
  5802. download_sources() {
  5803. local netfile all_sources
  5804. local get_source_fn=get_all_sources_for_arch get_vcs=1
  5805.  
  5806. msg "$(gettext "Retrieving sources...")"
  5807.  
  5808. while true; do
  5809. case $1 in
  5810. allarch)
  5811. get_source_fn=get_all_sources
  5812. ;;
  5813. novcs)
  5814. get_vcs=0
  5815. ;;
  5816. *)
  5817. break
  5818. ;;
  5819. esac
  5820. shift
  5821. done
  5822.  
  5823. "$get_source_fn" 'all_sources'
  5824. for netfile in "${all_sources[@]}"; do
  5825. pushd "$SRCDEST" &>/dev/null
  5826.  
  5827. local proto=$(get_protocol "$netfile")
  5828. case "$proto" in
  5829. local)
  5830. download_local "$netfile"
  5831. ;;
  5832. bzr*)
  5833. (( get_vcs )) && download_bzr "$netfile"
  5834. ;;
  5835. git*)
  5836. (( get_vcs )) && download_git "$netfile"
  5837. ;;
  5838. hg*)
  5839. (( get_vcs )) && download_hg "$netfile"
  5840. ;;
  5841. svn*)
  5842. (( get_vcs )) && download_svn "$netfile"
  5843. ;;
  5844. *)
  5845. download_file "$netfile"
  5846. ;;
  5847. esac
  5848.  
  5849. popd &>/dev/null
  5850. done
  5851. }
  5852.  
  5853. extract_sources() {
  5854. msg "$(gettext "Extracting sources...")"
  5855. local netfile all_sources
  5856.  
  5857. get_all_sources_for_arch 'all_sources'
  5858. for netfile in "${all_sources[@]}"; do
  5859. local file=$(get_filename "$netfile")
  5860. local proto=$(get_protocol "$netfile")
  5861. case "$proto" in
  5862. bzr*)
  5863. extract_bzr "$netfile"
  5864. ;;
  5865. git*)
  5866. extract_git "$netfile"
  5867. ;;
  5868. hg*)
  5869. extract_hg "$netfile"
  5870. ;;
  5871. svn*)
  5872. extract_svn "$netfile"
  5873. ;;
  5874. *)
  5875. extract_file "$file"
  5876. ;;
  5877. esac
  5878. done
  5879. }
  5880. + for lib in "$LIBRARY"/*.sh
  5881. + source /usr/share/makepkg/srcinfo.sh
  5882. #!/usr/bin/bash
  5883. #
  5884. # srcinfo.sh - functions for writing .SRCINFO files
  5885. #
  5886. # Copyright (c) 2014-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5887. #
  5888. # This program is free software; you can redistribute it and/or modify
  5889. # it under the terms of the GNU General Public License as published by
  5890. # the Free Software Foundation; either version 2 of the License, or
  5891. # (at your option) any later version.
  5892. #
  5893. # This program is distributed in the hope that it will be useful,
  5894. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5895. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5896. # GNU General Public License for more details.
  5897. #
  5898. # You should have received a copy of the GNU General Public License
  5899. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5900. #
  5901.  
  5902. [[ -n "$LIBMAKEPKG_SRCINFO_SH" ]] && return
  5903. ++ [[ -n '' ]]
  5904. LIBMAKEPKG_SRCINFO_SH=1
  5905. ++ LIBMAKEPKG_SRCINFO_SH=1
  5906.  
  5907. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  5908. ++ LIBRARY=/usr/share/makepkg
  5909.  
  5910. source "$LIBRARY/util/pkgbuild.sh"
  5911. ++ source /usr/share/makepkg/util/pkgbuild.sh
  5912. #!/usr/bin/bash
  5913. #
  5914. # pkgbuild.sh - functions to extract information from PKGBUILD files
  5915. #
  5916. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  5917. #
  5918. # This program is free software; you can redistribute it and/or modify
  5919. # it under the terms of the GNU General Public License as published by
  5920. # the Free Software Foundation; either version 2 of the License, or
  5921. # (at your option) any later version.
  5922. #
  5923. # This program is distributed in the hope that it will be useful,
  5924. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  5925. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  5926. # GNU General Public License for more details.
  5927. #
  5928. # You should have received a copy of the GNU General Public License
  5929. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  5930. #
  5931.  
  5932. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  5933. +++ [[ -n 1 ]]
  5934. +++ return
  5935.  
  5936. srcinfo_open_section() {
  5937. printf '%s = %s\n' "$1" "$2"
  5938. }
  5939.  
  5940. srcinfo_close_section() {
  5941. echo
  5942. }
  5943.  
  5944. srcinfo_write_attr() {
  5945. # $1: attr name
  5946. # $2: attr values
  5947.  
  5948. local attrname=$1 attrvalues=("${@:2}")
  5949.  
  5950. # normalize whitespace, strip leading and trailing
  5951. attrvalues=("${attrvalues[@]//+([[:space:]])/ }")
  5952. attrvalues=("${attrvalues[@]#[[:space:]]}")
  5953. attrvalues=("${attrvalues[@]%[[:space:]]}")
  5954.  
  5955. printf "\t$attrname = %s\n" "${attrvalues[@]}"
  5956. }
  5957.  
  5958. pkgbuild_extract_to_srcinfo() {
  5959. # $1: pkgname
  5960. # $2: attr name
  5961. # $3: multivalued
  5962.  
  5963. local pkgname=$1 attrname=$2 isarray=$3 outvalue=
  5964.  
  5965. if get_pkgbuild_attribute "$pkgname" "$attrname" "$isarray" 'outvalue'; then
  5966. srcinfo_write_attr "$attrname" "${outvalue[@]}"
  5967. fi
  5968. }
  5969.  
  5970. srcinfo_write_section_details() {
  5971. local attr package_arch a
  5972. local multivalued_arch_attrs=(source provides conflicts depends replaces
  5973. optdepends makedepends checkdepends
  5974. {md5,sha{1,224,256,384,512}}sums)
  5975.  
  5976. for attr in "${singlevalued[@]}"; do
  5977. pkgbuild_extract_to_srcinfo "$1" "$attr" 0
  5978. done
  5979.  
  5980. for attr in "${multivalued[@]}"; do
  5981. pkgbuild_extract_to_srcinfo "$1" "$attr" 1
  5982. done
  5983.  
  5984. get_pkgbuild_attribute "$1" 'arch' 1 'package_arch'
  5985. for a in "${package_arch[@]}"; do
  5986. # 'any' is special. there's no support for, e.g. depends_any.
  5987. [[ $a = any ]] && continue
  5988.  
  5989. for attr in "${multivalued_arch_attrs[@]}"; do
  5990. pkgbuild_extract_to_srcinfo "$1" "${attr}_$a" 1
  5991. done
  5992. done
  5993. }
  5994.  
  5995. srcinfo_write_global() {
  5996. local singlevalued=(pkgdesc pkgver pkgrel epoch url install changelog)
  5997. local multivalued=(arch groups license checkdepends makedepends
  5998. depends optdepends provides conflicts replaces
  5999. noextract options backup
  6000. source validpgpkeys {md5,sha{1,224,256,384,512}}sums)
  6001.  
  6002. srcinfo_open_section 'pkgbase' "${pkgbase:-$pkgname}"
  6003. srcinfo_write_section_details ''
  6004. srcinfo_close_section
  6005. }
  6006.  
  6007. srcinfo_write_package() {
  6008. local singlevalued=(pkgdesc url install changelog)
  6009. local multivalued=(arch groups license checkdepends depends optdepends
  6010. provides conflicts replaces options backup)
  6011.  
  6012. srcinfo_open_section 'pkgname' "$1"
  6013. srcinfo_write_section_details "$1"
  6014. srcinfo_close_section
  6015. }
  6016.  
  6017. write_srcinfo_header() {
  6018. printf "# Generated by makepkg %s\n" "$makepkg_version"
  6019. printf "# %s\n" "$(LC_ALL=C date -u)"
  6020. }
  6021.  
  6022. write_srcinfo_content() {
  6023. local pkg
  6024.  
  6025. srcinfo_write_global
  6026.  
  6027. for pkg in "${pkgname[@]}"; do
  6028. srcinfo_write_package "$pkg"
  6029. done
  6030. }
  6031.  
  6032. write_srcinfo() {
  6033. write_srcinfo_header
  6034. write_srcinfo_content
  6035. }
  6036. + for lib in "$LIBRARY"/*.sh
  6037. + source /usr/share/makepkg/tidy.sh
  6038. #!/usr/bin/bash
  6039. #
  6040. # tidy.sh - functions for modifying/removing installed files before
  6041. # package creation
  6042. #
  6043. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6044. #
  6045. # This program is free software; you can redistribute it and/or modify
  6046. # it under the terms of the GNU General Public License as published by
  6047. # the Free Software Foundation; either version 2 of the License, or
  6048. # (at your option) any later version.
  6049. #
  6050. # This program is distributed in the hope that it will be useful,
  6051. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6052. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6053. # GNU General Public License for more details.
  6054. #
  6055. # You should have received a copy of the GNU General Public License
  6056. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6057. #
  6058.  
  6059. [[ -n "$LIBMAKEPKG_TIDY_SH" ]] && return
  6060. ++ [[ -n '' ]]
  6061. LIBMAKEPKG_TIDY_SH=1
  6062. ++ LIBMAKEPKG_TIDY_SH=1
  6063.  
  6064. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  6065. ++ LIBRARY=/usr/share/makepkg
  6066.  
  6067. source "$LIBRARY/util/message.sh"
  6068. ++ source /usr/share/makepkg/util/message.sh
  6069. #!/usr/bin/bash
  6070. #
  6071. # message.sh - functions for outputting messages in makepkg
  6072. #
  6073. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6074. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  6075. #
  6076. # This program is free software; you can redistribute it and/or modify
  6077. # it under the terms of the GNU General Public License as published by
  6078. # the Free Software Foundation; either version 2 of the License, or
  6079. # (at your option) any later version.
  6080. #
  6081. # This program is distributed in the hope that it will be useful,
  6082. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6083. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6084. # GNU General Public License for more details.
  6085. #
  6086. # You should have received a copy of the GNU General Public License
  6087. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6088. #
  6089.  
  6090. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  6091. +++ [[ -n 1 ]]
  6092. +++ return
  6093.  
  6094.  
  6095. declare -a packaging_options tidy_remove tidy_modify
  6096. ++ declare -a packaging_options tidy_remove tidy_modify
  6097.  
  6098. for lib in "$LIBRARY/tidy/"*.sh; do
  6099. source "$lib"
  6100. done
  6101. ++ for lib in "$LIBRARY/tidy/"*.sh
  6102. ++ source /usr/share/makepkg/tidy/docs.sh
  6103. #!/usr/bin/bash
  6104. #
  6105. # docs.sh - Remove documentation files from the package
  6106. #
  6107. # Copyright (c) 2008-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6108. #
  6109. # This program is free software; you can redistribute it and/or modify
  6110. # it under the terms of the GNU General Public License as published by
  6111. # the Free Software Foundation; either version 2 of the License, or
  6112. # (at your option) any later version.
  6113. #
  6114. # This program is distributed in the hope that it will be useful,
  6115. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6116. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6117. # GNU General Public License for more details.
  6118. #
  6119. # You should have received a copy of the GNU General Public License
  6120. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6121. #
  6122.  
  6123. [[ -n "$LIBMAKEPKG_TIDY_DOCS_SH" ]] && return
  6124. +++ [[ -n '' ]]
  6125. LIBMAKEPKG_TIDY_DOCS_SH=1
  6126. +++ LIBMAKEPKG_TIDY_DOCS_SH=1
  6127.  
  6128. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  6129. +++ LIBRARY=/usr/share/makepkg
  6130.  
  6131. source "$LIBRARY/util/message.sh"
  6132. +++ source /usr/share/makepkg/util/message.sh
  6133. #!/usr/bin/bash
  6134. #
  6135. # message.sh - functions for outputting messages in makepkg
  6136. #
  6137. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6138. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  6139. #
  6140. # This program is free software; you can redistribute it and/or modify
  6141. # it under the terms of the GNU General Public License as published by
  6142. # the Free Software Foundation; either version 2 of the License, or
  6143. # (at your option) any later version.
  6144. #
  6145. # This program is distributed in the hope that it will be useful,
  6146. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6147. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6148. # GNU General Public License for more details.
  6149. #
  6150. # You should have received a copy of the GNU General Public License
  6151. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6152. #
  6153.  
  6154. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  6155. ++++ [[ -n 1 ]]
  6156. ++++ return
  6157. source "$LIBRARY/util/option.sh"
  6158. +++ source /usr/share/makepkg/util/option.sh
  6159. #!/usr/bin/bash
  6160. #
  6161. # option.sh - functions to test if build/packaging options are enabled
  6162. #
  6163. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6164. #
  6165. # This program is free software; you can redistribute it and/or modify
  6166. # it under the terms of the GNU General Public License as published by
  6167. # the Free Software Foundation; either version 2 of the License, or
  6168. # (at your option) any later version.
  6169. #
  6170. # This program is distributed in the hope that it will be useful,
  6171. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6172. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6173. # GNU General Public License for more details.
  6174. #
  6175. # You should have received a copy of the GNU General Public License
  6176. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6177. #
  6178.  
  6179. [[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ]] && return
  6180. ++++ [[ -n '' ]]
  6181. LIBMAKEPKG_UTIL_OPTION_SH=1
  6182. ++++ LIBMAKEPKG_UTIL_OPTION_SH=1
  6183.  
  6184.  
  6185. ##
  6186. # usage : in_opt_array( $needle, $haystack )
  6187. # return : 0 - enabled
  6188. # 1 - disabled
  6189. # 127 - not found
  6190. ##
  6191. in_opt_array() {
  6192. local needle=$1; shift
  6193.  
  6194. local i opt
  6195. for (( i = $#; i > 0; i-- )); do
  6196. opt=${!i}
  6197. if [[ $opt = "$needle" ]]; then
  6198. # enabled
  6199. return 0
  6200. elif [[ $opt = "!$needle" ]]; then
  6201. # disabled
  6202. return 1
  6203. fi
  6204. done
  6205.  
  6206. # not found
  6207. return 127
  6208. }
  6209.  
  6210.  
  6211. ##
  6212. # Checks to see if options are present in makepkg.conf or PKGBUILD;
  6213. # PKGBUILD options always take precedence.
  6214. #
  6215. # usage : check_option( $option, $expected_val )
  6216. # return : 0 - matches expected
  6217. # 1 - does not match expected
  6218. # 127 - not found
  6219. ##
  6220. check_option() {
  6221. in_opt_array "$1" ${options[@]}
  6222. case $? in
  6223. 0) # assert enabled
  6224. [[ $2 = y ]]
  6225. return ;;
  6226. 1) # assert disabled
  6227. [[ $2 = n ]]
  6228. return
  6229. esac
  6230.  
  6231. # fall back to makepkg.conf options
  6232. in_opt_array "$1" ${OPTIONS[@]}
  6233. case $? in
  6234. 0) # assert enabled
  6235. [[ $2 = y ]]
  6236. return ;;
  6237. 1) # assert disabled
  6238. [[ $2 = n ]]
  6239. return
  6240. esac
  6241.  
  6242. # not found
  6243. return 127
  6244. }
  6245.  
  6246.  
  6247. ##
  6248. # Check if option is present in BUILDENV
  6249. #
  6250. # usage : check_buildenv( $option, $expected_val )
  6251. # return : 0 - matches expected
  6252. # 1 - does not match expected
  6253. # 127 - not found
  6254. ##
  6255. check_buildenv() {
  6256. in_opt_array "$1" ${BUILDENV[@]}
  6257. case $? in
  6258. 0) # assert enabled
  6259. [[ $2 = "y" ]]
  6260. return ;;
  6261. 1) # assert disabled
  6262. [[ $2 = "n" ]]
  6263. return ;;
  6264. esac
  6265.  
  6266. # not found
  6267. return 127
  6268. }
  6269.  
  6270. ##
  6271. # Checks to see if options are present in BUILDENV or PKGBUILD;
  6272. # PKGBUILD options always take precedence.
  6273. #
  6274. # usage : check_buildoption( $option, $expected_val )
  6275. # return : 0 - matches expected
  6276. # 1 - does not match expected
  6277. # 127 - not found
  6278. ##
  6279. check_buildoption() {
  6280. in_opt_array "$1" ${options[@]}
  6281. case $? in
  6282. 0) # assert enabled
  6283. [[ $2 = y ]]
  6284. return ;;
  6285. 1) # assert disabled
  6286. [[ $2 = n ]]
  6287. return
  6288. esac
  6289.  
  6290. in_opt_array "$1" ${BUILDENV[@]}
  6291. case $? in
  6292. 0) # assert enabled
  6293. [[ $2 = y ]]
  6294. return ;;
  6295. 1) # assert disabled
  6296. [[ $2 = n ]]
  6297. return
  6298. esac
  6299.  
  6300. # not found
  6301. return 127
  6302. }
  6303.  
  6304. packaging_options+=('docs')
  6305. +++ packaging_options+=('docs')
  6306. tidy_remove+=('tidy_docs')
  6307. +++ tidy_remove+=('tidy_docs')
  6308.  
  6309. tidy_docs() {
  6310. if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
  6311. msg2 "$(gettext "Removing doc files...")"
  6312. rm -rf -- ${DOC_DIRS[@]}
  6313. fi
  6314. }
  6315. ++ for lib in "$LIBRARY/tidy/"*.sh
  6316. ++ source /usr/share/makepkg/tidy/emptydirs.sh
  6317. #!/usr/bin/bash
  6318. #
  6319. # emptydirs.sh - Remove empty directories from the package
  6320. #
  6321. # Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6322. #
  6323. # This program is free software; you can redistribute it and/or modify
  6324. # it under the terms of the GNU General Public License as published by
  6325. # the Free Software Foundation; either version 2 of the License, or
  6326. # (at your option) any later version.
  6327. #
  6328. # This program is distributed in the hope that it will be useful,
  6329. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6330. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6331. # GNU General Public License for more details.
  6332. #
  6333. # You should have received a copy of the GNU General Public License
  6334. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6335. #
  6336.  
  6337. [[ -n "$LIBMAKEPKG_TIDY_EMPTYDIRS_SH" ]] && return
  6338. +++ [[ -n '' ]]
  6339. LIBMAKEPKG_TIDY_EMPTYDIRS_SH=1
  6340. +++ LIBMAKEPKG_TIDY_EMPTYDIRS_SH=1
  6341.  
  6342. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  6343. +++ LIBRARY=/usr/share/makepkg
  6344.  
  6345. source "$LIBRARY/util/message.sh"
  6346. +++ source /usr/share/makepkg/util/message.sh
  6347. #!/usr/bin/bash
  6348. #
  6349. # message.sh - functions for outputting messages in makepkg
  6350. #
  6351. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6352. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  6353. #
  6354. # This program is free software; you can redistribute it and/or modify
  6355. # it under the terms of the GNU General Public License as published by
  6356. # the Free Software Foundation; either version 2 of the License, or
  6357. # (at your option) any later version.
  6358. #
  6359. # This program is distributed in the hope that it will be useful,
  6360. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6361. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6362. # GNU General Public License for more details.
  6363. #
  6364. # You should have received a copy of the GNU General Public License
  6365. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6366. #
  6367.  
  6368. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  6369. ++++ [[ -n 1 ]]
  6370. ++++ return
  6371. source "$LIBRARY/util/option.sh"
  6372. +++ source /usr/share/makepkg/util/option.sh
  6373. #!/usr/bin/bash
  6374. #
  6375. # option.sh - functions to test if build/packaging options are enabled
  6376. #
  6377. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6378. #
  6379. # This program is free software; you can redistribute it and/or modify
  6380. # it under the terms of the GNU General Public License as published by
  6381. # the Free Software Foundation; either version 2 of the License, or
  6382. # (at your option) any later version.
  6383. #
  6384. # This program is distributed in the hope that it will be useful,
  6385. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6386. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6387. # GNU General Public License for more details.
  6388. #
  6389. # You should have received a copy of the GNU General Public License
  6390. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6391. #
  6392.  
  6393. [[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ]] && return
  6394. ++++ [[ -n 1 ]]
  6395. ++++ return
  6396.  
  6397.  
  6398. packaging_options+=('emptydirs')
  6399. +++ packaging_options+=('emptydirs')
  6400. tidy_remove+=('tidy_emptydirs')
  6401. +++ tidy_remove+=('tidy_emptydirs')
  6402.  
  6403. tidy_emptydirs() {
  6404. if check_option "emptydirs" "n"; then
  6405. msg2 "$(gettext "Removing empty directories...")"
  6406. # we are unable to use '-empty' as it is non-POSIX and not support by all find variants
  6407. find . -depth -type d -exec rmdir '{}' \; 2>/dev/null
  6408. fi
  6409. }
  6410. ++ for lib in "$LIBRARY/tidy/"*.sh
  6411. ++ source /usr/share/makepkg/tidy/libtool.sh
  6412. #!/usr/bin/bash
  6413. #
  6414. # libtool.sh - Remove libtool files from the package
  6415. #
  6416. # Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6417. #
  6418. # This program is free software; you can redistribute it and/or modify
  6419. # it under the terms of the GNU General Public License as published by
  6420. # the Free Software Foundation; either version 2 of the License, or
  6421. # (at your option) any later version.
  6422. #
  6423. # This program is distributed in the hope that it will be useful,
  6424. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6425. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6426. # GNU General Public License for more details.
  6427. #
  6428. # You should have received a copy of the GNU General Public License
  6429. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6430. #
  6431.  
  6432. [[ -n "$LIBMAKEPKG_TIDY_LIBTOOL_SH" ]] && return
  6433. +++ [[ -n '' ]]
  6434. LIBMAKEPKG_TIDY_LIBTOOL_SH=1
  6435. +++ LIBMAKEPKG_TIDY_LIBTOOL_SH=1
  6436.  
  6437. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  6438. +++ LIBRARY=/usr/share/makepkg
  6439.  
  6440. source "$LIBRARY/util/message.sh"
  6441. +++ source /usr/share/makepkg/util/message.sh
  6442. #!/usr/bin/bash
  6443. #
  6444. # message.sh - functions for outputting messages in makepkg
  6445. #
  6446. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6447. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  6448. #
  6449. # This program is free software; you can redistribute it and/or modify
  6450. # it under the terms of the GNU General Public License as published by
  6451. # the Free Software Foundation; either version 2 of the License, or
  6452. # (at your option) any later version.
  6453. #
  6454. # This program is distributed in the hope that it will be useful,
  6455. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6456. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6457. # GNU General Public License for more details.
  6458. #
  6459. # You should have received a copy of the GNU General Public License
  6460. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6461. #
  6462.  
  6463. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  6464. ++++ [[ -n 1 ]]
  6465. ++++ return
  6466. source "$LIBRARY/util/option.sh"
  6467. +++ source /usr/share/makepkg/util/option.sh
  6468. #!/usr/bin/bash
  6469. #
  6470. # option.sh - functions to test if build/packaging options are enabled
  6471. #
  6472. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6473. #
  6474. # This program is free software; you can redistribute it and/or modify
  6475. # it under the terms of the GNU General Public License as published by
  6476. # the Free Software Foundation; either version 2 of the License, or
  6477. # (at your option) any later version.
  6478. #
  6479. # This program is distributed in the hope that it will be useful,
  6480. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6481. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6482. # GNU General Public License for more details.
  6483. #
  6484. # You should have received a copy of the GNU General Public License
  6485. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6486. #
  6487.  
  6488. [[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ]] && return
  6489. ++++ [[ -n 1 ]]
  6490. ++++ return
  6491.  
  6492.  
  6493. packaging_options+=('libtool')
  6494. +++ packaging_options+=('libtool')
  6495. tidy_remove+=('tidy_libtool')
  6496. +++ tidy_remove+=('tidy_libtool')
  6497.  
  6498. tidy_libtool() {
  6499. if check_option "libtool" "n"; then
  6500. msg2 "$(gettext "Removing "%s" files...")" "libtool"
  6501. find . ! -type d -name "*.la" -exec rm -f -- '{}' +
  6502. fi
  6503. }
  6504. ++ for lib in "$LIBRARY/tidy/"*.sh
  6505. ++ source /usr/share/makepkg/tidy/purge.sh
  6506. #!/usr/bin/bash
  6507. #
  6508. # purge.sh - Remove unwanted files from the package
  6509. #
  6510. # Copyright (c) 2008-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6511. #
  6512. # This program is free software; you can redistribute it and/or modify
  6513. # it under the terms of the GNU General Public License as published by
  6514. # the Free Software Foundation; either version 2 of the License, or
  6515. # (at your option) any later version.
  6516. #
  6517. # This program is distributed in the hope that it will be useful,
  6518. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6519. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6520. # GNU General Public License for more details.
  6521. #
  6522. # You should have received a copy of the GNU General Public License
  6523. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6524. #
  6525.  
  6526. [[ -n "$LIBMAKEPKG_TIDY_PURGE_SH" ]] && return
  6527. +++ [[ -n '' ]]
  6528. LIBMAKEPKG_TIDY_PURGE_SH=1
  6529. +++ LIBMAKEPKG_TIDY_PURGE_SH=1
  6530.  
  6531. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  6532. +++ LIBRARY=/usr/share/makepkg
  6533.  
  6534. source "$LIBRARY/util/message.sh"
  6535. +++ source /usr/share/makepkg/util/message.sh
  6536. #!/usr/bin/bash
  6537. #
  6538. # message.sh - functions for outputting messages in makepkg
  6539. #
  6540. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6541. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  6542. #
  6543. # This program is free software; you can redistribute it and/or modify
  6544. # it under the terms of the GNU General Public License as published by
  6545. # the Free Software Foundation; either version 2 of the License, or
  6546. # (at your option) any later version.
  6547. #
  6548. # This program is distributed in the hope that it will be useful,
  6549. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6550. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6551. # GNU General Public License for more details.
  6552. #
  6553. # You should have received a copy of the GNU General Public License
  6554. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6555. #
  6556.  
  6557. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  6558. ++++ [[ -n 1 ]]
  6559. ++++ return
  6560. source "$LIBRARY/util/option.sh"
  6561. +++ source /usr/share/makepkg/util/option.sh
  6562. #!/usr/bin/bash
  6563. #
  6564. # option.sh - functions to test if build/packaging options are enabled
  6565. #
  6566. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6567. #
  6568. # This program is free software; you can redistribute it and/or modify
  6569. # it under the terms of the GNU General Public License as published by
  6570. # the Free Software Foundation; either version 2 of the License, or
  6571. # (at your option) any later version.
  6572. #
  6573. # This program is distributed in the hope that it will be useful,
  6574. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6575. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6576. # GNU General Public License for more details.
  6577. #
  6578. # You should have received a copy of the GNU General Public License
  6579. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6580. #
  6581.  
  6582. [[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ]] && return
  6583. ++++ [[ -n 1 ]]
  6584. ++++ return
  6585.  
  6586.  
  6587. packaging_options+=('purge')
  6588. +++ packaging_options+=('purge')
  6589. tidy_remove+=('tidy_purge')
  6590. +++ tidy_remove+=('tidy_purge')
  6591.  
  6592. tidy_purge() {
  6593. if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
  6594. msg2 "$(gettext "Purging unwanted files...")"
  6595. local pt
  6596. for pt in "${PURGE_TARGETS[@]}"; do
  6597. if [[ ${pt} = "${pt//\/}" ]]; then
  6598. find . ! -type d -name "${pt}" -exec rm -f -- '{}' +
  6599. else
  6600. rm -f ${pt}
  6601. fi
  6602. done
  6603. fi
  6604. }
  6605. ++ for lib in "$LIBRARY/tidy/"*.sh
  6606. ++ source /usr/share/makepkg/tidy/staticlibs.sh
  6607. #!/usr/bin/bash
  6608. #
  6609. # staticlibs.sh - Remove static library files from the package
  6610. #
  6611. # Copyright (c) 2013-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6612. #
  6613. # This program is free software; you can redistribute it and/or modify
  6614. # it under the terms of the GNU General Public License as published by
  6615. # the Free Software Foundation; either version 2 of the License, or
  6616. # (at your option) any later version.
  6617. #
  6618. # This program is distributed in the hope that it will be useful,
  6619. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6620. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6621. # GNU General Public License for more details.
  6622. #
  6623. # You should have received a copy of the GNU General Public License
  6624. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6625. #
  6626.  
  6627. [[ -n "$LIBMAKEPKG_TIDY_STATICLIBS_SH" ]] && return
  6628. +++ [[ -n '' ]]
  6629. LIBMAKEPKG_TIDY_STATICLIBS_SH=1
  6630. +++ LIBMAKEPKG_TIDY_STATICLIBS_SH=1
  6631.  
  6632. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  6633. +++ LIBRARY=/usr/share/makepkg
  6634.  
  6635. source "$LIBRARY/util/message.sh"
  6636. +++ source /usr/share/makepkg/util/message.sh
  6637. #!/usr/bin/bash
  6638. #
  6639. # message.sh - functions for outputting messages in makepkg
  6640. #
  6641. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6642. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  6643. #
  6644. # This program is free software; you can redistribute it and/or modify
  6645. # it under the terms of the GNU General Public License as published by
  6646. # the Free Software Foundation; either version 2 of the License, or
  6647. # (at your option) any later version.
  6648. #
  6649. # This program is distributed in the hope that it will be useful,
  6650. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6651. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6652. # GNU General Public License for more details.
  6653. #
  6654. # You should have received a copy of the GNU General Public License
  6655. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6656. #
  6657.  
  6658. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  6659. ++++ [[ -n 1 ]]
  6660. ++++ return
  6661. source "$LIBRARY/util/option.sh"
  6662. +++ source /usr/share/makepkg/util/option.sh
  6663. #!/usr/bin/bash
  6664. #
  6665. # option.sh - functions to test if build/packaging options are enabled
  6666. #
  6667. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6668. #
  6669. # This program is free software; you can redistribute it and/or modify
  6670. # it under the terms of the GNU General Public License as published by
  6671. # the Free Software Foundation; either version 2 of the License, or
  6672. # (at your option) any later version.
  6673. #
  6674. # This program is distributed in the hope that it will be useful,
  6675. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6676. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6677. # GNU General Public License for more details.
  6678. #
  6679. # You should have received a copy of the GNU General Public License
  6680. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6681. #
  6682.  
  6683. [[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ]] && return
  6684. ++++ [[ -n 1 ]]
  6685. ++++ return
  6686.  
  6687.  
  6688. packaging_options+=('staticlibs')
  6689. +++ packaging_options+=('staticlibs')
  6690. tidy_remove+=('tidy_staticlibs')
  6691. +++ tidy_remove+=('tidy_staticlibs')
  6692.  
  6693. tidy_staticlibs() {
  6694. if check_option "staticlibs" "n"; then
  6695. msg2 "$(gettext "Removing static library files...")"
  6696. local l
  6697. while read -rd '' l; do
  6698. if [[ -f "${l%.a}.so" || -h "${l%.a}.so" ]]; then
  6699. rm "$l"
  6700. fi
  6701. done < <(find . ! -type d -name "*.a" -print0)
  6702. fi
  6703. }
  6704. ++ for lib in "$LIBRARY/tidy/"*.sh
  6705. ++ source /usr/share/makepkg/tidy/strip.sh
  6706. #!/usr/bin/bash
  6707. #
  6708. # strip.sh - Strip debugging symbols from binary files
  6709. #
  6710. # Copyright (c) 2007-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6711. #
  6712. # This program is free software; you can redistribute it and/or modify
  6713. # it under the terms of the GNU General Public License as published by
  6714. # the Free Software Foundation; either version 2 of the License, or
  6715. # (at your option) any later version.
  6716. #
  6717. # This program is distributed in the hope that it will be useful,
  6718. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6719. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6720. # GNU General Public License for more details.
  6721. #
  6722. # You should have received a copy of the GNU General Public License
  6723. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6724. #
  6725.  
  6726. [[ -n "$LIBMAKEPKG_TIDY_STRIP_SH" ]] && return
  6727. +++ [[ -n '' ]]
  6728. LIBMAKEPKG_TIDY_STRIP_SH=1
  6729. +++ LIBMAKEPKG_TIDY_STRIP_SH=1
  6730.  
  6731. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  6732. +++ LIBRARY=/usr/share/makepkg
  6733.  
  6734. source "$LIBRARY/util/message.sh"
  6735. +++ source /usr/share/makepkg/util/message.sh
  6736. #!/usr/bin/bash
  6737. #
  6738. # message.sh - functions for outputting messages in makepkg
  6739. #
  6740. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6741. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  6742. #
  6743. # This program is free software; you can redistribute it and/or modify
  6744. # it under the terms of the GNU General Public License as published by
  6745. # the Free Software Foundation; either version 2 of the License, or
  6746. # (at your option) any later version.
  6747. #
  6748. # This program is distributed in the hope that it will be useful,
  6749. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6750. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6751. # GNU General Public License for more details.
  6752. #
  6753. # You should have received a copy of the GNU General Public License
  6754. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6755. #
  6756.  
  6757. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  6758. ++++ [[ -n 1 ]]
  6759. ++++ return
  6760. source "$LIBRARY/util/option.sh"
  6761. +++ source /usr/share/makepkg/util/option.sh
  6762. #!/usr/bin/bash
  6763. #
  6764. # option.sh - functions to test if build/packaging options are enabled
  6765. #
  6766. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6767. #
  6768. # This program is free software; you can redistribute it and/or modify
  6769. # it under the terms of the GNU General Public License as published by
  6770. # the Free Software Foundation; either version 2 of the License, or
  6771. # (at your option) any later version.
  6772. #
  6773. # This program is distributed in the hope that it will be useful,
  6774. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6775. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6776. # GNU General Public License for more details.
  6777. #
  6778. # You should have received a copy of the GNU General Public License
  6779. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6780. #
  6781.  
  6782. [[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ]] && return
  6783. ++++ [[ -n 1 ]]
  6784. ++++ return
  6785.  
  6786.  
  6787. packaging_options+=('strip' 'debug')
  6788. +++ packaging_options+=('strip' 'debug')
  6789. tidy_modify+=('tidy_strip')
  6790. +++ tidy_modify+=('tidy_strip')
  6791.  
  6792.  
  6793. build_id() {
  6794. LANG=C readelf -n "$1" | sed -n '/Build ID/ { s/.*: //p; q; }'
  6795. }
  6796.  
  6797. source_files() {
  6798. LANG=C readelf "$1" --debug-dump | \
  6799. awk '/DW_AT_name +:/{name=$8}/DW_AT_comp_dir +:/{{if (name !~ /^\//) {printf "%s/", $8}}{print name}}'
  6800. }
  6801.  
  6802. strip_file() {
  6803. local binary=$1; shift
  6804.  
  6805. if check_option "debug" "y"; then
  6806. local bid=$(build_id "$binary")
  6807.  
  6808. # has this file already been stripped
  6809. if [[ -n "$bid" ]]; then
  6810. if [[ -f "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug" ]]; then
  6811. return
  6812. fi
  6813. elif [[ -f "$dbgdir/$binary.debug" ]]; then
  6814. return
  6815. fi
  6816.  
  6817. # copy source files to debug directory
  6818. local f t
  6819. while read -r t; do
  6820. f=${t/${dbgsrcdir}/"$srcdir"}
  6821. mkdir -p "${dbgsrc/"$dbgsrcdir"/}${t%/*}"
  6822. cp -- "$f" "${dbgsrc/"$dbgsrcdir"/}$t"
  6823. done < <(source_files "$binary")
  6824.  
  6825. # copy debug symbols to debug directory
  6826. mkdir -p "$dbgdir/${binary%/*}"
  6827. objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
  6828. objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
  6829.  
  6830. # create any needed hardlinks
  6831. while read -rd '' file ; do
  6832. if [[ "${binary}" -ef "${file}" && ! -f "$dbgdir/${file}.debug" ]]; then
  6833. mkdir -p "$dbgdir/${file%/*}"
  6834. ln "$dbgdir/${binary}.debug" "$dbgdir/${file}.debug"
  6835. fi
  6836. done < <(find . -type f -perm -u+w -print0 2>/dev/null)
  6837.  
  6838. if [[ -n "$bid" ]]; then
  6839. local target
  6840. mkdir -p "$dbgdir/.build-id/${bid:0:2}"
  6841.  
  6842. target="../../../../../${binary#./}"
  6843. target="${target/..\/..\/usr\/lib\/}"
  6844. target="${target/..\/usr\/}"
  6845. ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}"
  6846.  
  6847. target="../../${binary#./}.debug"
  6848. ln -s "$target" "$dbgdir/.build-id/${bid:0:2}/${bid:2}.debug"
  6849. fi
  6850. fi
  6851.  
  6852. strip $@ "$binary"
  6853. }
  6854.  
  6855.  
  6856. tidy_strip() {
  6857. if check_option "strip" "y"; then
  6858. msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
  6859. # make sure library stripping variables are defined to prevent excess stripping
  6860. [[ -z ${STRIP_SHARED+x} ]] && STRIP_SHARED="-S"
  6861. [[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
  6862.  
  6863. if check_option "debug" "y"; then
  6864.  
  6865. dbgdir="$pkgdirbase/$pkgbase-debug/usr/lib/debug"
  6866. dbgsrcdir="${DBGSRCDIR:-/usr/src/debug}"
  6867. dbgsrc="$pkgdirbase/$pkgbase-debug$dbgsrcdir"
  6868. mkdir -p "$dbgdir" "$dbgsrc"
  6869. fi
  6870.  
  6871. local binary strip_flags
  6872. find . -type f -perm -u+w -print0 2>/dev/null | while read -rd '' binary ; do
  6873. case "$(file -bi "$binary")" in
  6874. *application/x-sharedlib*) # Libraries (.so)
  6875. strip_flags="$STRIP_SHARED";;
  6876. *application/x-archive*) # Libraries (.a)
  6877. strip_flags="$STRIP_STATIC";;
  6878. *application/x-object*)
  6879. case "$binary" in
  6880. *.ko) # Kernel module
  6881. strip_flags="$STRIP_SHARED";;
  6882. *)
  6883. continue;;
  6884. esac;;
  6885. *application/x-executable*) # Binaries
  6886. strip_flags="$STRIP_BINARIES";;
  6887. *application/x-pie-executable*) # Relocatable binaries
  6888. strip_flags="$STRIP_SHARED";;
  6889. *)
  6890. continue ;;
  6891. esac
  6892. strip_file "$binary" ${strip_flags}
  6893. done
  6894. fi
  6895. }
  6896. ++ for lib in "$LIBRARY/tidy/"*.sh
  6897. ++ source /usr/share/makepkg/tidy/zipman.sh
  6898. #!/usr/bin/bash
  6899. #
  6900. # zipman.sh - Compress man and info pages
  6901. #
  6902. # Copyright (c) 2011-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6903. #
  6904. # This program is free software; you can redistribute it and/or modify
  6905. # it under the terms of the GNU General Public License as published by
  6906. # the Free Software Foundation; either version 2 of the License, or
  6907. # (at your option) any later version.
  6908. #
  6909. # This program is distributed in the hope that it will be useful,
  6910. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6911. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6912. # GNU General Public License for more details.
  6913. #
  6914. # You should have received a copy of the GNU General Public License
  6915. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6916. #
  6917.  
  6918. [[ -n "$LIBMAKEPKG_TIDY_ZIPMAN_SH" ]] && return
  6919. +++ [[ -n '' ]]
  6920. LIBMAKEPKG_TIDY_ZIPMAN_SH=1
  6921. +++ LIBMAKEPKG_TIDY_ZIPMAN_SH=1
  6922.  
  6923. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  6924. +++ LIBRARY=/usr/share/makepkg
  6925.  
  6926. source "$LIBRARY/util/message.sh"
  6927. +++ source /usr/share/makepkg/util/message.sh
  6928. #!/usr/bin/bash
  6929. #
  6930. # message.sh - functions for outputting messages in makepkg
  6931. #
  6932. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6933. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  6934. #
  6935. # This program is free software; you can redistribute it and/or modify
  6936. # it under the terms of the GNU General Public License as published by
  6937. # the Free Software Foundation; either version 2 of the License, or
  6938. # (at your option) any later version.
  6939. #
  6940. # This program is distributed in the hope that it will be useful,
  6941. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6942. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6943. # GNU General Public License for more details.
  6944. #
  6945. # You should have received a copy of the GNU General Public License
  6946. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6947. #
  6948.  
  6949. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  6950. ++++ [[ -n 1 ]]
  6951. ++++ return
  6952. source "$LIBRARY/util/option.sh"
  6953. +++ source /usr/share/makepkg/util/option.sh
  6954. #!/usr/bin/bash
  6955. #
  6956. # option.sh - functions to test if build/packaging options are enabled
  6957. #
  6958. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  6959. #
  6960. # This program is free software; you can redistribute it and/or modify
  6961. # it under the terms of the GNU General Public License as published by
  6962. # the Free Software Foundation; either version 2 of the License, or
  6963. # (at your option) any later version.
  6964. #
  6965. # This program is distributed in the hope that it will be useful,
  6966. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  6967. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  6968. # GNU General Public License for more details.
  6969. #
  6970. # You should have received a copy of the GNU General Public License
  6971. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  6972. #
  6973.  
  6974. [[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ]] && return
  6975. ++++ [[ -n 1 ]]
  6976. ++++ return
  6977.  
  6978.  
  6979. packaging_options+=('zipman')
  6980. +++ packaging_options+=('zipman')
  6981. tidy_modify+=('tidy_zipman')
  6982. +++ tidy_modify+=('tidy_zipman')
  6983.  
  6984. tidy_zipman() {
  6985. if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
  6986. msg2 "$(gettext "Compressing man and info pages...")"
  6987. local file files inode link
  6988. while read -rd ' ' inode; do
  6989. read file
  6990. find ${MAN_DIRS[@]} -type l 2>/dev/null |
  6991. while read -r link ; do
  6992. if [[ "${file}" -ef "${link}" ]] ; then
  6993. rm -f "$link" "${link}.gz"
  6994. if [[ ${file%/*} = ${link%/*} ]]; then
  6995. ln -s -- "${file##*/}.gz" "${link}.gz"
  6996. else
  6997. ln -s -- "/${file}.gz" "${link}.gz"
  6998. fi
  6999. fi
  7000. done
  7001. if [[ -z ${files[$inode]} ]]; then
  7002. files[$inode]=$file
  7003. gzip -9 -n -f "$file"
  7004. else
  7005. rm -f "$file"
  7006. ln "${files[$inode]}.gz" "${file}.gz"
  7007. chmod 644 "${file}.gz"
  7008. fi
  7009. done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
  7010. -exec stat -c '%i %n' '{}' + 2>/dev/null)
  7011. fi
  7012. }
  7013.  
  7014. readonly -a packaging_options tidy_remove tidy_modify
  7015. ++ readonly -a packaging_options tidy_remove tidy_modify
  7016.  
  7017.  
  7018. tidy_install() {
  7019. cd_safe "$pkgdir"
  7020. msg "$(gettext "Tidying install...")"
  7021.  
  7022. # options that remove unwanted files
  7023. for func in ${tidy_remove[@]}; do
  7024. $func
  7025. done
  7026.  
  7027. # options that modify files
  7028. for func in ${tidy_modify[@]}; do
  7029. $func
  7030. done
  7031. }
  7032. + for lib in "$LIBRARY"/*.sh
  7033. + source /usr/share/makepkg/util.sh
  7034. #!/usr/bin/bash
  7035. #
  7036. # util.sh - utility functions for makepkg
  7037. #
  7038. # Copyright (c) 2015-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7039. #
  7040. # This program is free software; you can redistribute it and/or modify
  7041. # it under the terms of the GNU General Public License as published by
  7042. # the Free Software Foundation; either version 2 of the License, or
  7043. # (at your option) any later version.
  7044. #
  7045. # This program is distributed in the hope that it will be useful,
  7046. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7047. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7048. # GNU General Public License for more details.
  7049. #
  7050. # You should have received a copy of the GNU General Public License
  7051. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7052. #
  7053.  
  7054. [[ -n "$LIBMAKEPKG_UTIL_SH" ]] && return
  7055. ++ [[ -n '' ]]
  7056. LIBMAKEPKG_UTIL_SH=1
  7057. ++ LIBMAKEPKG_UTIL_SH=1
  7058.  
  7059. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  7060. ++ LIBRARY=/usr/share/makepkg
  7061.  
  7062. for lib in "$LIBRARY/util/"*.sh; do
  7063. source "$lib"
  7064. done
  7065. ++ for lib in "$LIBRARY/util/"*.sh
  7066. ++ source /usr/share/makepkg/util/compress.sh
  7067. #!/usr/bin/bash
  7068. #
  7069. # compress.sh - functions to compress archives in a uniform manner
  7070. #
  7071. # Copyright (c) 2017-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7072. #
  7073. # This program is free software; you can redistribute it and/or modify
  7074. # it under the terms of the GNU General Public License as published by
  7075. # the Free Software Foundation; either version 2 of the License, or
  7076. # (at your option) any later version.
  7077. #
  7078. # This program is distributed in the hope that it will be useful,
  7079. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7080. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7081. # GNU General Public License for more details.
  7082. #
  7083. # You should have received a copy of the GNU General Public License
  7084. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7085. #
  7086.  
  7087. [[ -n "$LIBMAKEPKG_UTIL_COMPRESS_SH" ]] && return
  7088. +++ [[ -n '' ]]
  7089. LIBMAKEPKG_UTIL_COMPRESS_SH=1
  7090. +++ LIBMAKEPKG_UTIL_COMPRESS_SH=1
  7091.  
  7092. LIBRARY=${LIBRARY:-'/usr/share/makepkg'}
  7093. +++ LIBRARY=/usr/share/makepkg
  7094.  
  7095. source "$LIBRARY/util/message.sh"
  7096. +++ source /usr/share/makepkg/util/message.sh
  7097. #!/usr/bin/bash
  7098. #
  7099. # message.sh - functions for outputting messages in makepkg
  7100. #
  7101. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7102. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  7103. #
  7104. # This program is free software; you can redistribute it and/or modify
  7105. # it under the terms of the GNU General Public License as published by
  7106. # the Free Software Foundation; either version 2 of the License, or
  7107. # (at your option) any later version.
  7108. #
  7109. # This program is distributed in the hope that it will be useful,
  7110. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7111. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7112. # GNU General Public License for more details.
  7113. #
  7114. # You should have received a copy of the GNU General Public License
  7115. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7116. #
  7117.  
  7118. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  7119. ++++ [[ -n 1 ]]
  7120. ++++ return
  7121.  
  7122.  
  7123. # Wrapper around many stream compression formats, for use in the middle of a
  7124. # pipeline. A tar archive is passed on stdin and compressed to stdout.
  7125. compress_as() {
  7126. # $1: final archive filename extension for compression type detection
  7127.  
  7128. local filename="$1"
  7129.  
  7130. case "$filename" in
  7131. *tar.gz) ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
  7132. *tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
  7133. *tar.xz) ${COMPRESSXZ[@]:-xz -c -z -} ;;
  7134. *tar.lrz) ${COMPRESSLRZ[@]:-lrzip -q} ;;
  7135. *tar.lzo) ${COMPRESSLZO[@]:-lzop -q} ;;
  7136. *tar.Z) ${COMPRESSZ[@]:-compress -c -f} ;;
  7137. *tar) cat ;;
  7138. *) warning "$(gettext "'%s' is not a valid archive extension.")" \
  7139. "$ext"; cat ;;
  7140. esac
  7141. }
  7142. ++ for lib in "$LIBRARY/util/"*.sh
  7143. ++ source /usr/share/makepkg/util/error.sh
  7144. #!/usr/bin/bash
  7145. #
  7146. # error.sh.in - error variable definitions for makepkg
  7147. #
  7148. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7149. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  7150. #
  7151. # This program is free software; you can redistribute it and/or modify
  7152. # it under the terms of the GNU General Public License as published by
  7153. # the Free Software Foundation; either version 2 of the License, or
  7154. # (at your option) any later version.
  7155. #
  7156. # This program is distributed in the hope that it will be useful,
  7157. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7158. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7159. # GNU General Public License for more details.
  7160. #
  7161. # You should have received a copy of the GNU General Public License
  7162. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7163. #
  7164.  
  7165. [[ -n "$LIBMAKEPKG_UTIL_ERROR_SH" ]] && return
  7166. +++ [[ -n '' ]]
  7167. LIBMAKEPKG_UTIL_ERROR_SH=1
  7168. +++ LIBMAKEPKG_UTIL_ERROR_SH=1
  7169.  
  7170. E_OK=0
  7171. +++ E_OK=0
  7172. E_FAIL=1 # Generic error
  7173. +++ E_FAIL=1
  7174. E_CONFIG_ERROR=2
  7175. +++ E_CONFIG_ERROR=2
  7176. E_INVALID_OPTION=3
  7177. +++ E_INVALID_OPTION=3
  7178. E_USER_FUNCTION_FAILED=4
  7179. +++ E_USER_FUNCTION_FAILED=4
  7180. E_PACKAGE_FAILED=5
  7181. +++ E_PACKAGE_FAILED=5
  7182. E_MISSING_FILE=6
  7183. +++ E_MISSING_FILE=6
  7184. E_MISSING_PKGDIR=7
  7185. +++ E_MISSING_PKGDIR=7
  7186. E_INSTALL_DEPS_FAILED=8
  7187. +++ E_INSTALL_DEPS_FAILED=8
  7188. E_REMOVE_DEPS_FAILED=9
  7189. +++ E_REMOVE_DEPS_FAILED=9
  7190. E_ROOT=10
  7191. +++ E_ROOT=10
  7192. E_FS_PERMISSIONS=11
  7193. +++ E_FS_PERMISSIONS=11
  7194. E_PKGBUILD_ERROR=12
  7195. +++ E_PKGBUILD_ERROR=12
  7196. E_ALREADY_BUILT=13
  7197. +++ E_ALREADY_BUILT=13
  7198. E_INSTALL_FAILED=14
  7199. +++ E_INSTALL_FAILED=14
  7200. E_MISSING_MAKEPKG_DEPS=15
  7201. +++ E_MISSING_MAKEPKG_DEPS=15
  7202. E_PRETTY_BAD_PRIVACY=16
  7203. +++ E_PRETTY_BAD_PRIVACY=16
  7204. ++ for lib in "$LIBRARY/util/"*.sh
  7205. ++ source /usr/share/makepkg/util/message.sh
  7206. #!/usr/bin/bash
  7207. #
  7208. # message.sh - functions for outputting messages in makepkg
  7209. #
  7210. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7211. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  7212. #
  7213. # This program is free software; you can redistribute it and/or modify
  7214. # it under the terms of the GNU General Public License as published by
  7215. # the Free Software Foundation; either version 2 of the License, or
  7216. # (at your option) any later version.
  7217. #
  7218. # This program is distributed in the hope that it will be useful,
  7219. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7220. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7221. # GNU General Public License for more details.
  7222. #
  7223. # You should have received a copy of the GNU General Public License
  7224. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7225. #
  7226.  
  7227. [[ -n "$LIBMAKEPKG_UTIL_MESSAGE_SH" ]] && return
  7228. +++ [[ -n 1 ]]
  7229. +++ return
  7230. ++ for lib in "$LIBRARY/util/"*.sh
  7231. ++ source /usr/share/makepkg/util/option.sh
  7232. #!/usr/bin/bash
  7233. #
  7234. # option.sh - functions to test if build/packaging options are enabled
  7235. #
  7236. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7237. #
  7238. # This program is free software; you can redistribute it and/or modify
  7239. # it under the terms of the GNU General Public License as published by
  7240. # the Free Software Foundation; either version 2 of the License, or
  7241. # (at your option) any later version.
  7242. #
  7243. # This program is distributed in the hope that it will be useful,
  7244. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7245. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7246. # GNU General Public License for more details.
  7247. #
  7248. # You should have received a copy of the GNU General Public License
  7249. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7250. #
  7251.  
  7252. [[ -n "$LIBMAKEPKG_UTIL_OPTION_SH" ]] && return
  7253. +++ [[ -n 1 ]]
  7254. +++ return
  7255. ++ for lib in "$LIBRARY/util/"*.sh
  7256. ++ source /usr/share/makepkg/util/parseopts.sh
  7257. #!/usr/bin/bash
  7258. #
  7259. # parseopts.sh - getopt_long-like parser
  7260. #
  7261. # Copyright (c) 2012-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7262. #
  7263. # This program is free software; you can redistribute it and/or modify
  7264. # it under the terms of the GNU General Public License as published by
  7265. # the Free Software Foundation; either version 2 of the License, or
  7266. # (at your option) any later version.
  7267. #
  7268. # This program is distributed in the hope that it will be useful,
  7269. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7270. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7271. # GNU General Public License for more details.
  7272. #
  7273. # You should have received a copy of the GNU General Public License
  7274. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7275. #
  7276. # A getopt_long-like parser which portably supports longopts and
  7277. # shortopts with some GNU extensions. It does not allow for options
  7278. # with optional arguments. For both short and long opts, options
  7279. # requiring an argument should be suffixed with a colon. After the
  7280. # first argument containing the short opts, any number of valid long
  7281. # opts may be be passed. The end of the options delimiter must then be
  7282. # added, followed by the user arguments to the calling program.
  7283. #
  7284. # Recommended Usage:
  7285. # OPT_SHORT='fb:z'
  7286. # OPT_LONG=('foo' 'bar:' 'baz')
  7287. # if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
  7288. # exit 1
  7289. # fi
  7290. # set -- "${OPTRET[@]}"
  7291. # Returns:
  7292. # 0: parse success
  7293. # 1: parse failure (error message supplied)
  7294. parseopts() {
  7295. local opt= optarg= i= shortopts=$1
  7296. local -a longopts=() unused_argv=()
  7297.  
  7298. shift
  7299. while [[ $1 && $1 != '--' ]]; do
  7300. longopts+=("$1")
  7301. shift
  7302. done
  7303. shift
  7304.  
  7305. longoptmatch() {
  7306. local o longmatch=()
  7307. for o in "${longopts[@]}"; do
  7308. if [[ ${o%:} = "$1" ]]; then
  7309. longmatch=("$o")
  7310. break
  7311. fi
  7312. [[ ${o%:} = "$1"* ]] && longmatch+=("$o")
  7313. done
  7314.  
  7315. case ${#longmatch[*]} in
  7316. 1)
  7317. # success, override with opt and return arg req (0 == none, 1 == required)
  7318. opt=${longmatch%:}
  7319. if [[ $longmatch = *: ]]; then
  7320. return 1
  7321. else
  7322. return 0
  7323. fi ;;
  7324. 0)
  7325. # fail, no match found
  7326. return 255 ;;
  7327. *)
  7328. # fail, ambiguous match
  7329. printf "${0##*/}: $(gettext "option '%s' is ambiguous; possibilities:")" "--$1"
  7330. printf " '%s'" "${longmatch[@]%:}"
  7331. printf '\n'
  7332. return 254 ;;
  7333. esac >&2
  7334. }
  7335.  
  7336. while (( $# )); do
  7337. case $1 in
  7338. --) # explicit end of options
  7339. shift
  7340. break
  7341. ;;
  7342. -[!-]*) # short option
  7343. for (( i = 1; i < ${#1}; i++ )); do
  7344. opt=${1:i:1}
  7345.  
  7346. # option doesn't exist
  7347. if [[ $shortopts != *$opt* ]]; then
  7348. printf "${0##*/}: $(gettext "invalid option") -- '%s'\n" "$opt" >&2
  7349. OPTRET=(--)
  7350. return 1
  7351. fi
  7352.  
  7353. OPTRET+=("-$opt")
  7354. # option requires optarg
  7355. if [[ $shortopts = *$opt:* ]]; then
  7356. # if we're not at the end of the option chunk, the rest is the optarg
  7357. if (( i < ${#1} - 1 )); then
  7358. OPTRET+=("${1:i+1}")
  7359. break
  7360. # if we're at the end, grab the the next positional, if it exists
  7361. elif (( i == ${#1} - 1 )) && [[ $2 ]]; then
  7362. OPTRET+=("$2")
  7363. shift
  7364. break
  7365. # parse failure
  7366. else
  7367. printf "${0##*/}: $(gettext "option requires an argument") -- '%s'\n" "$opt" >&2
  7368. OPTRET=(--)
  7369. return 1
  7370. fi
  7371. fi
  7372. done
  7373. ;;
  7374. --?*=*|--?*) # long option
  7375. IFS='=' read -r opt optarg <<< "${1#--}"
  7376. longoptmatch "$opt"
  7377. case $? in
  7378. 0)
  7379. # parse failure
  7380. if [[ $optarg ]]; then
  7381. printf "${0##*/}: $(gettext "option '%s' does not allow an argument")\n" "--$opt" >&2
  7382. OPTRET=(--)
  7383. return 1
  7384. # --longopt
  7385. else
  7386. OPTRET+=("--$opt")
  7387. fi
  7388. ;;
  7389. 1)
  7390. # --longopt=optarg
  7391. if [[ $optarg ]]; then
  7392. OPTRET+=("--$opt" "$optarg")
  7393. # --longopt optarg
  7394. elif [[ $2 ]]; then
  7395. OPTRET+=("--$opt" "$2" )
  7396. shift
  7397. # parse failure
  7398. else
  7399. printf "${0##*/}: $(gettext "option '%s' requires an argument")\n" "--$opt" >&2
  7400. OPTRET=(--)
  7401. return 1
  7402. fi
  7403. ;;
  7404. 254)
  7405. # ambiguous option -- error was reported for us by longoptmatch()
  7406. OPTRET=(--)
  7407. return 1
  7408. ;;
  7409. 255)
  7410. # parse failure
  7411. printf "${0##*/}: $(gettext "invalid option") '--%s'\n" "$opt" >&2
  7412. OPTRET=(--)
  7413. return 1
  7414. ;;
  7415. esac
  7416. ;;
  7417. *) # non-option arg encountered, add it as a parameter
  7418. unused_argv+=("$1")
  7419. ;;
  7420. esac
  7421. shift
  7422. done
  7423.  
  7424. # add end-of-opt terminator and any leftover positional parameters
  7425. OPTRET+=('--' "${unused_argv[@]}" "$@")
  7426. unset longoptmatch
  7427.  
  7428. return 0
  7429. }
  7430. ++ for lib in "$LIBRARY/util/"*.sh
  7431. ++ source /usr/share/makepkg/util/pkgbuild.sh
  7432. #!/usr/bin/bash
  7433. #
  7434. # pkgbuild.sh - functions to extract information from PKGBUILD files
  7435. #
  7436. # Copyright (c) 2009-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7437. #
  7438. # This program is free software; you can redistribute it and/or modify
  7439. # it under the terms of the GNU General Public License as published by
  7440. # the Free Software Foundation; either version 2 of the License, or
  7441. # (at your option) any later version.
  7442. #
  7443. # This program is distributed in the hope that it will be useful,
  7444. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7445. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7446. # GNU General Public License for more details.
  7447. #
  7448. # You should have received a copy of the GNU General Public License
  7449. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7450. #
  7451.  
  7452. [[ -n "$LIBMAKEPKG_UTIL_PKGBUILD_SH" ]] && return
  7453. +++ [[ -n 1 ]]
  7454. +++ return
  7455. ++ for lib in "$LIBRARY/util/"*.sh
  7456. ++ source /usr/share/makepkg/util/source.sh
  7457. #!/usr/bin/bash
  7458. #
  7459. # source.sh - functions to extract information from source URLs
  7460. #
  7461. # Copyright (c) 2010-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7462. #
  7463. # This program is free software; you can redistribute it and/or modify
  7464. # it under the terms of the GNU General Public License as published by
  7465. # the Free Software Foundation; either version 2 of the License, or
  7466. # (at your option) any later version.
  7467. #
  7468. # This program is distributed in the hope that it will be useful,
  7469. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7470. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7471. # GNU General Public License for more details.
  7472. #
  7473. # You should have received a copy of the GNU General Public License
  7474. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7475. #
  7476.  
  7477. [[ -n "$LIBMAKEPKG_UTIL_SOURCE_SH" ]] && return
  7478. +++ [[ -n 1 ]]
  7479. +++ return
  7480. ++ for lib in "$LIBRARY/util/"*.sh
  7481. ++ source /usr/share/makepkg/util/util.sh
  7482. #!/usr/bin/bash
  7483. #
  7484. # util.sh - general utility functions
  7485. #
  7486. # Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>
  7487. # Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
  7488. #
  7489. # This program is free software; you can redistribute it and/or modify
  7490. # it under the terms of the GNU General Public License as published by
  7491. # the Free Software Foundation; either version 2 of the License, or
  7492. # (at your option) any later version.
  7493. #
  7494. # This program is distributed in the hope that it will be useful,
  7495. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7496. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  7497. # GNU General Public License for more details.
  7498. #
  7499. # You should have received a copy of the GNU General Public License
  7500. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  7501. #
  7502.  
  7503. [[ -n "$LIBMAKEPKG_UTIL_UTIL_SH" ]] && return
  7504. +++ [[ -n 1 ]]
  7505. +++ return
  7506.  
  7507. ##
  7508. # Special exit call for traps, Don't print any error messages when inside,
  7509. # the fakeroot call, the error message will be printed by the main call.
  7510. ##
  7511. trap_exit() {
  7512. local signal=$1; shift
  7513.  
  7514. if (( ! INFAKEROOT )); then
  7515. echo
  7516. error "$@"
  7517. fi
  7518. [[ -n $srclinks ]] && rm -rf "$srclinks"
  7519.  
  7520. # unset the trap for this signal, and then call the default handler
  7521. trap -- "$signal"
  7522. kill "-$signal" "$$"
  7523. }
  7524.  
  7525.  
  7526. ##
  7527. # Clean up function. Called automatically when the script exits.
  7528. ##
  7529. clean_up() {
  7530. local EXIT_CODE=$?
  7531.  
  7532. if (( INFAKEROOT )); then
  7533. # Don't clean up when leaving fakeroot, we're not done yet.
  7534. return 0
  7535. fi
  7536.  
  7537. if (( (EXIT_CODE == E_OK || EXIT_CODE == E_INSTALL_FAILED) && CLEANUP )); then
  7538. local pkg file
  7539.  
  7540. # If it's a clean exit and -c/--clean has been passed...
  7541. msg "$(gettext "Cleaning up...")"
  7542. rm -rf "$pkgdirbase" "$srcdir"
  7543. if [[ -n $pkgbase ]]; then
  7544. local fullver=$(get_full_version)
  7545. # Can't do this unless the BUILDSCRIPT has been sourced.
  7546. if (( PKGVERFUNC )); then
  7547. rm -f "${pkgbase}-${fullver}-${CARCH}-pkgver.log"*
  7548. fi
  7549. if (( PREPAREFUNC )); then
  7550. rm -f "${pkgbase}-${fullver}-${CARCH}-prepare.log"*
  7551. fi
  7552. if (( BUILDFUNC )); then
  7553. rm -f "${pkgbase}-${fullver}-${CARCH}-build.log"*
  7554. fi
  7555. if (( CHECKFUNC )); then
  7556. rm -f "${pkgbase}-${fullver}-${CARCH}-check.log"*
  7557. fi
  7558. if (( PKGFUNC )); then
  7559. rm -f "${pkgbase}-${fullver}-${CARCH}-package.log"*
  7560. elif (( SPLITPKG )); then
  7561. for pkg in ${pkgname[@]}; do
  7562. rm -f "${pkgbase}-${fullver}-${CARCH}-package_${pkg}.log"*
  7563. done
  7564. fi
  7565.  
  7566. # clean up dangling symlinks to packages
  7567. for pkg in ${pkgname[@]}; do
  7568. for file in ${pkg}-*-*-*{${PKGEXT},${SRCEXT}}; do
  7569. if [[ -h $file && ! -e $file ]]; then
  7570. rm -f "$file"
  7571. fi
  7572. done
  7573. done
  7574. fi
  7575. fi
  7576.  
  7577. remove_deps
  7578. }
  7579.  
  7580. enter_fakeroot() {
  7581. msg "$(gettext "Entering %s environment...")" "fakeroot"
  7582. fakeroot -- $0 -F "${ARGLIST[@]}" || exit $?
  7583. }
  7584.  
  7585. # Automatically update pkgver variable if a pkgver() function is provided
  7586. # Re-sources the PKGBUILD afterwards to allow for other variables that use $pkgver
  7587. update_pkgver() {
  7588. newpkgver=$(run_function_safe pkgver)
  7589. if ! check_pkgver "$newpkgver"; then
  7590. error "$(gettext "pkgver() generated an invalid version: %s")" "$newpkgver"
  7591. exit $E_PKGBUILD_ERROR
  7592. fi
  7593.  
  7594. if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then
  7595. if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then
  7596. if ! /usr/bin/sed --follow-symlinks -i "s:^pkgver=[^ ]*:pkgver=$newpkgver:" "$BUILDFILE"; then
  7597. error "$(gettext "Failed to update %s from %s to %s")" \
  7598. "pkgver" "$pkgver" "$newpkgver"
  7599. exit $E_PKGBUILD_ERROR
  7600. fi
  7601. /usr/bin/sed --follow-symlinks -i "s:^pkgrel=[^ ]*:pkgrel=1:" "$BUILDFILE"
  7602. source_safe "$BUILDFILE"
  7603. local fullver=$(get_full_version)
  7604. msg "$(gettext "Updated version: %s")" "$pkgbase $fullver"
  7605. else
  7606. warning "$(gettext "%s is not writeable -- pkgver will not be updated")" \
  7607. "$BUILDFILE"
  7608. fi
  7609. fi
  7610. }
  7611.  
  7612. # Print 'source not found' error message and exit makepkg
  7613. missing_source_file() {
  7614. error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")"
  7615. plain "$(gettext "Aborting...")"
  7616. exit $E_MISSING_FILE
  7617. }
  7618.  
  7619. run_pacman() {
  7620. local cmd
  7621. if [[ $1 != -@(T|Q)*([[:alpha:]]) ]]; then
  7622. cmd=("$PACMAN_PATH" "${PACMAN_OPTS[@]}" "$@")
  7623. else
  7624. cmd=("$PACMAN_PATH" "$@")
  7625. fi
  7626. if [[ $1 != -@(T|Q)*([[:alpha:]]) ]]; then
  7627. if type -p sudo >/dev/null; then
  7628. cmd=(sudo "${cmd[@]}")
  7629. else
  7630. cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
  7631. fi
  7632. fi
  7633. "${cmd[@]}"
  7634. }
  7635.  
  7636. check_deps() {
  7637. (( $# > 0 )) || return 0
  7638.  
  7639. local ret=0
  7640. local pmout
  7641. pmout=$(run_pacman -T "$@")
  7642. ret=$?
  7643.  
  7644. if (( ret == 127 )); then #unresolved deps
  7645. printf "%s\n" "$pmout"
  7646. elif (( ret )); then
  7647. error "$(gettext "'%s' returned a fatal error (%i): %s")" "$PACMAN" "$ret" "$pmout"
  7648. return "$ret"
  7649. fi
  7650. }
  7651.  
  7652. handle_deps() {
  7653. local R_DEPS_SATISFIED=0
  7654. local R_DEPS_MISSING=1
  7655.  
  7656. (( $# == 0 )) && return $R_DEPS_SATISFIED
  7657.  
  7658. local deplist=("$@")
  7659.  
  7660. if (( ! DEP_BIN )); then
  7661. return $R_DEPS_MISSING
  7662. fi
  7663.  
  7664. if (( DEP_BIN )); then
  7665. # install missing deps from binary packages (using pacman -S)
  7666. msg "$(gettext "Installing missing dependencies...")"
  7667.  
  7668. if ! run_pacman -S --asdeps "${deplist[@]}"; then
  7669. error "$(gettext "'%s' failed to install missing dependencies.")" "$PACMAN"
  7670. exit $E_INSTALL_DEPS_FAILED
  7671. fi
  7672. fi
  7673.  
  7674. # we might need the new system environment
  7675. # save our shell options and turn off extglob
  7676. local shellopts=$(shopt -p extglob)
  7677. shopt -u extglob
  7678. source /etc/profile &>/dev/null
  7679. eval "$shellopts"
  7680.  
  7681. # umask might have been changed in /etc/profile
  7682. # ensure that sane default is set again
  7683. umask 0022
  7684.  
  7685. return $R_DEPS_SATISFIED
  7686. }
  7687.  
  7688. resolve_deps() {
  7689. local R_DEPS_SATISFIED=0
  7690. local R_DEPS_MISSING=1
  7691.  
  7692. # deplist cannot be declared like this: local deplist=$(foo)
  7693. # Otherwise, the return value will depend on the assignment.
  7694. local deplist
  7695. deplist=($(check_deps "$@")) || exit $E_INSTALL_DEPS_FAILED
  7696. [[ -z $deplist ]] && return $R_DEPS_SATISFIED
  7697.  
  7698. if handle_deps "${deplist[@]}"; then
  7699. # check deps again to make sure they were resolved
  7700. deplist=$(check_deps "$@") || exit $E_INSTALL_DEPS_FAILED
  7701. [[ -z $deplist ]] && return $R_DEPS_SATISFIED
  7702. fi
  7703.  
  7704. msg "$(gettext "Missing dependencies:")"
  7705. local dep
  7706. for dep in ${deplist[@]}; do
  7707. msg2 "$dep"
  7708. done
  7709.  
  7710. return $R_DEPS_MISSING
  7711. }
  7712.  
  7713. remove_deps() {
  7714. (( ! RMDEPS )) && return 0
  7715.  
  7716. # check for packages removed during dependency install (e.g. due to conflicts)
  7717. # removing all installed packages is risky in this case
  7718. if [[ -n $(grep -xvFf <(printf '%s\n' "${current_pkglist[@]}") \
  7719. <(printf '%s\n' "${original_pkglist[@]}")) ]]; then
  7720. warning "$(gettext "Failed to remove installed dependencies.")"
  7721. return $E_REMOVE_DEPS_FAILED
  7722. fi
  7723.  
  7724. local deplist
  7725. deplist=($(grep -xvFf <(printf "%s\n" "${original_pkglist[@]}") \
  7726. <(printf "%s\n" "${current_pkglist[@]}")))
  7727. if [[ -z $deplist ]]; then
  7728. return 0
  7729. fi
  7730.  
  7731. msg "Removing installed dependencies..."
  7732. # exit cleanly on failure to remove deps as package has been built successfully
  7733. if ! run_pacman -Rn ${deplist[@]}; then
  7734. warning "$(gettext "Failed to remove installed dependencies.")"
  7735. return $E_REMOVE_DEPS_FAILED
  7736. fi
  7737. }
  7738.  
  7739. error_function() {
  7740. if [[ -p $logpipe ]]; then
  7741. rm "$logpipe"
  7742. fi
  7743. # first exit all subshells, then print the error
  7744. if (( ! BASH_SUBSHELL )); then
  7745. error "$(gettext "A failure occurred in %s().")" "$1"
  7746. plain "$(gettext "Aborting...")"
  7747. fi
  7748. exit $E_USER_FUNCTION_FAILED
  7749. }
  7750.  
  7751. source_safe() {
  7752. shopt -u extglob
  7753. if ! source "$@"; then
  7754. error "$(gettext "Failed to source %s")" "$1"
  7755. exit $E_MISSING_FILE
  7756. fi
  7757. shopt -s extglob
  7758. }
  7759.  
  7760. merge_arch_attrs() {
  7761. local attr supported_attrs=(
  7762. provides conflicts depends replaces optdepends
  7763. makedepends checkdepends)
  7764.  
  7765. for attr in "${supported_attrs[@]}"; do
  7766. eval "$attr+=(\"\${${attr}_$CARCH[@]}\")"
  7767. done
  7768.  
  7769. # ensure that calling this function is idempotent.
  7770. unset -v "${supported_attrs[@]/%/_$CARCH}"
  7771. }
  7772.  
  7773. source_buildfile() {
  7774. source_safe "$@"
  7775. }
  7776.  
  7777. prepare_buildenv() {
  7778. # clear user-specified buildflags if requested
  7779. if check_option "buildflags" "n"; then
  7780. unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
  7781. fi
  7782.  
  7783. if check_option "debug" "y"; then
  7784. DEBUG_CFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
  7785. DEBUG_CXXFLAGS+=" -fdebug-prefix-map=$srcdir=${DBGSRCDIR:-/usr/src/debug}"
  7786. CFLAGS+=" $DEBUG_CFLAGS"
  7787. CXXFLAGS+=" $DEBUG_CXXFLAGS"
  7788. fi
  7789.  
  7790. # clear user-specified makeflags if requested
  7791. if check_option "makeflags" "n"; then
  7792. unset MAKEFLAGS
  7793. fi
  7794.  
  7795. # ensure all necessary build variables are exported
  7796. export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
  7797.  
  7798. local ccache=0
  7799.  
  7800. # use ccache if it is requested (check buildenv and PKGBUILD opts)
  7801. if check_buildoption "ccache" "y" && [[ -d /usr/lib/ccache/bin ]]; then
  7802. export PATH="/usr/lib/ccache/bin:$PATH"
  7803. ccache=1
  7804. fi
  7805.  
  7806. # use distcc if it is requested (check buildenv and PKGBUILD opts)
  7807. if check_buildoption "distcc" "y"; then
  7808. if (( ccache )); then
  7809. export CCACHE_PREFIX="${CCACHE_PREFIX:+$CCACHE_PREFIX }distcc"
  7810. export CCACHE_BASEDIR="$srcdir"
  7811. elif [[ -d /usr/lib/distcc/bin ]]; then
  7812. export PATH="/usr/lib/distcc/bin:$PATH"
  7813. fi
  7814. export DISTCC_HOSTS
  7815. fi
  7816. }
  7817.  
  7818. run_function_safe() {
  7819. local restoretrap restoreset restoreshopt
  7820.  
  7821. # we don't set any special shopts of our own, but we don't want the user to
  7822. # muck with our environment.
  7823. restoreshopt=$(shopt -p)
  7824.  
  7825. restoreset=$(shopt -o -p)
  7826. shopt -o -s errexit errtrace
  7827.  
  7828. restoretrap=$(trap -p ERR)
  7829. trap "error_function '$1'" ERR
  7830.  
  7831. run_function "$1"
  7832.  
  7833. trap - ERR
  7834. eval "$restoretrap"
  7835. eval "$restoreset"
  7836. eval "$restoreshopt"
  7837. }
  7838.  
  7839. run_function() {
  7840. if [[ -z $1 ]]; then
  7841. return 1
  7842. fi
  7843. local pkgfunc="$1"
  7844.  
  7845. msg "$(gettext "Starting %s()...")" "$pkgfunc"
  7846. cd_safe "$srcdir"
  7847.  
  7848. # save our shell options so pkgfunc() can't override what we need
  7849. local shellopts=$(shopt -p)
  7850.  
  7851. local ret=0
  7852. if (( LOGGING )); then
  7853. local fullver=$(get_full_version)
  7854. local BUILDLOG="$LOGDEST/${pkgbase}-${fullver}-${CARCH}-$pkgfunc.log"
  7855. if [[ -f $BUILDLOG ]]; then
  7856. local i=1
  7857. while true; do
  7858. if [[ -f $BUILDLOG.$i ]]; then
  7859. i=$(($i +1))
  7860. else
  7861. break
  7862. fi
  7863. done
  7864. mv "$BUILDLOG" "$BUILDLOG.$i"
  7865. fi
  7866.  
  7867. # ensure overridden package variables survive tee with split packages
  7868. logpipe=$(mktemp -u "$LOGDEST/logpipe.XXXXXXXX")
  7869. mkfifo "$logpipe"
  7870. tee "$BUILDLOG" < "$logpipe" &
  7871. local teepid=$!
  7872.  
  7873. $pkgfunc &>"$logpipe"
  7874.  
  7875. wait $teepid
  7876. rm "$logpipe"
  7877. else
  7878. "$pkgfunc"
  7879. fi
  7880. # reset our shell options
  7881. eval "$shellopts"
  7882. }
  7883.  
  7884. run_prepare() {
  7885. run_function_safe "prepare"
  7886. }
  7887.  
  7888. run_build() {
  7889. run_function_safe "build"
  7890. }
  7891.  
  7892. run_check() {
  7893. run_function_safe "check"
  7894. }
  7895.  
  7896. run_package() {
  7897. local pkgfunc
  7898. if [[ -z $1 ]]; then
  7899. pkgfunc="package"
  7900. else
  7901. pkgfunc="package_$1"
  7902. fi
  7903.  
  7904. run_function_safe "$pkgfunc"
  7905. }
  7906.  
  7907. find_libdepends() {
  7908. local d sodepends;
  7909.  
  7910. sodepends=0;
  7911. for d in "${depends[@]}"; do
  7912. if [[ $d = *.so ]]; then
  7913. sodepends=1;
  7914. break;
  7915. fi
  7916. done
  7917.  
  7918. if (( sodepends == 0 )); then
  7919. (( ${#depends[@]} )) && printf '%s\n' "${depends[@]}"
  7920. return 0
  7921. fi
  7922.  
  7923. local libdeps filename soarch sofile soname soversion;
  7924. declare -A libdeps;
  7925.  
  7926. while read -r filename; do
  7927. # get architecture of the file; if soarch is empty it's not an ELF binary
  7928. soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
  7929. [[ -n "$soarch" ]] || continue
  7930.  
  7931. # process all libraries needed by the binary
  7932. for sofile in $(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p')
  7933. do
  7934. # extract the library name: libfoo.so
  7935. soname="${sofile%.so?(+(.+([0-9])))}".so
  7936. # extract the major version: 1
  7937. soversion="${sofile##*\.so\.}"
  7938.  
  7939. if [[ ${libdeps[$soname]} ]]; then
  7940. if [[ ${libdeps[$soname]} != *${soversion}-${soarch}* ]]; then
  7941. libdeps[$soname]+=" ${soversion}-${soarch}"
  7942. fi
  7943. else
  7944. libdeps[$soname]="${soversion}-${soarch}"
  7945. fi
  7946. done
  7947. done < <(find "$pkgdir" -type f -perm -u+x)
  7948.  
  7949. local libdepends v
  7950. for d in "${depends[@]}"; do
  7951. case "$d" in
  7952. *.so)
  7953. if [[ ${libdeps[$d]} ]]; then
  7954. for v in ${libdeps[$d]}; do
  7955. libdepends+=("$d=$v")
  7956. done
  7957. else
  7958. warning "$(gettext "Library listed in %s is not required by any files: %s")" "'depends'" "$d"
  7959. libdepends+=("$d")
  7960. fi
  7961. ;;
  7962. *)
  7963. libdepends+=("$d")
  7964. ;;
  7965. esac
  7966. done
  7967.  
  7968. (( ${#libdepends[@]} )) && printf '%s\n' "${libdepends[@]}"
  7969. }
  7970.  
  7971.  
  7972. find_libprovides() {
  7973. local p libprovides missing
  7974. for p in "${provides[@]}"; do
  7975. missing=0
  7976. case "$p" in
  7977. *.so)
  7978. mapfile -t filename < <(find "$pkgdir" -type f -name $p\*)
  7979. if [[ $filename ]]; then
  7980. # packages may provide multiple versions of the same library
  7981. for fn in "${filename[@]}"; do
  7982. # check if we really have a shared object
  7983. if LC_ALL=C readelf -h "$fn" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
  7984. # get the string binaries link to (e.g. libfoo.so.1.2 -> libfoo.so.1)
  7985. local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
  7986. if [[ -z "$sofile" ]]; then
  7987. warning "$(gettext "Library listed in %s is not versioned: %s")" "'provides'" "$p"
  7988. libprovides+=("$p")
  7989. continue
  7990. fi
  7991.  
  7992. # get the library architecture (32 or 64 bit)
  7993. local soarch=$(LC_ALL=C readelf -h "$fn" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
  7994.  
  7995. # extract the library major version
  7996. local soversion="${sofile##*\.so\.}"
  7997.  
  7998. libprovides+=("${p}=${soversion}-${soarch}")
  7999. else
  8000. warning "$(gettext "Library listed in %s is not a shared object: %s")" "'provides'" "$p"
  8001. libprovides+=("$p")
  8002. fi
  8003. done
  8004. else
  8005. libprovides+=("$p")
  8006. missing=1
  8007. fi
  8008. ;;
  8009. *)
  8010. libprovides+=("$p")
  8011. ;;
  8012. esac
  8013.  
  8014. if (( missing )); then
  8015. warning "$(gettext "Cannot find library listed in %s: %s")" "'provides'" "$p"
  8016. fi
  8017. done
  8018.  
  8019. (( ${#libprovides[@]} )) && printf '%s\n' "${libprovides[@]}"
  8020. }
  8021.  
  8022. write_kv_pair() {
  8023. local key="$1"
  8024. shift
  8025.  
  8026. for val in "$@"; do
  8027. if [[ $val = *$'\n'* ]]; then
  8028. error "$(gettext "Invalid value for %s: %s")" "$key" "$val"
  8029. exit $E_PKGBUILD_ERROR
  8030. fi
  8031. printf "%s = %s\n" "$key" "$val"
  8032. done
  8033. }
  8034.  
  8035. write_pkginfo() {
  8036. local size="$(/usr/bin/du -sk --apparent-size)"
  8037. size="$(( ${size%%[^0-9]*} * 1024 ))"
  8038.  
  8039. merge_arch_attrs
  8040.  
  8041. msg2 "$(gettext "Generating %s file...")" ".PKGINFO"
  8042. printf "# Generated by makepkg %s\n" "$makepkg_version"
  8043. printf "# using %s\n" "$(fakeroot -v)"
  8044.  
  8045. write_kv_pair "pkgname" "$pkgname"
  8046. write_kv_pair "pkgbase" "$pkgbase"
  8047.  
  8048. local fullver=$(get_full_version)
  8049. write_kv_pair "pkgver" "$fullver"
  8050.  
  8051. # TODO: all fields should have this treatment
  8052. local spd="${pkgdesc//+([[:space:]])/ }"
  8053. spd=("${spd[@]#[[:space:]]}")
  8054. spd=("${spd[@]%[[:space:]]}")
  8055.  
  8056. write_kv_pair "pkgdesc" "$spd"
  8057. write_kv_pair "url" "$url"
  8058. write_kv_pair "builddate" "$SOURCE_DATE_EPOCH"
  8059. write_kv_pair "packager" "$PACKAGER"
  8060. write_kv_pair "size" "$size"
  8061. write_kv_pair "arch" "$pkgarch"
  8062.  
  8063. mapfile -t provides < <(find_libprovides)
  8064. mapfile -t depends < <(find_libdepends)
  8065.  
  8066. write_kv_pair "license" "${license[@]}"
  8067. write_kv_pair "replaces" "${replaces[@]}"
  8068. write_kv_pair "group" "${groups[@]}"
  8069. write_kv_pair "conflict" "${conflicts[@]}"
  8070. write_kv_pair "provides" "${provides[@]}"
  8071. write_kv_pair "backup" "${backup[@]}"
  8072. write_kv_pair "depend" "${depends[@]}"
  8073. write_kv_pair "optdepend" "${optdepends[@]//+([[:space:]])/ }"
  8074. write_kv_pair "makedepend" "${makedepends[@]}"
  8075. write_kv_pair "checkdepend" "${checkdepends[@]}"
  8076. }
  8077.  
  8078. write_buildinfo() {
  8079. msg2 "$(gettext "Generating %s file...")" ".BUILDINFO"
  8080.  
  8081. write_kv_pair "format" "1"
  8082.  
  8083. write_kv_pair "pkgname" "$pkgname"
  8084. write_kv_pair "pkgbase" "$pkgbase"
  8085.  
  8086. local fullver=$(get_full_version)
  8087. write_kv_pair "pkgver" "$fullver"
  8088.  
  8089. write_kv_pair "pkgarch" "$pkgarch"
  8090.  
  8091. local sum="$(sha256sum "${BUILDFILE}")"
  8092. sum=${sum%% *}
  8093. write_kv_pair "pkgbuild_sha256sum" $sum
  8094.  
  8095. write_kv_pair "packager" "${PACKAGER}"
  8096. write_kv_pair "builddate" "${SOURCE_DATE_EPOCH}"
  8097. write_kv_pair "builddir" "${BUILDDIR}"
  8098. write_kv_pair "buildenv" "${BUILDENV[@]}"
  8099. write_kv_pair "options" "${OPTIONS[@]}"
  8100.  
  8101. local pkginfos_parsed=($(LC_ALL=C run_pacman -Qi | awk -F': ' '\
  8102. /^Name .*/ {printf "%s", $2} \
  8103. /^Version .*/ {printf "-%s", $2} \
  8104. /^Architecture .*/ {print "-"$2} \
  8105. '))
  8106.  
  8107. write_kv_pair "installed" "${pkginfos_parsed[@]}"
  8108. }
  8109.  
  8110. # build a sorted NUL-separated list of the full contents of the current
  8111. # directory suitable for passing to `bsdtar --files-from`
  8112. # database files are placed at the beginning of the package regardless of
  8113. # sorting
  8114. list_package_files() {
  8115. (find . -path './.*' \! -name '.'; find . \! -path './.*' \! -name '.' | LC_ALL=C sort) |
  8116. sed -e 's|^\./||' | tr '\n' '\0'
  8117. }
  8118.  
  8119. create_package() {
  8120. (( NOARCHIVE )) && return 0
  8121.  
  8122. if [[ ! -d $pkgdir ]]; then
  8123. error "$(gettext "Missing %s directory.")" "\$pkgdir/"
  8124. plain "$(gettext "Aborting...")"
  8125. exit $E_MISSING_PKGDIR
  8126. fi
  8127.  
  8128. cd_safe "$pkgdir"
  8129. msg "$(gettext "Creating package \"%s\"...")" "$pkgname"
  8130.  
  8131. pkgarch=$(get_pkg_arch)
  8132. write_pkginfo > .PKGINFO
  8133. write_buildinfo > .BUILDINFO
  8134.  
  8135. # check for changelog/install files
  8136. for i in 'changelog/.CHANGELOG' 'install/.INSTALL'; do
  8137. IFS='/' read -r orig dest < <(printf '%s\n' "$i")
  8138.  
  8139. if [[ -n ${!orig} ]]; then
  8140. msg2 "$(gettext "Adding %s file...")" "$orig"
  8141. if ! cp "$startdir/${!orig}" "$dest"; then
  8142. error "$(gettext "Failed to add %s file to package.")" "$orig"
  8143. exit $E_MISSING_FILE
  8144. fi
  8145. chmod 644 "$dest"
  8146. fi
  8147. done
  8148.  
  8149. # tar it up
  8150. local fullver=$(get_full_version)
  8151. local pkg_file="$PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT}"
  8152. local ret=0
  8153.  
  8154. [[ -f $pkg_file ]] && rm -f "$pkg_file"
  8155. [[ -f $pkg_file.sig ]] && rm -f "$pkg_file.sig"
  8156.  
  8157. # ensure all elements of the package have the same mtime
  8158. find . -exec touch -h -d @$SOURCE_DATE_EPOCH {} +
  8159.  
  8160. msg2 "$(gettext "Generating .MTREE file...")"
  8161. list_package_files | LANG=C bsdtar -cnf - --format=mtree \
  8162. --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
  8163. --null --files-from - --exclude .MTREE | gzip -c -f -n > .MTREE
  8164. touch -d @$SOURCE_DATE_EPOCH .MTREE
  8165.  
  8166. msg2 "$(gettext "Compressing package...")"
  8167. # TODO: Maybe this can be set globally for robustness
  8168. shopt -s -o pipefail
  8169. list_package_files | LANG=C bsdtar -cnf - --null --files-from - |
  8170. compress_as "$PKGEXT" > "${pkg_file}" || ret=$?
  8171.  
  8172. shopt -u -o pipefail
  8173.  
  8174. if (( ret )); then
  8175. error "$(gettext "Failed to create package file.")"
  8176. exit $E_PACKAGE_FAILED
  8177. fi
  8178. }
  8179.  
  8180. create_debug_package() {
  8181. # check if a debug package was requested
  8182. if ! check_option "debug" "y" || ! check_option "strip" "y"; then
  8183. return 0
  8184. fi
  8185.  
  8186. pkgdir="$pkgdirbase/$pkgbase-debug"
  8187.  
  8188. # check if we have any debug symbols to package
  8189. if dir_is_empty "$pkgdir/usr/lib/debug"; then
  8190. return 0
  8191. fi
  8192.  
  8193. unset groups depends optdepends provides conflicts replaces backup install changelog
  8194.  
  8195. local pkg
  8196. for pkg in ${pkgname[@]}; do
  8197. if [[ $pkg != $pkgbase ]]; then
  8198. provides+=("$pkg-debug")
  8199. fi
  8200. done
  8201.  
  8202. pkgdesc="Detached debugging symbols for $pkgname"
  8203. pkgname=$pkgbase-debug
  8204.  
  8205. create_package
  8206. }
  8207.  
  8208. create_srcpackage() {
  8209. local ret=0
  8210. msg "$(gettext "Creating source package...")"
  8211. local srclinks="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)"
  8212. mkdir "${srclinks}"/${pkgbase}
  8213.  
  8214. msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT"
  8215. ln -s "${BUILDFILE}" "${srclinks}/${pkgbase}/${BUILDSCRIPT}"
  8216.  
  8217. msg2 "$(gettext "Generating %s file...")" .SRCINFO
  8218. write_srcinfo > "$srclinks/$pkgbase"/.SRCINFO
  8219.  
  8220. local file all_sources
  8221.  
  8222. get_all_sources 'all_sources'
  8223. for file in "${all_sources[@]}"; do
  8224. if [[ "$file" = "$(get_filename "$file")" ]] || (( SOURCEONLY == 2 )); then
  8225. local absfile
  8226. absfile=$(get_filepath "$file") || missing_source_file "$file"
  8227. msg2 "$(gettext "Adding %s...")" "${absfile##*/}"
  8228. ln -s "$absfile" "$srclinks/$pkgbase"
  8229. fi
  8230. done
  8231.  
  8232. local i
  8233. for i in 'changelog' 'install'; do
  8234. local file files
  8235.  
  8236. [[ ${!i} ]] && files+=("${!i}")
  8237. for name in "${pkgname[@]}"; do
  8238. if extract_function_variable "package_$name" "$i" 0 file; then
  8239. files+=("$file")
  8240. fi
  8241. done
  8242.  
  8243. for file in "${files[@]}"; do
  8244. if [[ $file && ! -f "${srclinks}/${pkgbase}/$file" ]]; then
  8245. msg2 "$(gettext "Adding %s file (%s)...")" "$i" "${file}"
  8246. ln -s "${startdir}/$file" "${srclinks}/${pkgbase}/"
  8247. fi
  8248. done
  8249. done
  8250.  
  8251. local fullver=$(get_full_version)
  8252. local pkg_file="$SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT}"
  8253.  
  8254. # tar it up
  8255. msg2 "$(gettext "Compressing source package...")"
  8256. cd_safe "${srclinks}"
  8257.  
  8258. # TODO: Maybe this can be set globally for robustness
  8259. shopt -s -o pipefail
  8260. LANG=C bsdtar -cLf - ${pkgbase} | compress_as "$SRCEXT" > "${pkg_file}" || ret=$?
  8261.  
  8262. shopt -u -o pipefail
  8263.  
  8264. if (( ret )); then
  8265. error "$(gettext "Failed to create source package file.")"
  8266. exit $E_PACKAGE_FAILED
  8267. fi
  8268.  
  8269. cd_safe "${startdir}"
  8270. rm -rf "${srclinks}"
  8271. }
  8272.  
  8273. install_package() {
  8274. (( ! INSTALL )) && return 0
  8275.  
  8276. if (( ! SPLITPKG )); then
  8277. msg "$(gettext "Installing package %s with %s...")" "$pkgname" "$PACMAN -U"
  8278. else
  8279. msg "$(gettext "Installing %s package group with %s...")" "$pkgbase" "$PACMAN -U"
  8280. fi
  8281.  
  8282. local fullver pkgarch pkg pkglist
  8283. (( ASDEPS )) && pkglist+=('--asdeps')
  8284. (( NEEDED )) && pkglist+=('--needed')
  8285.  
  8286. for pkg in ${pkgname[@]}; do
  8287. fullver=$(get_full_version)
  8288. pkgarch=$(get_pkg_arch $pkg)
  8289. pkglist+=("$PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT}")
  8290.  
  8291. if [[ -f "$PKGDEST/${pkg}-debug-${fullver}-${pkgarch}${PKGEXT}" ]]; then
  8292. pkglist+=("$PKGDEST/${pkg}-debug-${fullver}-${pkgarch}${PKGEXT}")
  8293. fi
  8294. done
  8295.  
  8296. if ! run_pacman -U "${pkglist[@]}"; then
  8297. warning "$(gettext "Failed to install built package(s).")"
  8298. return $E_INSTALL_FAILED
  8299. fi
  8300. }
  8301.  
  8302. get_vcsclient() {
  8303. local proto=${1%%+*}
  8304.  
  8305. local i
  8306. for i in "${VCSCLIENTS[@]}"; do
  8307. local handler="${i%%::*}"
  8308. if [[ $proto = "$handler" ]]; then
  8309. local client="${i##*::}"
  8310. break
  8311. fi
  8312. done
  8313.  
  8314. # if we didn't find an client, return an error
  8315. if [[ -z $client ]]; then
  8316. error "$(gettext "Unknown download protocol: %s")" "$proto"
  8317. plain "$(gettext "Aborting...")"
  8318. exit $E_CONFIG_ERROR
  8319. fi
  8320.  
  8321. printf "%s\n" "$client"
  8322. }
  8323.  
  8324. check_vcs_software() {
  8325. local netfile all_sources all_deps deps ret=0
  8326.  
  8327. if (( SOURCEONLY == 1 )); then
  8328. # we will not download VCS sources
  8329. return $ret
  8330. fi
  8331.  
  8332. if [[ -z $PACMAN_PATH ]]; then
  8333. warning "$(gettext "Cannot find the %s binary needed to check VCS source requirements.")" "$PACMAN"
  8334. return $ret
  8335. fi
  8336.  
  8337. # we currently only use global depends/makedepends arrays for --syncdeps
  8338. for attr in depends makedepends; do
  8339. get_pkgbuild_attribute "$pkg" "$attr" 1 'deps'
  8340. all_deps+=("${deps[@]}")
  8341.  
  8342. get_pkgbuild_attribute "$pkg" "${attr}_$CARCH" 1 'deps'
  8343. all_deps+=("${deps[@]}")
  8344. done
  8345.  
  8346. get_all_sources_for_arch 'all_sources'
  8347. for netfile in ${all_sources[@]}; do
  8348. local proto=$(get_protocol "$netfile")
  8349.  
  8350. case $proto in
  8351. bzr*|git*|hg*|svn*)
  8352. if ! type -p ${proto%%+*} > /dev/null; then
  8353. local client
  8354. client=$(get_vcsclient "$proto") || exit $?
  8355. # ensure specified program is installed
  8356. local uninstalled
  8357. uninstalled=$(check_deps "$client") || exit $E_INSTALL_DEPS_FAILED
  8358. # if not installed, check presence in depends or makedepends
  8359. if [[ -n "$uninstalled" ]] && (( ! NODEPS || ( VERIFYSOURCE && !DEP_BIN ) )); then
  8360. if ! in_array "$client" ${all_deps[@]}; then
  8361. error "$(gettext "Cannot find the %s package needed to handle %s sources.")" \
  8362. "$client" "${proto%%+*}"
  8363. ret=1
  8364. fi
  8365. fi
  8366. fi
  8367. ;;
  8368. *)
  8369. # non VCS source
  8370. ;;
  8371. esac
  8372. done
  8373.  
  8374. return $ret
  8375. }
  8376.  
  8377. check_software() {
  8378. # check for needed software
  8379. local ret=0
  8380.  
  8381. # check for PACMAN if we need it
  8382. if (( ! NODEPS || DEP_BIN || RMDEPS || INSTALL )); then
  8383. if [[ -z $PACMAN_PATH ]]; then
  8384. error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN"
  8385. ret=1
  8386. fi
  8387. fi
  8388.  
  8389. # check for sudo if we will need it during makepkg execution
  8390. if (( DEP_BIN || RMDEPS || INSTALL )); then
  8391. if ! type -p sudo >/dev/null; then
  8392. warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su"
  8393. fi
  8394. fi
  8395.  
  8396. # fakeroot - correct package file permissions
  8397. if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then
  8398. if ! type -p fakeroot >/dev/null; then
  8399. error "$(gettext "Cannot find the %s binary.")" "fakeroot"
  8400. ret=1
  8401. fi
  8402. fi
  8403.  
  8404. # gpg - package signing
  8405. if [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; then
  8406. if ! type -p gpg >/dev/null; then
  8407. error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg"
  8408. ret=1
  8409. fi
  8410. fi
  8411.  
  8412. # gpg - source verification
  8413. if (( ! SKIPPGPCHECK )) && source_has_signatures; then
  8414. if ! type -p gpg >/dev/null; then
  8415. error "$(gettext "Cannot find the %s binary required for verifying source files.")" "gpg"
  8416. ret=1
  8417. fi
  8418. fi
  8419.  
  8420. # checksum operations
  8421. if (( GENINTEG || ! SKIPCHECKSUMS )); then
  8422. local integlist
  8423. IFS=$'\n' read -rd '' -a integlist < <(get_integlist)
  8424.  
  8425. local integ
  8426. for integ in "${integlist[@]}"; do
  8427. if ! type -p "${integ}sum" >/dev/null; then
  8428. error "$(gettext "Cannot find the %s binary required for source file checksums operations.")" "${integ}sum"
  8429. ret=1
  8430. fi
  8431. done
  8432. fi
  8433.  
  8434. # distcc - compilation with distcc
  8435. if check_buildoption "distcc" "y"; then
  8436. if ! type -p distcc >/dev/null; then
  8437. error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc"
  8438. ret=1
  8439. fi
  8440. fi
  8441.  
  8442. # ccache - compilation with ccache
  8443. if check_buildoption "ccache" "y"; then
  8444. if ! type -p ccache >/dev/null; then
  8445. error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache"
  8446. ret=1
  8447. fi
  8448. fi
  8449.  
  8450. # strip - strip symbols from binaries/libraries
  8451. if check_option "strip" "y"; then
  8452. if ! type -p strip >/dev/null; then
  8453. error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip"
  8454. ret=1
  8455. fi
  8456. fi
  8457.  
  8458. # gzip - compressig man and info pages
  8459. if check_option "zipman" "y"; then
  8460. if ! type -p gzip >/dev/null; then
  8461. error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip"
  8462. ret=1
  8463. fi
  8464. fi
  8465.  
  8466. # tools to download vcs sources
  8467. if ! check_vcs_software; then
  8468. ret=1
  8469. fi
  8470.  
  8471. return $ret
  8472. }
  8473.  
  8474. check_build_status() {
  8475. if (( ! SPLITPKG )); then
  8476. fullver=$(get_full_version)
  8477. pkgarch=$(get_pkg_arch)
  8478. if [[ -f $PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT} ]] \
  8479. && ! (( FORCE || SOURCEONLY || NOBUILD || NOARCHIVE)); then
  8480. if (( INSTALL )); then
  8481. warning "$(gettext "A package has already been built, installing existing package...")"
  8482. install_package
  8483. exit $?
  8484. else
  8485. error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f"
  8486. exit $E_ALREADY_BUILT
  8487. fi
  8488. fi
  8489. else
  8490. allpkgbuilt=1
  8491. somepkgbuilt=0
  8492. for pkg in ${pkgname[@]}; do
  8493. fullver=$(get_full_version)
  8494. pkgarch=$(get_pkg_arch $pkg)
  8495. if [[ -f $PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT} ]]; then
  8496. somepkgbuilt=1
  8497. else
  8498. allpkgbuilt=0
  8499. fi
  8500. done
  8501. if ! (( FORCE || SOURCEONLY || NOBUILD || NOARCHIVE)); then
  8502. if (( allpkgbuilt )); then
  8503. if (( INSTALL )); then
  8504. warning "$(gettext "The package group has already been built, installing existing packages...")"
  8505. install_package
  8506. exit $?
  8507. else
  8508. error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f"
  8509. exit $E_ALREADY_BUILT
  8510. fi
  8511. fi
  8512. if (( somepkgbuilt && ! PKGVERFUNC )); then
  8513. error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f"
  8514. exit $E_ALREADY_BUILT
  8515. fi
  8516. fi
  8517. unset allpkgbuilt somepkgbuilt
  8518. fi
  8519. }
  8520.  
  8521. backup_package_variables() {
  8522. local var
  8523. for var in ${splitpkg_overrides[@]}; do
  8524. local indirect="${var}_backup"
  8525. eval "${indirect}=(\"\${$var[@]}\")"
  8526. done
  8527. }
  8528.  
  8529. restore_package_variables() {
  8530. local var
  8531. for var in ${splitpkg_overrides[@]}; do
  8532. local indirect="${var}_backup"
  8533. if [[ -n ${!indirect} ]]; then
  8534. eval "${var}=(\"\${$indirect[@]}\")"
  8535. else
  8536. unset ${var}
  8537. fi
  8538. done
  8539. }
  8540.  
  8541. run_split_packaging() {
  8542. local pkgname_backup=("${pkgname[@]}")
  8543. for pkgname in ${pkgname_backup[@]}; do
  8544. pkgdir="$pkgdirbase/$pkgname"
  8545. mkdir "$pkgdir"
  8546. backup_package_variables
  8547. run_package $pkgname
  8548. tidy_install
  8549. lint_package || exit $E_PACKAGE_FAILED
  8550. create_package
  8551. restore_package_variables
  8552. done
  8553. pkgname=("${pkgname_backup[@]}")
  8554. create_debug_package
  8555. }
  8556.  
  8557. usage() {
  8558. printf "makepkg (pacman) %s\n" "$makepkg_version"
  8559. echo
  8560. printf -- "$(gettext "Make packages compatible for use with pacman")\n"
  8561. echo
  8562. printf -- "$(gettext "Usage: %s [options]")\n" "$0"
  8563. echo
  8564. printf -- "$(gettext "Options:")\n"
  8565. printf -- "$(gettext " -A, --ignorearch Ignore incomplete %s field in %s")\n" "arch" "$BUILDSCRIPT"
  8566. printf -- "$(gettext " -c, --clean Clean up work files after build")\n"
  8567. printf -- "$(gettext " -C, --cleanbuild Remove %s dir before building the package")\n" "\$srcdir/"
  8568. printf -- "$(gettext " -d, --nodeps Skip all dependency checks")\n"
  8569. printf -- "$(gettext " -e, --noextract Do not extract source files (use existing %s dir)")\n" "\$srcdir/"
  8570. printf -- "$(gettext " -f, --force Overwrite existing package")\n"
  8571. printf -- "$(gettext " -g, --geninteg Generate integrity checks for source files")\n"
  8572. printf -- "$(gettext " -h, --help Show this help message and exit")\n"
  8573. printf -- "$(gettext " -i, --install Install package after successful build")\n"
  8574. printf -- "$(gettext " -L, --log Log package build process")\n"
  8575. printf -- "$(gettext " -m, --nocolor Disable colorized output messages")\n"
  8576. printf -- "$(gettext " -o, --nobuild Download and extract files only")\n"
  8577. printf -- "$(gettext " -p <file> Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT"
  8578. printf -- "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build")\n"
  8579. printf -- "$(gettext " -R, --repackage Repackage contents of the package without rebuilding")\n"
  8580. printf -- "$(gettext " -s, --syncdeps Install missing dependencies with %s")\n" "pacman"
  8581. printf -- "$(gettext " -S, --source Generate a source-only tarball without downloaded sources")\n"
  8582. printf -- "$(gettext " -V, --version Show version information and exit")\n"
  8583. printf -- "$(gettext " --allsource Generate a source-only tarball including downloaded sources")\n"
  8584. printf -- "$(gettext " --check Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
  8585. printf -- "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
  8586. printf -- "$(gettext " --holdver Do not update VCS sources")\n"
  8587. printf -- "$(gettext " --key <key> Specify a key to use for %s signing instead of the default")\n" "gpg"
  8588. printf -- "$(gettext " --noarchive Do not create package archive")\n"
  8589. printf -- "$(gettext " --nocheck Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
  8590. printf -- "$(gettext " --noprepare Do not run the %s function in the %s")\n" "prepare()" "$BUILDSCRIPT"
  8591. printf -- "$(gettext " --nosign Do not create a signature for the package")\n"
  8592. printf -- "$(gettext " --packagelist Only list package filepaths that would be produced")\n"
  8593. printf -- "$(gettext " --printsrcinfo Print the generated SRCINFO and exit")\n"
  8594. printf -- "$(gettext " --sign Sign the resulting package with %s")\n" "gpg"
  8595. printf -- "$(gettext " --skipchecksums Do not verify checksums of the source files")\n"
  8596. printf -- "$(gettext " --skipinteg Do not perform any verification checks on source files")\n"
  8597. printf -- "$(gettext " --skippgpcheck Do not verify source files with PGP signatures")\n"
  8598. printf -- "$(gettext " --verifysource Download source files (if needed) and perform integrity checks")\n"
  8599. echo
  8600. printf -- "$(gettext "These options can be passed to %s:")\n" "pacman"
  8601. echo
  8602. printf -- "$(gettext " --asdeps Install packages as non-explicitly installed")\n"
  8603. printf -- "$(gettext " --needed Do not reinstall the targets that are already up to date")\n"
  8604. printf -- "$(gettext " --noconfirm Do not ask for confirmation when resolving dependencies")\n"
  8605. printf -- "$(gettext " --noprogressbar Do not show a progress bar when downloading files")\n"
  8606. echo
  8607. printf -- "$(gettext "If %s is not specified, %s will look for '%s'")\n" "-p" "makepkg" "$BUILDSCRIPT"
  8608. echo
  8609. }
  8610.  
  8611. version() {
  8612. printf "makepkg (pacman) %s\n" "$makepkg_version"
  8613. printf -- "$(gettext "\
  8614. Copyright (c) 2006-2018 Pacman Development Team <pacman-dev@archlinux.org>.\n\
  8615. Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>.\n\n\
  8616. This is free software; see the source for copying conditions.\n\
  8617. There is NO WARRANTY, to the extent permitted by law.\n")"
  8618. }
  8619.  
  8620. # PROGRAM START
  8621.  
  8622. # ensure we have a sane umask set
  8623. umask 0022
  8624. + umask 0022
  8625.  
  8626. # determine whether we have gettext; make it a no-op if we do not
  8627. if ! type -p gettext >/dev/null; then
  8628. gettext() {
  8629. printf "%s\n" "$@"
  8630. }
  8631. fi
  8632. + type -p gettext
  8633.  
  8634. ARGLIST=("$@")
  8635. + ARGLIST=("$@")
  8636.  
  8637. # Parse Command Line Options.
  8638. OPT_SHORT="AcCdefFghiLmop:rRsSV"
  8639. + OPT_SHORT=AcCdefFghiLmop:rRsSV
  8640. OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'force' 'geninteg'
  8641. 'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'noarchive' 'nobuild'
  8642. 'nocolor' 'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign' 'packagelist'
  8643. 'printsrcinfo' 'repackage' 'rmdeps' 'sign' 'skipchecksums' 'skipinteg'
  8644. 'skippgpcheck' 'source' 'syncdeps' 'verifysource' 'version')
  8645. + OPT_LONG=('allsource' 'check' 'clean' 'cleanbuild' 'config:' 'force' 'geninteg' 'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'noarchive' 'nobuild' 'nocolor' 'nocheck' 'nodeps' 'noextract' 'noprepare' 'nosign' 'packagelist' 'printsrcinfo' 'repackage' 'rmdeps' 'sign' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'source' 'syncdeps' 'verifysource' 'version')
  8646.  
  8647. # Pacman Options
  8648. OPT_LONG+=('asdeps' 'noconfirm' 'needed' 'noprogressbar')
  8649. + OPT_LONG+=('asdeps' 'noconfirm' 'needed' 'noprogressbar')
  8650.  
  8651. if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
  8652. exit $E_INVALID_OPTION;
  8653. fi
  8654. + parseopts AcCdefFghiLmop:rRsSV allsource check clean cleanbuild config: force geninteg help holdver ignorearch install key: log noarchive nobuild nocolor nocheck nodeps noextract noprepare nosign packagelist printsrcinfo repackage rmdeps sign skipchecksums skipinteg skippgpcheck source syncdeps verifysource version asdeps noconfirm needed noprogressbar --
  8655. + local opt= optarg= i= shortopts=AcCdefFghiLmop:rRsSV
  8656. + longopts=()
  8657. + unused_argv=()
  8658. + local -a longopts unused_argv
  8659. + shift
  8660. + [[ -n allsource ]]
  8661. + [[ allsource != \-\- ]]
  8662. + longopts+=("$1")
  8663. + shift
  8664. + [[ -n check ]]
  8665. + [[ check != \-\- ]]
  8666. + longopts+=("$1")
  8667. + shift
  8668. + [[ -n clean ]]
  8669. + [[ clean != \-\- ]]
  8670. + longopts+=("$1")
  8671. + shift
  8672. + [[ -n cleanbuild ]]
  8673. + [[ cleanbuild != \-\- ]]
  8674. + longopts+=("$1")
  8675. + shift
  8676. + [[ -n config: ]]
  8677. + [[ config: != \-\- ]]
  8678. + longopts+=("$1")
  8679. + shift
  8680. + [[ -n force ]]
  8681. + [[ force != \-\- ]]
  8682. + longopts+=("$1")
  8683. + shift
  8684. + [[ -n geninteg ]]
  8685. + [[ geninteg != \-\- ]]
  8686. + longopts+=("$1")
  8687. + shift
  8688. + [[ -n help ]]
  8689. + [[ help != \-\- ]]
  8690. + longopts+=("$1")
  8691. + shift
  8692. + [[ -n holdver ]]
  8693. + [[ holdver != \-\- ]]
  8694. + longopts+=("$1")
  8695. + shift
  8696. + [[ -n ignorearch ]]
  8697. + [[ ignorearch != \-\- ]]
  8698. + longopts+=("$1")
  8699. + shift
  8700. + [[ -n install ]]
  8701. + [[ install != \-\- ]]
  8702. + longopts+=("$1")
  8703. + shift
  8704. + [[ -n key: ]]
  8705. + [[ key: != \-\- ]]
  8706. + longopts+=("$1")
  8707. + shift
  8708. + [[ -n log ]]
  8709. + [[ log != \-\- ]]
  8710. + longopts+=("$1")
  8711. + shift
  8712. + [[ -n noarchive ]]
  8713. + [[ noarchive != \-\- ]]
  8714. + longopts+=("$1")
  8715. + shift
  8716. + [[ -n nobuild ]]
  8717. + [[ nobuild != \-\- ]]
  8718. + longopts+=("$1")
  8719. + shift
  8720. + [[ -n nocolor ]]
  8721. + [[ nocolor != \-\- ]]
  8722. + longopts+=("$1")
  8723. + shift
  8724. + [[ -n nocheck ]]
  8725. + [[ nocheck != \-\- ]]
  8726. + longopts+=("$1")
  8727. + shift
  8728. + [[ -n nodeps ]]
  8729. + [[ nodeps != \-\- ]]
  8730. + longopts+=("$1")
  8731. + shift
  8732. + [[ -n noextract ]]
  8733. + [[ noextract != \-\- ]]
  8734. + longopts+=("$1")
  8735. + shift
  8736. + [[ -n noprepare ]]
  8737. + [[ noprepare != \-\- ]]
  8738. + longopts+=("$1")
  8739. + shift
  8740. + [[ -n nosign ]]
  8741. + [[ nosign != \-\- ]]
  8742. + longopts+=("$1")
  8743. + shift
  8744. + [[ -n packagelist ]]
  8745. + [[ packagelist != \-\- ]]
  8746. + longopts+=("$1")
  8747. + shift
  8748. + [[ -n printsrcinfo ]]
  8749. + [[ printsrcinfo != \-\- ]]
  8750. + longopts+=("$1")
  8751. + shift
  8752. + [[ -n repackage ]]
  8753. + [[ repackage != \-\- ]]
  8754. + longopts+=("$1")
  8755. + shift
  8756. + [[ -n rmdeps ]]
  8757. + [[ rmdeps != \-\- ]]
  8758. + longopts+=("$1")
  8759. + shift
  8760. + [[ -n sign ]]
  8761. + [[ sign != \-\- ]]
  8762. + longopts+=("$1")
  8763. + shift
  8764. + [[ -n skipchecksums ]]
  8765. + [[ skipchecksums != \-\- ]]
  8766. + longopts+=("$1")
  8767. + shift
  8768. + [[ -n skipinteg ]]
  8769. + [[ skipinteg != \-\- ]]
  8770. + longopts+=("$1")
  8771. + shift
  8772. + [[ -n skippgpcheck ]]
  8773. + [[ skippgpcheck != \-\- ]]
  8774. + longopts+=("$1")
  8775. + shift
  8776. + [[ -n source ]]
  8777. + [[ source != \-\- ]]
  8778. + longopts+=("$1")
  8779. + shift
  8780. + [[ -n syncdeps ]]
  8781. + [[ syncdeps != \-\- ]]
  8782. + longopts+=("$1")
  8783. + shift
  8784. + [[ -n verifysource ]]
  8785. + [[ verifysource != \-\- ]]
  8786. + longopts+=("$1")
  8787. + shift
  8788. + [[ -n version ]]
  8789. + [[ version != \-\- ]]
  8790. + longopts+=("$1")
  8791. + shift
  8792. + [[ -n asdeps ]]
  8793. + [[ asdeps != \-\- ]]
  8794. + longopts+=("$1")
  8795. + shift
  8796. + [[ -n noconfirm ]]
  8797. + [[ noconfirm != \-\- ]]
  8798. + longopts+=("$1")
  8799. + shift
  8800. + [[ -n needed ]]
  8801. + [[ needed != \-\- ]]
  8802. + longopts+=("$1")
  8803. + shift
  8804. + [[ -n noprogressbar ]]
  8805. + [[ noprogressbar != \-\- ]]
  8806. + longopts+=("$1")
  8807. + shift
  8808. + [[ -n -- ]]
  8809. + [[ -- != \-\- ]]
  8810. + shift
  8811. + (( 0 ))
  8812. + OPTRET+=('--' "${unused_argv[@]}" "$@")
  8813. + unset longoptmatch
  8814. + return 0
  8815. set -- "${OPTRET[@]}"
  8816. + set -- --
  8817. unset OPT_SHORT OPT_LONG OPTRET
  8818. + unset OPT_SHORT OPT_LONG OPTRET
  8819.  
  8820. while true; do
  8821. case "$1" in
  8822. # Pacman Options
  8823. --asdeps) ASDEPS=1;;
  8824. --needed) NEEDED=1;;
  8825. --noconfirm) PACMAN_OPTS+=("--noconfirm") ;;
  8826. --noprogressbar) PACMAN_OPTS+=("--noprogressbar") ;;
  8827.  
  8828. # Makepkg Options
  8829. --allsource) SOURCEONLY=2 ;;
  8830. -A|--ignorearch) IGNOREARCH=1 ;;
  8831. -c|--clean) CLEANUP=1 ;;
  8832. -C|--cleanbuild) CLEANBUILD=1 ;;
  8833. --check) RUN_CHECK='y' ;;
  8834. --config) shift; MAKEPKG_CONF=$1 ;;
  8835. -d|--nodeps) NODEPS=1 ;;
  8836. -e|--noextract) NOEXTRACT=1 ;;
  8837. -f|--force) FORCE=1 ;;
  8838. -F) INFAKEROOT=1 ;;
  8839. # generating integrity checks does not depend on architecture
  8840. -g|--geninteg) GENINTEG=1 IGNOREARCH=1;;
  8841. --holdver) HOLDVER=1 ;;
  8842. -i|--install) INSTALL=1 ;;
  8843. --key) shift; GPGKEY=$1 ;;
  8844. -L|--log) LOGGING=1 ;;
  8845. -m|--nocolor) USE_COLOR='n'; PACMAN_OPTS+=("--color" "never") ;;
  8846. --noarchive) NOARCHIVE=1 ;;
  8847. --nocheck) RUN_CHECK='n' ;;
  8848. --noprepare) RUN_PREPARE='n' ;;
  8849. --nosign) SIGNPKG='n' ;;
  8850. -o|--nobuild) NOBUILD=1 ;;
  8851. -p) shift; BUILDFILE=$1 ;;
  8852. --packagelist) PACKAGELIST=1 IGNOREARCH=1;;
  8853. --printsrcinfo) PRINTSRCINFO=1 IGNOREARCH=1;;
  8854. -r|--rmdeps) RMDEPS=1 ;;
  8855. -R|--repackage) REPKG=1 ;;
  8856. --sign) SIGNPKG='y' ;;
  8857. --skipchecksums) SKIPCHECKSUMS=1 ;;
  8858. --skipinteg) SKIPCHECKSUMS=1; SKIPPGPCHECK=1 ;;
  8859. --skippgpcheck) SKIPPGPCHECK=1;;
  8860. -s|--syncdeps) DEP_BIN=1 ;;
  8861. -S|--source) SOURCEONLY=1 ;;
  8862. --verifysource) VERIFYSOURCE=1 ;;
  8863.  
  8864. -h|--help) usage; exit $E_OK ;;
  8865. -V|--version) version; exit $E_OK ;;
  8866.  
  8867. --) shift; break ;;
  8868. esac
  8869. shift
  8870. done
  8871. + true
  8872. + case "$1" in
  8873. + shift
  8874. + break
  8875.  
  8876. # attempt to consume any extra argv as environment variables. this supports
  8877. # overriding (e.g. CC=clang) as well as overriding (e.g. CFLAGS+=' -g').
  8878. extra_environment=()
  8879. + extra_environment=()
  8880. while [[ $1 ]]; do
  8881. if [[ $1 = [_[:alpha:]]*([[:alnum:]_])?(+)=* ]]; then
  8882. extra_environment+=("$1")
  8883. fi
  8884. shift
  8885. done
  8886. + [[ -n '' ]]
  8887.  
  8888. # setup signal traps
  8889. trap 'clean_up' 0
  8890. + trap clean_up 0
  8891. for signal in TERM HUP QUIT; do
  8892. trap "trap_exit $signal \"$(gettext "%s signal caught. Exiting...")\" \"$signal\"" "$signal"
  8893. done
  8894. + for signal in TERM HUP QUIT
  8895. ++ gettext '%s signal caught. Exiting...'
  8896. + trap 'trap_exit TERM "%s signal caught. Exiting..." "TERM"' TERM
  8897. + for signal in TERM HUP QUIT
  8898. ++ gettext '%s signal caught. Exiting...'
  8899. + trap 'trap_exit HUP "%s signal caught. Exiting..." "HUP"' HUP
  8900. + for signal in TERM HUP QUIT
  8901. ++ gettext '%s signal caught. Exiting...'
  8902. + trap 'trap_exit QUIT "%s signal caught. Exiting..." "QUIT"' QUIT
  8903. trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
  8904. + trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
  8905. trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
  8906. + trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
  8907.  
  8908. # preserve environment variables to override makepkg.conf
  8909. restore_envvars=$(declare -p PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR PKGEXT SRCEXT GPGKEY PACKAGER CARCH 2>/dev/null || true)
  8910. ++ declare -p PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR PKGEXT SRCEXT GPGKEY PACKAGER CARCH
  8911. ++ true
  8912. + restore_envvars=
  8913.  
  8914. # default config is makepkg.conf
  8915. MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf}
  8916. + MAKEPKG_CONF=/etc/makepkg.conf
  8917.  
  8918. # Source the config file; fail if it is not found
  8919. if [[ -r $MAKEPKG_CONF ]]; then
  8920. source_safe "$MAKEPKG_CONF"
  8921. else
  8922. error "$(gettext "%s not found.")" "$MAKEPKG_CONF"
  8923. plain "$(gettext "Aborting...")"
  8924. exit $E_CONFIG_ERROR
  8925. fi
  8926. + [[ -r /etc/makepkg.conf ]]
  8927. + source_safe /etc/makepkg.conf
  8928. + shopt -u extglob
  8929. + source /etc/makepkg.conf
  8930. #!/hint/bash
  8931. #
  8932. # /etc/makepkg.conf
  8933. #
  8934.  
  8935. #########################################################################
  8936. # SOURCE ACQUISITION
  8937. #########################################################################
  8938. #
  8939. #-- The download utilities that makepkg should use to acquire sources
  8940. # Format: 'protocol::agent'
  8941. DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u'
  8942. 'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
  8943. 'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
  8944. 'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u'
  8945. 'rsync::/usr/bin/rsync --no-motd -z %u %o'
  8946. 'scp::/usr/bin/scp -C %u %o')
  8947. ++ DLAGENTS=('file::/usr/bin/curl -gqC - -o %o %u' 'ftp::/usr/bin/curl -gqfC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u' 'http::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u' 'https::/usr/bin/curl -gqb "" -fLC - --retry 3 --retry-delay 3 -o %o %u' 'rsync::/usr/bin/rsync --no-motd -z %u %o' 'scp::/usr/bin/scp -C %u %o')
  8948.  
  8949. # Other common tools:
  8950. # /usr/bin/snarf
  8951. # /usr/bin/lftpget -c
  8952. # /usr/bin/wget
  8953.  
  8954. #-- The package required by makepkg to download VCS sources
  8955. # Format: 'protocol::package'
  8956. VCSCLIENTS=('bzr::bzr'
  8957. 'git::git'
  8958. 'hg::mercurial'
  8959. 'svn::subversion')
  8960. ++ VCSCLIENTS=('bzr::bzr' 'git::git' 'hg::mercurial' 'svn::subversion')
  8961.  
  8962. #########################################################################
  8963. # ARCHITECTURE, COMPILE FLAGS
  8964. #########################################################################
  8965. #
  8966. CARCH="x86_64"
  8967. ++ CARCH=x86_64
  8968. CHOST="x86_64-pc-linux-gnu"
  8969. ++ CHOST=x86_64-pc-linux-gnu
  8970.  
  8971. #-- Compiler and Linker Flags
  8972. CPPFLAGS="-D_FORTIFY_SOURCE=2"
  8973. ++ CPPFLAGS=-D_FORTIFY_SOURCE=2
  8974. CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt"
  8975. ++ CFLAGS='-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt'
  8976. CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt"
  8977. ++ CXXFLAGS='-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt'
  8978. LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
  8979. ++ LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
  8980. #-- Make Flags: change this for DistCC/SMP systems
  8981. #MAKEFLAGS="-j2"
  8982. #-- Debugging flags
  8983. DEBUG_CFLAGS="-g -fvar-tracking-assignments"
  8984. ++ DEBUG_CFLAGS='-g -fvar-tracking-assignments'
  8985. DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"
  8986. ++ DEBUG_CXXFLAGS='-g -fvar-tracking-assignments'
  8987.  
  8988. #########################################################################
  8989. # BUILD ENVIRONMENT
  8990. #########################################################################
  8991. #
  8992. # Defaults: BUILDENV=(!distcc !color !ccache check !sign)
  8993. # A negated environment option will do the opposite of the comments below.
  8994. #
  8995. #-- distcc: Use the Distributed C/C++/ObjC compiler
  8996. #-- color: Colorize output messages
  8997. #-- ccache: Use ccache to cache compilation
  8998. #-- check: Run the check() function if present in the PKGBUILD
  8999. #-- sign: Generate PGP signature file
  9000. #
  9001. BUILDENV=(!distcc color !ccache check !sign)
  9002. ++ BUILDENV=(!distcc color !ccache check !sign)
  9003. #
  9004. #-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
  9005. #-- specify a space-delimited list of hosts running in the DistCC cluster.
  9006. #DISTCC_HOSTS=""
  9007. #
  9008. #-- Specify a directory for package building.
  9009. #BUILDDIR=/tmp/makepkg
  9010.  
  9011. #########################################################################
  9012. # GLOBAL PACKAGE OPTIONS
  9013. # These are default values for the options=() settings
  9014. #########################################################################
  9015. #
  9016. # Default: OPTIONS=(!strip docs libtool staticlibs emptydirs !zipman !purge !debug)
  9017. # A negated option will do the opposite of the comments below.
  9018. #
  9019. #-- strip: Strip symbols from binaries/libraries
  9020. #-- docs: Save doc directories specified by DOC_DIRS
  9021. #-- libtool: Leave libtool (.la) files in packages
  9022. #-- staticlibs: Leave static library (.a) files in packages
  9023. #-- emptydirs: Leave empty directories in packages
  9024. #-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
  9025. #-- purge: Remove files specified by PURGE_TARGETS
  9026. #-- debug: Add debugging flags as specified in DEBUG_* variables
  9027. #
  9028. OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug)
  9029. ++ OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug)
  9030.  
  9031. #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
  9032. INTEGRITY_CHECK=(md5)
  9033. ++ INTEGRITY_CHECK=(md5)
  9034. #-- Options to be used when stripping binaries. See `man strip' for details.
  9035. STRIP_BINARIES="--strip-all"
  9036. ++ STRIP_BINARIES=--strip-all
  9037. #-- Options to be used when stripping shared libraries. See `man strip' for details.
  9038. STRIP_SHARED="--strip-unneeded"
  9039. ++ STRIP_SHARED=--strip-unneeded
  9040. #-- Options to be used when stripping static libraries. See `man strip' for details.
  9041. STRIP_STATIC="--strip-debug"
  9042. ++ STRIP_STATIC=--strip-debug
  9043. #-- Manual (man and info) directories to compress (if zipman is specified)
  9044. MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
  9045. ++ MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
  9046. #-- Doc directories to remove (if !docs is specified)
  9047. DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
  9048. ++ DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
  9049. #-- Files to be removed from all packages (if purge is specified)
  9050. PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
  9051. ++ PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
  9052. #-- Directory to store source code in for debug packages
  9053. DBGSRCDIR="/usr/src/debug"
  9054. ++ DBGSRCDIR=/usr/src/debug
  9055.  
  9056. #########################################################################
  9057. # PACKAGE OUTPUT
  9058. #########################################################################
  9059. #
  9060. # Default: put built package and cached source in build directory
  9061. #
  9062. #-- Destination: specify a fixed directory where all packages will be placed
  9063. #PKGDEST=/home/packages
  9064. #-- Source cache: specify a fixed directory where source files will be cached
  9065. #SRCDEST=/home/sources
  9066. #-- Source packages: specify a fixed directory where all src packages will be placed
  9067. #SRCPKGDEST=/home/srcpackages
  9068. #-- Log files: specify a fixed directory where all log files will be placed
  9069. #LOGDEST=/home/makepkglogs
  9070. #-- Packager: name/email of the person or organization building packages
  9071. #PACKAGER="John Doe <john@doe.com>"
  9072. #-- Specify a key to use for package signing
  9073. #GPGKEY=""
  9074.  
  9075. #########################################################################
  9076. # COMPRESSION DEFAULTS
  9077. #########################################################################
  9078. #
  9079. COMPRESSGZ=(gzip -c -f -n)
  9080. ++ COMPRESSGZ=(gzip -c -f -n)
  9081. COMPRESSBZ2=(bzip2 -c -f)
  9082. ++ COMPRESSBZ2=(bzip2 -c -f)
  9083. COMPRESSXZ=(xz -c -z -)
  9084. ++ COMPRESSXZ=(xz -c -z -)
  9085. COMPRESSLRZ=(lrzip -q)
  9086. ++ COMPRESSLRZ=(lrzip -q)
  9087. COMPRESSLZO=(lzop -q)
  9088. ++ COMPRESSLZO=(lzop -q)
  9089. COMPRESSZ=(compress -c -f)
  9090. ++ COMPRESSZ=(compress -c -f)
  9091.  
  9092. #########################################################################
  9093. # EXTENSION DEFAULTS
  9094. #########################################################################
  9095. #
  9096. # WARNING: Do NOT modify these variables unless you know what you are
  9097. # doing.
  9098. #
  9099. PKGEXT='.pkg.tar.xz'
  9100. ++ PKGEXT=.pkg.tar.xz
  9101. SRCEXT='.src.tar.gz'
  9102. ++ SRCEXT=.src.tar.gz
  9103. + shopt -s extglob
  9104.  
  9105. # Source user-specific makepkg.conf overrides, but only if no override config
  9106. # file was specified
  9107. XDG_PACMAN_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/pacman"
  9108. + XDG_PACMAN_DIR=/home/keltere/.config/pacman
  9109. if [[ "$MAKEPKG_CONF" = "$confdir/makepkg.conf" ]]; then
  9110. if [[ -r "$XDG_PACMAN_DIR/makepkg.conf" ]]; then
  9111. source_safe "$XDG_PACMAN_DIR/makepkg.conf"
  9112. elif [[ -r "$HOME/.makepkg.conf" ]]; then
  9113. source_safe "$HOME/.makepkg.conf"
  9114. fi
  9115. fi
  9116. + [[ /etc/makepkg.conf = \/\e\t\c\/\m\a\k\e\p\k\g\.\c\o\n\f ]]
  9117. + [[ -r /home/keltere/.config/pacman/makepkg.conf ]]
  9118. + [[ -r /home/keltere/.makepkg.conf ]]
  9119.  
  9120. eval "$restore_envvars"
  9121. + eval ''
  9122.  
  9123. # override settings from extra variables on commandline, if any
  9124. if (( ${#extra_environment[*]} )); then
  9125. export "${extra_environment[@]}"
  9126. fi
  9127. + (( 0 ))
  9128.  
  9129. # canonicalize paths and provide defaults if anything is still undefined
  9130. for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR; do
  9131. printf -v "$var" "$(canonicalize_path "${!var:-$startdir}")"
  9132. done
  9133. + for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR
  9134. ++ canonicalize_path /home/keltere
  9135. ++ local path=/home/keltere
  9136. ++ [[ -d /home/keltere ]]
  9137. ++ cd_safe /home/keltere
  9138. ++ cd /home/keltere
  9139. ++ pwd -P
  9140. + printf -v PKGDEST /home/keltere
  9141. + for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR
  9142. ++ canonicalize_path /home/keltere
  9143. ++ local path=/home/keltere
  9144. ++ [[ -d /home/keltere ]]
  9145. ++ cd_safe /home/keltere
  9146. ++ cd /home/keltere
  9147. ++ pwd -P
  9148. + printf -v SRCDEST /home/keltere
  9149. + for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR
  9150. ++ canonicalize_path /home/keltere
  9151. ++ local path=/home/keltere
  9152. ++ [[ -d /home/keltere ]]
  9153. ++ cd_safe /home/keltere
  9154. ++ cd /home/keltere
  9155. ++ pwd -P
  9156. + printf -v SRCPKGDEST /home/keltere
  9157. + for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR
  9158. ++ canonicalize_path /home/keltere
  9159. ++ local path=/home/keltere
  9160. ++ [[ -d /home/keltere ]]
  9161. ++ cd_safe /home/keltere
  9162. ++ cd /home/keltere
  9163. ++ pwd -P
  9164. + printf -v LOGDEST /home/keltere
  9165. + for var in PKGDEST SRCDEST SRCPKGDEST LOGDEST BUILDDIR
  9166. ++ canonicalize_path /home/keltere
  9167. ++ local path=/home/keltere
  9168. ++ [[ -d /home/keltere ]]
  9169. ++ cd_safe /home/keltere
  9170. ++ cd /home/keltere
  9171. ++ pwd -P
  9172. + printf -v BUILDDIR /home/keltere
  9173. unset var
  9174. + unset var
  9175. PACKAGER=${PACKAGER:-"Unknown Packager"}
  9176. + PACKAGER='Unknown Packager'
  9177.  
  9178. # set pacman command if not already defined
  9179. PACMAN=${PACMAN:-pacman}
  9180. + PACMAN=pacman
  9181. # save full path to command as PATH may change when sourcing /etc/profile
  9182. PACMAN_PATH=$(type -P $PACMAN)
  9183. ++ type -P pacman
  9184. + PACMAN_PATH=/usr/bin/pacman
  9185.  
  9186. # check if messages are to be printed using color
  9187. if [[ -t 2 && $USE_COLOR != "n" ]] && check_buildenv "color" "y"; then
  9188. colorize
  9189. else
  9190. unset ALL_OFF BOLD BLUE GREEN RED YELLOW
  9191. fi
  9192. + [[ -t 2 ]]
  9193. + unset ALL_OFF BOLD BLUE GREEN RED YELLOW
  9194.  
  9195.  
  9196. # check makepkg.conf for some basic requirements
  9197. lint_config || exit $E_CONFIG_ERROR
  9198. + lint_config
  9199. + local ret=0
  9200. + for func in ${lint_config_functions[@]}
  9201. + lint_paths
  9202. + pathvars=(BUILDDIR PKGDEST SRCDEST SRCPKGDEST LOGDEST PKGEXT SRCEXT)
  9203. + local pathvars
  9204. + local i ret=0
  9205. + for i in ${pathvars[@]}
  9206. + [[ /home/keltere = *\
  9207. * ]]
  9208. + for i in ${pathvars[@]}
  9209. + [[ /home/keltere = *\
  9210. * ]]
  9211. + for i in ${pathvars[@]}
  9212. + [[ /home/keltere = *\
  9213. * ]]
  9214. + for i in ${pathvars[@]}
  9215. + [[ /home/keltere = *\
  9216. * ]]
  9217. + for i in ${pathvars[@]}
  9218. + [[ /home/keltere = *\
  9219. * ]]
  9220. + for i in ${pathvars[@]}
  9221. + [[ .pkg.tar.xz = *\
  9222. * ]]
  9223. + for i in ${pathvars[@]}
  9224. + [[ .src.tar.gz = *\
  9225. * ]]
  9226. + return 0
  9227. + for func in ${lint_config_functions[@]}
  9228. + lint_variable
  9229. + array=(arch backup checkdepends groups license noextract options validpgpkeys)
  9230. + local array
  9231. + arch_array=(conflicts depends makedepends md5sums optdepends provides replaces sha1sums sha224sums sha256sums sha384sums sha512sums source)
  9232. + local arch_array
  9233. + string=(changelog epoch install pkgdesc pkgrel pkgver url)
  9234. + local string
  9235. + local i a v pkg keys out bad ret=0
  9236. + for i in ${array[@]} ${arch_array[@]}
  9237. + eval 'keys=("${!arch[@]}")'
  9238. keys=("${!arch[@]}")
  9239. ++ keys=("${!arch[@]}")
  9240. + (( 0 > 0 ))
  9241. + for i in ${array[@]} ${arch_array[@]}
  9242. + eval 'keys=("${!backup[@]}")'
  9243. keys=("${!backup[@]}")
  9244. ++ keys=("${!backup[@]}")
  9245. + (( 0 > 0 ))
  9246. + for i in ${array[@]} ${arch_array[@]}
  9247. + eval 'keys=("${!checkdepends[@]}")'
  9248. keys=("${!checkdepends[@]}")
  9249. ++ keys=("${!checkdepends[@]}")
  9250. + (( 0 > 0 ))
  9251. + for i in ${array[@]} ${arch_array[@]}
  9252. + eval 'keys=("${!groups[@]}")'
  9253. keys=("${!groups[@]}")
  9254. ++ keys=("${!groups[@]}")
  9255. + (( 0 > 0 ))
  9256. + for i in ${array[@]} ${arch_array[@]}
  9257. + eval 'keys=("${!license[@]}")'
  9258. keys=("${!license[@]}")
  9259. ++ keys=("${!license[@]}")
  9260. + (( 0 > 0 ))
  9261. + for i in ${array[@]} ${arch_array[@]}
  9262. + eval 'keys=("${!noextract[@]}")'
  9263. keys=("${!noextract[@]}")
  9264. ++ keys=("${!noextract[@]}")
  9265. + (( 0 > 0 ))
  9266. + for i in ${array[@]} ${arch_array[@]}
  9267. + eval 'keys=("${!options[@]}")'
  9268. keys=("${!options[@]}")
  9269. ++ keys=("${!options[@]}")
  9270. + (( 0 > 0 ))
  9271. + for i in ${array[@]} ${arch_array[@]}
  9272. + eval 'keys=("${!validpgpkeys[@]}")'
  9273. keys=("${!validpgpkeys[@]}")
  9274. ++ keys=("${!validpgpkeys[@]}")
  9275. + (( 0 > 0 ))
  9276. + for i in ${array[@]} ${arch_array[@]}
  9277. + eval 'keys=("${!conflicts[@]}")'
  9278. keys=("${!conflicts[@]}")
  9279. ++ keys=("${!conflicts[@]}")
  9280. + (( 0 > 0 ))
  9281. + for i in ${array[@]} ${arch_array[@]}
  9282. + eval 'keys=("${!depends[@]}")'
  9283. keys=("${!depends[@]}")
  9284. ++ keys=("${!depends[@]}")
  9285. + (( 0 > 0 ))
  9286. + for i in ${array[@]} ${arch_array[@]}
  9287. + eval 'keys=("${!makedepends[@]}")'
  9288. keys=("${!makedepends[@]}")
  9289. ++ keys=("${!makedepends[@]}")
  9290. + (( 0 > 0 ))
  9291. + for i in ${array[@]} ${arch_array[@]}
  9292. + eval 'keys=("${!md5sums[@]}")'
  9293. keys=("${!md5sums[@]}")
  9294. ++ keys=("${!md5sums[@]}")
  9295. + (( 0 > 0 ))
  9296. + for i in ${array[@]} ${arch_array[@]}
  9297. + eval 'keys=("${!optdepends[@]}")'
  9298. keys=("${!optdepends[@]}")
  9299. ++ keys=("${!optdepends[@]}")
  9300. + (( 0 > 0 ))
  9301. + for i in ${array[@]} ${arch_array[@]}
  9302. + eval 'keys=("${!provides[@]}")'
  9303. keys=("${!provides[@]}")
  9304. ++ keys=("${!provides[@]}")
  9305. + (( 0 > 0 ))
  9306. + for i in ${array[@]} ${arch_array[@]}
  9307. + eval 'keys=("${!replaces[@]}")'
  9308. keys=("${!replaces[@]}")
  9309. ++ keys=("${!replaces[@]}")
  9310. + (( 0 > 0 ))
  9311. + for i in ${array[@]} ${arch_array[@]}
  9312. + eval 'keys=("${!sha1sums[@]}")'
  9313. keys=("${!sha1sums[@]}")
  9314. ++ keys=("${!sha1sums[@]}")
  9315. + (( 0 > 0 ))
  9316. + for i in ${array[@]} ${arch_array[@]}
  9317. + eval 'keys=("${!sha224sums[@]}")'
  9318. keys=("${!sha224sums[@]}")
  9319. ++ keys=("${!sha224sums[@]}")
  9320. + (( 0 > 0 ))
  9321. + for i in ${array[@]} ${arch_array[@]}
  9322. + eval 'keys=("${!sha256sums[@]}")'
  9323. keys=("${!sha256sums[@]}")
  9324. ++ keys=("${!sha256sums[@]}")
  9325. + (( 0 > 0 ))
  9326. + for i in ${array[@]} ${arch_array[@]}
  9327. + eval 'keys=("${!sha384sums[@]}")'
  9328. keys=("${!sha384sums[@]}")
  9329. ++ keys=("${!sha384sums[@]}")
  9330. + (( 0 > 0 ))
  9331. + for i in ${array[@]} ${arch_array[@]}
  9332. + eval 'keys=("${!sha512sums[@]}")'
  9333. keys=("${!sha512sums[@]}")
  9334. ++ keys=("${!sha512sums[@]}")
  9335. + (( 0 > 0 ))
  9336. + for i in ${array[@]} ${arch_array[@]}
  9337. + eval 'keys=("${!source[@]}")'
  9338. keys=("${!source[@]}")
  9339. ++ keys=("${!source[@]}")
  9340. + (( 0 > 0 ))
  9341. + for i in ${string[@]}
  9342. + eval 'keys=("${!changelog[@]}")'
  9343. keys=("${!changelog[@]}")
  9344. ++ keys=("${!changelog[@]}")
  9345. + (( 0 > 0 ))
  9346. + for i in ${string[@]}
  9347. + eval 'keys=("${!epoch[@]}")'
  9348. keys=("${!epoch[@]}")
  9349. ++ keys=("${!epoch[@]}")
  9350. + (( 0 > 0 ))
  9351. + for i in ${string[@]}
  9352. + eval 'keys=("${!install[@]}")'
  9353. keys=("${!install[@]}")
  9354. ++ keys=("${!install[@]}")
  9355. + (( 0 > 0 ))
  9356. + for i in ${string[@]}
  9357. + eval 'keys=("${!pkgdesc[@]}")'
  9358. keys=("${!pkgdesc[@]}")
  9359. ++ keys=("${!pkgdesc[@]}")
  9360. + (( 0 > 0 ))
  9361. + for i in ${string[@]}
  9362. + eval 'keys=("${!pkgrel[@]}")'
  9363. keys=("${!pkgrel[@]}")
  9364. ++ keys=("${!pkgrel[@]}")
  9365. + (( 0 > 0 ))
  9366. + for i in ${string[@]}
  9367. + eval 'keys=("${!pkgver[@]}")'
  9368. keys=("${!pkgver[@]}")
  9369. ++ keys=("${!pkgver[@]}")
  9370. + (( 0 > 0 ))
  9371. + for i in ${string[@]}
  9372. + eval 'keys=("${!url[@]}")'
  9373. keys=("${!url[@]}")
  9374. ++ keys=("${!url[@]}")
  9375. + (( 0 > 0 ))
  9376. + return 0
  9377. + return 0
  9378.  
  9379.  
  9380. # check that all settings directories are user-writable
  9381. if ! ensure_writable_dir "BUILDDIR" "$BUILDDIR"; then
  9382. plain "$(gettext "Aborting...")"
  9383. exit $E_FS_PERMISSIONS
  9384. fi
  9385. + ensure_writable_dir BUILDDIR /home/keltere
  9386. + local dirtype=BUILDDIR dirpath=/home/keltere
  9387. + mkdir -p /home/keltere
  9388. + [[ ! -w /home/keltere ]]
  9389. + return 0
  9390.  
  9391. if (( ! (NOBUILD || GENINTEG) )) && ! ensure_writable_dir "PKGDEST" "$PKGDEST"; then
  9392. plain "$(gettext "Aborting...")"
  9393. exit $E_FS_PERMISSIONS
  9394. fi
  9395. + (( ! (NOBUILD || GENINTEG) ))
  9396. + ensure_writable_dir PKGDEST /home/keltere
  9397. + local dirtype=PKGDEST dirpath=/home/keltere
  9398. + mkdir -p /home/keltere
  9399. + [[ ! -w /home/keltere ]]
  9400. + return 0
  9401.  
  9402. if ! ensure_writable_dir "SRCDEST" "$SRCDEST" ; then
  9403. plain "$(gettext "Aborting...")"
  9404. exit $E_FS_PERMISSIONS
  9405. fi
  9406. + ensure_writable_dir SRCDEST /home/keltere
  9407. + local dirtype=SRCDEST dirpath=/home/keltere
  9408. + mkdir -p /home/keltere
  9409. + [[ ! -w /home/keltere ]]
  9410. + return 0
  9411.  
  9412. if (( SOURCEONLY )); then
  9413. if ! ensure_writable_dir "SRCPKGDEST" "$SRCPKGDEST"; then
  9414. plain "$(gettext "Aborting...")"
  9415. exit $E_FS_PERMISSIONS
  9416. fi
  9417.  
  9418. # If we're only making a source tarball, then we need to ignore architecture-
  9419. # dependent behavior.
  9420. IGNOREARCH=1
  9421. fi
  9422. + (( SOURCEONLY ))
  9423.  
  9424. if (( LOGGING )) && ! ensure_writable_dir "LOGDEST" "$LOGDEST"; then
  9425. plain "$(gettext "Aborting...")"
  9426. exit $E_FS_PERMISSIONS
  9427. fi
  9428. + (( LOGGING ))
  9429.  
  9430. if (( ! INFAKEROOT )); then
  9431. if (( EUID == 0 )); then
  9432. error "$(gettext "Running %s as root is not allowed as it can cause permanent,\n\
  9433. catastrophic damage to your system.")" "makepkg"
  9434. exit $E_ROOT
  9435. fi
  9436. else
  9437. if [[ -z $FAKEROOTKEY ]]; then
  9438. error "$(gettext "Do not use the %s option. This option is only for internal use by %s.")" "'-F'" "makepkg"
  9439. exit $E_INVALID_OPTION
  9440. fi
  9441. fi
  9442. + (( ! INFAKEROOT ))
  9443. + (( EUID == 0 ))
  9444.  
  9445. unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
  9446. + unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
  9447. unset md5sums replaces depends conflicts backup source install changelog build
  9448. + unset md5sums replaces depends conflicts backup source install changelog build
  9449. unset sha{1,224,256,384,512}sums makedepends optdepends options noextract validpgpkeys
  9450. + unset sha1sums sha224sums sha256sums sha384sums sha512sums makedepends optdepends options noextract validpgpkeys
  9451. unset "${!makedepends_@}" "${!depends_@}" "${!source_@}" "${!checkdepends_@}"
  9452. + unset
  9453. unset "${!optdepends_@}" "${!conflicts_@}" "${!provides_@}" "${!replaces_@}"
  9454. + unset
  9455. unset "${!md5sums_@}" "${!sha1sums_@}" "${!sha224sums_@}" "${!sha256sums_@}"
  9456. + unset
  9457. unset "${!sha384sums_@}" "${!sha512sums_@}"
  9458. + unset
  9459.  
  9460. BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
  9461. + BUILDFILE=PKGBUILD
  9462. if [[ ! -f $BUILDFILE ]]; then
  9463. error "$(gettext "%s does not exist.")" "$BUILDFILE"
  9464. exit $E_USER_FUNCTION_FAILED
  9465.  
  9466. else
  9467. if [[ $(<"$BUILDFILE") = *$'\r'* ]]; then
  9468. error "$(gettext "%s contains %s characters and cannot be sourced.")" "$BUILDFILE" "CRLF"
  9469. exit $E_PKGBUILD_ERROR
  9470. fi
  9471.  
  9472. if [[ ! $BUILDFILE -ef $PWD/${BUILDFILE##*/} ]]; then
  9473. error "$(gettext "%s must be in the current working directory.")" "$BUILDFILE"
  9474. exit $E_PKGBUILD_ERROR
  9475. fi
  9476.  
  9477. if [[ ${BUILDFILE:0:1} != "/" ]]; then
  9478. BUILDFILE="$startdir/$BUILDFILE"
  9479. fi
  9480. source_buildfile "$BUILDFILE"
  9481. fi
  9482. + [[ ! -f PKGBUILD ]]
  9483. ++ gettext '%s does not exist.'
  9484. + error '%s does not exist.' PKGBUILD
  9485. + local 'mesg=%s does not exist.'
  9486. + shift
  9487. ++ gettext ERROR:
  9488. + printf '==> ERROR: %s does not exist.\n' PKGBUILD
  9489. ==> ERROR: PKGBUILD does not exist.
  9490. + exit 4
  9491. clean_up
  9492. + clean_up
  9493. + local EXIT_CODE=4
  9494. + (( INFAKEROOT ))
  9495. + (( (EXIT_CODE == E_OK || EXIT_CODE == E_INSTALL_FAILED) && CLEANUP ))
  9496. + remove_deps
  9497. + (( ! RMDEPS ))
  9498. + return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement