Advertisement
Guest User

Untitled

a guest
Jan 18th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 111.57 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-2013 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, openssl, sed, tput (ncurses), xz
  32.  
  33. # gettext initialization
  34. export TEXTDOMAIN='pacman-scripts'
  35. export TEXTDOMAINDIR='/usr/share/locale'
  36.  
  37. # file -i does not work on Mac OSX unless legacy mode is set
  38. export COMMAND_MODE='legacy'
  39. # Ensure CDPATH doesn't screw with our cd calls
  40. unset CDPATH
  41. # Ensure GREP_OPTIONS doesn't screw with our grep calls
  42. unset GREP_OPTIONS
  43.  
  44. declare -r makepkg_version='4.1.2'
  45. declare -r confdir='/etc'
  46. declare -r BUILDSCRIPT='PKGBUILD'
  47. declare -r startdir="$PWD"
  48.  
  49. packaging_options=('strip' 'docs' 'libtool' 'staticlibs' 'emptydirs' 'zipman' \
  50. 'purge' 'upx' 'debug')
  51. other_options=('ccache' 'distcc' 'buildflags' 'makeflags')
  52. splitpkg_overrides=('pkgver' 'pkgrel' 'epoch' 'pkgdesc' 'arch' 'url' 'license' \
  53. 'groups' 'depends' 'optdepends' 'provides' 'conflicts' \
  54. 'replaces' 'backup' 'options' 'install' 'changelog')
  55. readonly -a packaging_options other_options splitpkg_overrides
  56.  
  57. # Options
  58. ASDEPS=0
  59. NEEDED=0
  60. ASROOT=0
  61. CLEANUP=0
  62. DEP_BIN=0
  63. FORCE=0
  64. INFAKEROOT=0
  65. GENINTEG=0
  66. HOLDVER=0
  67. SKIPCHECKSUMS=0
  68. SKIPPGPCHECK=0
  69. INSTALL=0
  70. NOBUILD=0
  71. NODEPS=0
  72. NOEXTRACT=0
  73. VERIFYSOURCE=0
  74. RMDEPS=0
  75. REPKG=0
  76. LOGGING=0
  77. SOURCEONLY=0
  78. IGNOREARCH=0
  79. PREPAREFUNC=0
  80. BUILDFUNC=0
  81. CHECKFUNC=0
  82. PKGFUNC=0
  83. PKGVERFUNC=0
  84. SPLITPKG=0
  85. PKGLIST=()
  86. SIGNPKG=''
  87.  
  88. # Forces the pkgver of the current PKGBUILD. Used by the fakeroot call
  89. # when dealing with svn/cvs/etc PKGBUILDs.
  90. FORCE_VER=""
  91.  
  92. PACMAN_OPTS=
  93.  
  94. shopt -s extglob
  95.  
  96. ### SUBROUTINES ###
  97.  
  98. plain() {
  99. local mesg=$1; shift
  100. printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  101. }
  102.  
  103. msg() {
  104. local mesg=$1; shift
  105. printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  106. }
  107.  
  108. msg2() {
  109. local mesg=$1; shift
  110. printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  111. }
  112.  
  113. warning() {
  114. local mesg=$1; shift
  115. printf "${YELLOW}==> $(gettext "WARNING:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  116. }
  117.  
  118. error() {
  119. local mesg=$1; shift
  120. printf "${RED}==> $(gettext "ERROR:")${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
  121. }
  122.  
  123.  
  124. ##
  125. # Special exit call for traps, Don't print any error messages when inside,
  126. # the fakeroot call, the error message will be printed by the main call.
  127. ##
  128. trap_exit() {
  129. local signal=$1; shift
  130.  
  131. if (( ! INFAKEROOT )); then
  132. echo
  133. error "$@"
  134. fi
  135. [[ -n $srclinks ]] && rm -rf "$srclinks"
  136.  
  137. # unset the trap for this signal, and then call the default handler
  138. trap -- "$signal"
  139. kill "-$signal" "$$"
  140. }
  141.  
  142.  
  143. ##
  144. # Clean up function. Called automatically when the script exits.
  145. ##
  146. clean_up() {
  147. local EXIT_CODE=$?
  148.  
  149. if (( INFAKEROOT )); then
  150. # Don't clean up when leaving fakeroot, we're not done yet.
  151. return
  152. fi
  153.  
  154. if (( ! EXIT_CODE && CLEANUP )); then
  155. local pkg file
  156.  
  157. # If it's a clean exit and -c/--clean has been passed...
  158. msg "$(gettext "Cleaning up...")"
  159. rm -rf "$pkgdirbase" "$srcdir"
  160. if [[ -n $pkgbase ]]; then
  161. local fullver=$(get_full_version)
  162. # Can't do this unless the BUILDSCRIPT has been sourced.
  163. if (( BUILDFUNC )); then
  164. rm -f "${pkgbase}-${fullver}-${CARCH}-build.log"*
  165. fi
  166. if (( CHECKFUNC )); then
  167. rm -f "${pkgbase}-${fullver}-${CARCH}-check.log"*
  168. fi
  169. if (( PKGFUNC )); then
  170. rm -f "${pkgbase}-${fullver}-${CARCH}-package.log"*
  171. elif (( SPLITPKG )); then
  172. for pkg in ${pkgname[@]}; do
  173. rm -f "${pkgbase}-${fullver}-${CARCH}-package_${pkg}.log"*
  174. done
  175. fi
  176.  
  177. # clean up dangling symlinks to packages
  178. for pkg in ${pkgname[@]}; do
  179. for file in ${pkg}-*-*-*{${PKGEXT},${SRCEXT}}; do
  180. if [[ -h $file && ! -e $file ]]; then
  181. rm -f "$file"
  182. fi
  183. done
  184. done
  185. fi
  186. fi
  187.  
  188. remove_deps
  189. }
  190.  
  191.  
  192. enter_fakeroot() {
  193. msg "$(gettext "Entering %s environment...")" "fakeroot"
  194. fakeroot -- $0 -F "${ARGLIST[@]}" || exit $?
  195. }
  196.  
  197.  
  198. # a source entry can have two forms :
  199. # 1) "filename::http://path/to/file"
  200. # 2) "http://path/to/file"
  201.  
  202. # Return the absolute filename of a source entry
  203. get_filepath() {
  204. local file="$(get_filename "$1")"
  205. local proto="$(get_protocol "$1")"
  206.  
  207. case $proto in
  208. bzr*|git*|hg*|svn*)
  209. if [[ -d "$startdir/$file" ]]; then
  210. file="$startdir/$file"
  211. elif [[ -d "$SRCDEST/$file" ]]; then
  212. file="$SRCDEST/$file"
  213. else
  214. return 1
  215. fi
  216. ;;
  217. *)
  218. if [[ -f "$startdir/$file" ]]; then
  219. file="$startdir/$file"
  220. elif [[ -f "$SRCDEST/$file" ]]; then
  221. file="$SRCDEST/$file"
  222. else
  223. return 1
  224. fi
  225. ;;
  226. esac
  227.  
  228. printf "%s\n" "$file"
  229. }
  230.  
  231. # extract the filename from a source entry
  232. get_filename() {
  233. local netfile=$1
  234.  
  235. # if a filename is specified, use it
  236. if [[ $netfile = *::* ]]; then
  237. printf "%s\n" ${netfile%%::*}
  238. return
  239. fi
  240.  
  241. local proto=$(get_protocol "$netfile")
  242.  
  243. case $proto in
  244. bzr*|git*|hg*|svn*)
  245. filename=${netfile%%#*}
  246. filename=${filename%/}
  247. filename=${filename##*/}
  248. if [[ $proto = bzr* ]]; then
  249. filename=${filename#*lp:}
  250. fi
  251. if [[ $proto = git* ]]; then
  252. filename=${filename%%.git*}
  253. fi
  254. ;;
  255. *)
  256. # if it is just an URL, we only keep the last component
  257. filename="${netfile##*/}"
  258. ;;
  259. esac
  260. printf "%s\n" "${filename}"
  261. }
  262.  
  263. # extract the URL from a source entry
  264. get_url() {
  265. # strip an eventual filename
  266. printf "%s\n" "${1#*::}"
  267. }
  268.  
  269. # extract the protocol from a source entry - return "local" for local sources
  270. get_protocol() {
  271. if [[ $1 = *://* ]]; then
  272. # strip leading filename
  273. local proto="${1##*::}"
  274. printf "%s\n" "${proto%%://*}"
  275. elif [[ $1 = *lp:* ]]; then
  276. local proto="${1##*::}"
  277. printf "%s\n" "${proto%%lp:*}"
  278. else
  279. printf "%s\n" local
  280. fi
  281. }
  282.  
  283. get_downloadclient() {
  284. local proto=$1
  285.  
  286. # loop through DOWNLOAD_AGENTS variable looking for protocol
  287. local i
  288. for i in "${DLAGENTS[@]}"; do
  289. local handler="${i%%::*}"
  290. if [[ $proto = "$handler" ]]; then
  291. local agent="${i##*::}"
  292. break
  293. fi
  294. done
  295.  
  296. # if we didn't find an agent, return an error
  297. if [[ -z $agent ]]; then
  298. error "$(gettext "Unknown download protocol: %s")" "$proto"
  299. plain "$(gettext "Aborting...")"
  300. exit 1 # $E_CONFIG_ERROR
  301. fi
  302.  
  303. # ensure specified program is installed
  304. local program="${agent%% *}"
  305. if [[ ! -x $program ]]; then
  306. local baseprog="${program##*/}"
  307. error "$(gettext "The download program %s is not installed.")" "$baseprog"
  308. plain "$(gettext "Aborting...")"
  309. exit 1 # $E_MISSING_PROGRAM
  310. fi
  311.  
  312. printf "%s\n" "$agent"
  313. }
  314.  
  315. download_local() {
  316. local netfile=$1
  317. local filepath=$(get_filepath "$netfile")
  318.  
  319. if [[ -n "$filepath" ]]; then
  320. msg2 "$(gettext "Found %s")" "${filepath##*/}"
  321. rm -f "$srcdir/${filepath##*/}"
  322. ln -s "$filepath" "$srcdir/"
  323. else
  324. local filename=$(get_filename "$netfile")
  325. error "$(gettext "%s was not found in the build directory and is not a URL.")" "$filename"
  326. exit 1 # $E_MISSING_FILE
  327. fi
  328. }
  329.  
  330. download_file() {
  331. local netfile=$1
  332.  
  333. local filepath=$(get_filepath "$netfile")
  334. if [[ -n "$filepath" ]]; then
  335. msg2 "$(gettext "Found %s")" "${filepath##*/}"
  336. rm -f "$srcdir/${filepath##*/}"
  337. ln -s "$filepath" "$srcdir/"
  338. return
  339. fi
  340.  
  341. local proto=$(get_protocol "$netfile")
  342.  
  343. # find the client we should use for this URL
  344. local dlcmd
  345. dlcmd=$(get_downloadclient "$proto") || exit $?
  346.  
  347. local filename=$(get_filename "$netfile")
  348. local url=$(get_url "$netfile")
  349.  
  350. if [[ $proto = "scp" ]]; then
  351. # scp downloads should not pass the protocol in the url
  352. url="${url##*://}"
  353. fi
  354.  
  355. msg2 "$(gettext "Downloading %s...")" "$filename"
  356.  
  357. # temporary download file, default to last component of the URL
  358. local dlfile="${url##*/}"
  359.  
  360. # replace %o by the temporary dlfile if it exists
  361. if [[ $dlcmd = *%o* ]]; then
  362. dlcmd=${dlcmd//\%o/\"$filename.part\"}
  363. dlfile="$filename.part"
  364. fi
  365. # add the URL, either in place of %u or at the end
  366. if [[ $dlcmd = *%u* ]]; then
  367. dlcmd=${dlcmd//\%u/\"$url\"}
  368. else
  369. dlcmd="$dlcmd \"$url\""
  370. fi
  371.  
  372. local ret=0
  373. eval "$dlcmd || ret=\$?"
  374. if (( ret )); then
  375. [[ ! -s $dlfile ]] && rm -f -- "$dlfile"
  376. error "$(gettext "Failure while downloading %s")" "$filename"
  377. plain "$(gettext "Aborting...")"
  378. exit 1
  379. fi
  380.  
  381. # rename the temporary download file to the final destination
  382. if [[ $dlfile != "$filename" ]]; then
  383. mv -f "$SRCDEST/$dlfile" "$SRCDEST/$filename"
  384. fi
  385.  
  386. rm -f "$srcdir/$filename"
  387. ln -s "$SRCDEST/$filename" "$srcdir/"
  388. }
  389.  
  390. extract_file() {
  391. local file=$1
  392. # fix flyspray #6246
  393. local file_type=$(file -bizL "$file")
  394. local ext=${file##*.}
  395. local cmd=''
  396. case "$file_type" in
  397. *application/x-tar*|*application/zip*|*application/x-zip*|*application/x-cpio*)
  398. cmd="bsdtar" ;;
  399. *application/x-gzip*)
  400. case "$ext" in
  401. gz|z|Z) cmd="gzip" ;;
  402. *) continue;;
  403. esac ;;
  404. *application/x-bzip*)
  405. case "$ext" in
  406. bz2|bz) cmd="bzip2" ;;
  407. *) continue;;
  408. esac ;;
  409. *application/x-xz*)
  410. case "$ext" in
  411. xz) cmd="xz" ;;
  412. *) continue;;
  413. esac ;;
  414. *)
  415. # See if bsdtar can recognize the file
  416. if bsdtar -tf "$file" -q '*' &>/dev/null; then
  417. cmd="bsdtar"
  418. else
  419. continue
  420. fi ;;
  421. esac
  422.  
  423. local ret=0
  424. msg2 "$(gettext "Extracting %s with %s")" "$file" "$cmd"
  425. if [[ $cmd = "bsdtar" ]]; then
  426. $cmd -xf "$file" || ret=$?
  427. else
  428. rm -f -- "${file%.*}"
  429. $cmd -dcf "$file" > "${file%.*}" || ret=$?
  430. fi
  431. if (( ret )); then
  432. error "$(gettext "Failed to extract %s")" "$file"
  433. plain "$(gettext "Aborting...")"
  434. exit 1
  435. fi
  436.  
  437. if (( EUID == 0 )); then
  438. # change perms of all source files to root user & root group
  439. chown -R 0:0 "$srcdir"
  440. fi
  441. }
  442.  
  443. download_bzr() {
  444. local netfile=$1
  445.  
  446. local url=$(get_url "$netfile")
  447. url=${url##*bzr+}
  448. url=${url%%#*}
  449.  
  450. local repo=$(get_filename "$netfile")
  451. local displaylocation="$url"
  452.  
  453. local dir=$(get_filepath "$netfile")
  454. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  455.  
  456. if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
  457. msg2 "$(gettext "Branching %s ...")" "${displaylocation}"
  458. if ! bzr branch "$url" "$dir" --no-tree --use-existing-dir; then
  459. error "$(gettext "Failure while branching %s")" "${displaylocation}"
  460. plain "$(gettext "Aborting...")"
  461. exit 1
  462. fi
  463. elif (( ! HOLDVER )); then
  464. # Make sure we are fetching the right repo
  465. local distant_url="$(bzr info $url 2> /dev/null | sed -n '/branch root/{s/ branch root: //p;q;}')"
  466. local local_url="$(bzr config parent_location -d $dir)"
  467. if [[ -n $distant_url ]]; then
  468. if [[ $distant_url != "$local_url" ]]; then
  469. error "$(gettext "%s is not a branch of %s")" "$dir" "$url"
  470. plain "$(gettext "Aborting...")"
  471. exit 1
  472. fi
  473. else
  474. if [[ $url != "$local_url" ]] ; then
  475. error "$(gettext "%s is not a branch of %s")" "$dir" "$url"
  476. error "$(gettext "The local URL is %s")" "$local_url"
  477. plain "$(gettext "Aborting...")"
  478. exit 1
  479. fi
  480. fi
  481. msg2 "$(gettext "Pulling %s ...")" "${displaylocation}"
  482. cd_safe "$dir"
  483. if ! bzr pull "$url" --overwrite; then
  484. # only warn on failure to allow offline builds
  485. warning "$(gettext "Failure while pulling %s")" "${displaylocation}"
  486. fi
  487. fi
  488. }
  489.  
  490. extract_bzr() {
  491. local netfile=$1
  492.  
  493. local repo=$(get_filename "$netfile")
  494. local fragment=${netfile#*#}
  495. if [[ $fragment = "$netfile" ]]; then
  496. unset fragment
  497. fi
  498.  
  499. if [[ -n $fragment ]]; then
  500. case ${fragment%%=*} in
  501. revision)
  502. revision=("-r" "${fragment#*=}")
  503. displaylocation="$url -r ${fragment#*=}"
  504. ;;
  505. *)
  506. error "$(gettext "Unrecognized reference: %s")" "${fragment}"
  507. plain "$(gettext "Aborting...")"
  508. exit 1
  509. esac
  510. fi
  511.  
  512. local dir=$(get_filepath "$netfile")
  513. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  514.  
  515. msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "bzr"
  516. pushd "$srcdir" &>/dev/null
  517. rm -rf "${dir##*/}"
  518.  
  519. if ! { bzr checkout "$dir" "${revision[@]}" --lightweight &&
  520. ( cd "$repo" && bzr pull "$dir" -q --overwrite "${revision[@]}" ); }; then
  521. error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "bzr"
  522. plain "$(gettext "Aborting...")"
  523. exit 1
  524. fi
  525.  
  526. popd &>/dev/null
  527. }
  528.  
  529. download_git() {
  530. local netfile=$1
  531.  
  532. local dir=$(get_filepath "$netfile")
  533. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  534.  
  535. local repo=$(get_filename "$netfile")
  536.  
  537. local url=$(get_url "$netfile")
  538. url=${url##*git+}
  539. url=${url%%#*}
  540.  
  541. if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
  542. msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "git"
  543. if ! git clone --mirror "$url" "$dir"; then
  544. error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "git"
  545. plain "$(gettext "Aborting...")"
  546. exit 1
  547. fi
  548. elif (( ! HOLDVER )); then
  549. cd_safe "$dir"
  550. # Make sure we are fetching the right repo
  551. if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then
  552. error "$(gettext "%s is not a clone of %s")" "$dir" "$url"
  553. plain "$(gettext "Aborting...")"
  554. exit 1
  555. fi
  556. msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "git"
  557. if ! git fetch --all -p; then
  558. # only warn on failure to allow offline builds
  559. warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "git"
  560. fi
  561. fi
  562. }
  563.  
  564. extract_git() {
  565. local netfile=$1
  566.  
  567. local fragment=${netfile#*#}
  568. if [[ $fragment = "$netfile" ]]; then
  569. unset fragment
  570. fi
  571.  
  572. local repo=${netfile##*/}
  573. repo=${repo%%#*}
  574. repo=${repo%%.git*}
  575.  
  576. local dir=$(get_filepath "$netfile")
  577. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  578.  
  579. msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "git"
  580. pushd "$srcdir" &>/dev/null
  581. rm -rf "${dir##*/}"
  582.  
  583. if ! git clone "$dir"; then
  584. error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
  585. plain "$(gettext "Aborting...")"
  586. exit 1
  587. fi
  588.  
  589. cd_safe "${dir##*/}"
  590.  
  591. local ref
  592. if [[ -n $fragment ]]; then
  593. case ${fragment%%=*} in
  594. commit|tag)
  595. ref=${fragment##*=}
  596. ;;
  597. branch)
  598. ref=origin/${fragment##*=}
  599. ;;
  600. *)
  601. error "$(gettext "Unrecognized reference: %s")" "${fragment}"
  602. plain "$(gettext "Aborting...")"
  603. exit 1
  604. esac
  605. fi
  606.  
  607. if [[ -n $ref ]]; then
  608. if ! git checkout -b makepkg $ref; then
  609. error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "git"
  610. plain "$(gettext "Aborting...")"
  611. exit 1
  612. fi
  613. fi
  614.  
  615. popd &>/dev/null
  616. }
  617.  
  618. download_hg() {
  619. local netfile=$1
  620.  
  621. local dir=$(get_filepath "$netfile")
  622. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  623.  
  624. local repo=$(get_filename "$netfile")
  625.  
  626. local url=$(get_url "$netfile")
  627. url=${url##*hg+}
  628. url=${url%%#*}
  629.  
  630. if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
  631. msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "hg"
  632. if ! hg clone -U "$url" "$dir"; then
  633. error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "hg"
  634. plain "$(gettext "Aborting...")"
  635. exit 1
  636. fi
  637. elif (( ! HOLDVER )); then
  638. msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "hg"
  639. cd_safe "$dir"
  640. if ! hg pull; then
  641. # only warn on failure to allow offline builds
  642. warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "hg"
  643. fi
  644. fi
  645. }
  646.  
  647. extract_hg() {
  648. local netfile=$1
  649.  
  650. local fragment=${netfile#*#}
  651. if [[ $fragment = "$netfile" ]]; then
  652. unset fragment
  653. fi
  654.  
  655. local dir=$(get_filepath "$netfile")
  656. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  657.  
  658. local repo=${netfile##*/}
  659. repo=${repo%%#*}
  660.  
  661. msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "hg"
  662. pushd "$srcdir" &>/dev/null
  663. rm -rf "${dir##*/}"
  664.  
  665. local ref
  666. if [[ -n $fragment ]]; then
  667. case ${fragment%%=*} in
  668. branch|revision|tag)
  669. ref=('-u' "${fragment##*=}")
  670. ;;
  671. *)
  672. error "$(gettext "Unrecognized reference: %s")" "${fragment}"
  673. plain "$(gettext "Aborting...")"
  674. exit 1
  675. esac
  676. fi
  677.  
  678. if ! hg clone "${ref[@]}" "$dir" "${dir##*/}"; then
  679. error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "hg"
  680. plain "$(gettext "Aborting...")"
  681. exit 1
  682. fi
  683.  
  684. popd &>/dev/null
  685. }
  686.  
  687. download_svn() {
  688. local netfile=$1
  689.  
  690. local fragment=${netfile#*#}
  691. if [[ $fragment = "$netfile" ]]; then
  692. unset fragment
  693. fi
  694.  
  695. local dir=$(get_filepath "$netfile")
  696. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  697.  
  698. local repo=$(get_filename "$netfile")
  699.  
  700. local url=$(get_url "$netfile")
  701. if [[ $url != svn+ssh* ]]; then
  702. url=${url##*svn+}
  703. fi
  704. url=${url%%#*}
  705.  
  706. if [[ ! -d "$dir" ]] || dir_is_empty "$dir" ; then
  707. msg2 "$(gettext "Cloning %s %s repo...")" "${repo}" "svn"
  708. mkdir -p "$dir/.makepkg"
  709. if ! svn checkout --config-dir "$dir/.makepkg" "$url" "$dir"; then
  710. error "$(gettext "Failure while downloading %s %s repo")" "${repo}" "svn"
  711. plain "$(gettext "Aborting...")"
  712. exit 1
  713. fi
  714. elif (( ! HOLDVER )); then
  715. msg2 "$(gettext "Updating %s %s repo...")" "${repo}" "svn"
  716. cd_safe "$dir"
  717. if ! svn update; then
  718. # only warn on failure to allow offline builds
  719. warning "$(gettext "Failure while updating %s %s repo")" "${repo}" "svn"
  720. fi
  721. fi
  722. }
  723.  
  724. extract_svn() {
  725. local netfile=$1
  726.  
  727. local fragment=${netfile#*#}
  728. if [[ $fragment = "$netfile" ]]; then
  729. unset fragment
  730. fi
  731.  
  732. local dir=$(get_filepath "$netfile")
  733. [[ -z "$dir" ]] && dir="$SRCDEST/$(get_filename "$netfile")"
  734.  
  735. local repo=${netfile##*/}
  736. repo=${repo%%#*}
  737.  
  738. msg2 "$(gettext "Creating working copy of %s %s repo...")" "${repo}" "svn"
  739. pushd "$srcdir" &>/dev/null
  740. rm -rf "${dir##*/}"
  741.  
  742. local ref
  743. if [[ -n $fragment ]]; then
  744. case ${fragment%%=*} in
  745. revision)
  746. ref="${fragment##*=}"
  747. ;;
  748. *)
  749. error "$(gettext "Unrecognized reference: %s")" "${fragment}"
  750. plain "$(gettext "Aborting...")"
  751. exit 1
  752. esac
  753. fi
  754.  
  755. cp -a "$dir" .
  756.  
  757. if [[ -n ${ref} ]]; then
  758. cd_safe "$(get_filename "$netfile")"
  759. if ! svn update -r ${ref}; then
  760. error "$(gettext "Failure while creating working copy of %s %s repo")" "${repo}" "svn"
  761. plain "$(gettext "Aborting...")"
  762. fi
  763. fi
  764.  
  765. popd &>/dev/null
  766. }
  767.  
  768. download_sources() {
  769. msg "$(gettext "Retrieving sources...")"
  770.  
  771. local GET_VCS=1
  772. if [[ $1 == "fast" ]]; then
  773. GET_VCS=0
  774. fi
  775.  
  776. local netfile
  777. for netfile in "${source[@]}"; do
  778. pushd "$SRCDEST" &>/dev/null
  779.  
  780. local proto=$(get_protocol "$netfile")
  781. case "$proto" in
  782. local)
  783. download_local "$netfile"
  784. ;;
  785. bzr*)
  786. (( GET_VCS )) && download_bzr "$netfile"
  787. ;;
  788. git*)
  789. (( GET_VCS )) && download_git "$netfile"
  790. ;;
  791. hg*)
  792. (( GET_VCS )) && download_hg "$netfile"
  793. ;;
  794. svn*)
  795. (( GET_VCS )) && download_svn "$netfile"
  796. ;;
  797. *)
  798. download_file "$netfile"
  799. ;;
  800. esac
  801.  
  802. popd &>/dev/null
  803. done
  804. }
  805.  
  806. # Automatically update pkgver variable if a pkgver() function is provided
  807. # Re-sources the PKGBUILD afterwards to allow for other variables that use $pkgver
  808. update_pkgver() {
  809. newpkgver=$(run_function_safe pkgver)
  810.  
  811. if [[ -n $newpkgver && $newpkgver != "$pkgver" ]]; then
  812. if [[ -f $BUILDFILE && -w $BUILDFILE ]]; then
  813. sed --follow-symlinks -i "s/^pkgver=[^ ]*/pkgver=$newpkgver/" "$BUILDFILE"
  814. sed --follow-symlinks -i "s/^pkgrel=[^ ]*/pkgrel=1/" "$BUILDFILE"
  815. source "$BUILDFILE"
  816. local fullver=$(get_full_version)
  817. msg "$(gettext "Updated version: %s")" "$pkgbase $fullver"
  818. else
  819. warning "$(gettext "%s is not writeable -- pkgver will not be updated")" \
  820. "$BUILDFILE"
  821. fi
  822. fi
  823. }
  824.  
  825. # Print 'source not found' error message and exit makepkg
  826. missing_source_file() {
  827. error "$(gettext "Unable to find source file %s.")" "$(get_filename "$1")"
  828. plain "$(gettext "Aborting...")"
  829. exit 1 # $E_MISSING_FILE
  830. }
  831.  
  832. ##
  833. # usage : get_full_version( [$pkgname] )
  834. # return : full version spec, including epoch (if necessary), pkgver, pkgrel
  835. ##
  836. get_full_version() {
  837. if [[ -z $1 ]]; then
  838. if [[ $epoch ]] && (( ! $epoch )); then
  839. printf "%s\n" "$pkgver-$pkgrel"
  840. else
  841. printf "%s\n" "$epoch:$pkgver-$pkgrel"
  842. fi
  843. else
  844. for i in pkgver pkgrel epoch; do
  845. local indirect="${i}_override"
  846. eval $(declare -f package_$1 | sed -n "s/\(^[[:space:]]*$i=\)/${i}_override=/p")
  847. [[ -z ${!indirect} ]] && eval ${indirect}=\"${!i}\"
  848. done
  849. if (( ! $epoch_override )); then
  850. printf "%s\n" "$pkgver_override-$pkgrel_override"
  851. else
  852. printf "%s\n" "$epoch_override:$pkgver_override-$pkgrel_override"
  853. fi
  854. fi
  855. }
  856.  
  857. ##
  858. # usage : get_pkg_arch( [$pkgname] )
  859. # return : architecture of the package
  860. ##
  861. get_pkg_arch() {
  862. if [[ -z $1 ]]; then
  863. if [[ $arch = "any" ]]; then
  864. printf "%s\n" "any"
  865. else
  866. printf "%s\n" "$CARCH"
  867. fi
  868. else
  869. local arch_override
  870. eval $(declare -f package_$1 | sed -n 's/\(^[[:space:]]*arch=\)/arch_override=/p')
  871. (( ${#arch_override[@]} == 0 )) && arch_override=("${arch[@]}")
  872. if [[ $arch_override = "any" ]]; then
  873. printf "%s\n" "any"
  874. else
  875. printf "%s\n" "$CARCH"
  876. fi
  877. fi
  878. }
  879.  
  880. ##
  881. # Checks to see if options are present in makepkg.conf or PKGBUILD;
  882. # PKGBUILD options always take precedence.
  883. #
  884. # usage : check_option( $option, $expected_val )
  885. # return : 0 - matches expected
  886. # 1 - does not match expected
  887. # 127 - not found
  888. ##
  889. check_option() {
  890. in_opt_array "$1" ${options[@]}
  891. case $? in
  892. 0) # assert enabled
  893. [[ $2 = y ]]
  894. return ;;
  895. 1) # assert disabled
  896. [[ $2 = n ]]
  897. return
  898. esac
  899.  
  900. # fall back to makepkg.conf options
  901. in_opt_array "$1" ${OPTIONS[@]}
  902. case $? in
  903. 0) # assert enabled
  904. [[ $2 = y ]]
  905. return ;;
  906. 1) # assert disabled
  907. [[ $2 = n ]]
  908. return
  909. esac
  910.  
  911. # not found
  912. return 127
  913. }
  914.  
  915.  
  916. ##
  917. # Check if option is present in BUILDENV
  918. #
  919. # usage : check_buildenv( $option, $expected_val )
  920. # return : 0 - matches expected
  921. # 1 - does not match expected
  922. # 127 - not found
  923. ##
  924. check_buildenv() {
  925. in_opt_array "$1" ${BUILDENV[@]}
  926. case $? in
  927. 0) # assert enabled
  928. [[ $2 = "y" ]]
  929. return ;;
  930. 1) # assert disabled
  931. [[ $2 = "n" ]]
  932. return ;;
  933. esac
  934.  
  935. # not found
  936. return 127
  937. }
  938.  
  939.  
  940. ##
  941. # usage : in_opt_array( $needle, $haystack )
  942. # return : 0 - enabled
  943. # 1 - disabled
  944. # 127 - not found
  945. ##
  946. in_opt_array() {
  947. local needle=$1; shift
  948.  
  949. local i opt
  950. for (( i = $#; i > 0; i-- )); do
  951. opt=${!i}
  952. if [[ $opt = "$needle" ]]; then
  953. # enabled
  954. return 0
  955. elif [[ $opt = "!$needle" ]]; then
  956. # disabled
  957. return 1
  958. fi
  959. done
  960.  
  961. # not found
  962. return 127
  963. }
  964.  
  965.  
  966. ##
  967. # usage : in_array( $needle, $haystack )
  968. # return : 0 - found
  969. # 1 - not found
  970. ##
  971. in_array() {
  972. local needle=$1; shift
  973. local item
  974. for item in "$@"; do
  975. [[ $item = "$needle" ]] && return 0 # Found
  976. done
  977. return 1 # Not Found
  978. }
  979.  
  980. source_has_signatures() {
  981. local file
  982. for file in "${source[@]}"; do
  983. if [[ ${file%%::*} = *.@(sig?(n)|asc) ]]; then
  984. return 0
  985. fi
  986. done
  987. return 1
  988. }
  989.  
  990. run_pacman() {
  991. local cmd
  992. if [[ ! $1 = -@(T|Qq) ]]; then
  993. cmd=("$PACMAN_PATH" $PACMAN_OPTS "$@")
  994. else
  995. cmd=("$PACMAN_PATH" "$@")
  996. fi
  997. if (( ! ASROOT )) && [[ ! $1 = -@(T|Qq) ]]; then
  998. if type -p sudo >/dev/null; then
  999. cmd=(sudo "${cmd[@]}")
  1000. else
  1001. cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
  1002. fi
  1003. fi
  1004. "${cmd[@]}"
  1005. }
  1006.  
  1007. check_deps() {
  1008. (( $# > 0 )) || return 0
  1009.  
  1010. local ret=0
  1011. local pmout
  1012. pmout=$(run_pacman -T "$@")
  1013. ret=$?
  1014.  
  1015. if (( ret == 127 )); then #unresolved deps
  1016. printf "%s\n" "$pmout"
  1017. elif (( ret )); then
  1018. error "$(gettext "'%s' returned a fatal error (%i): %s")" "$PACMAN" "$ret" "$pmout"
  1019. return "$ret"
  1020. fi
  1021. }
  1022.  
  1023. handle_deps() {
  1024. local R_DEPS_SATISFIED=0
  1025. local R_DEPS_MISSING=1
  1026.  
  1027. (( $# == 0 )) && return $R_DEPS_SATISFIED
  1028.  
  1029. local deplist="$*"
  1030.  
  1031. if (( ! DEP_BIN )); then
  1032. return $R_DEPS_MISSING
  1033. fi
  1034.  
  1035. if (( DEP_BIN )); then
  1036. # install missing deps from binary packages (using pacman -S)
  1037. msg "$(gettext "Installing missing dependencies...")"
  1038.  
  1039. if ! run_pacman -S --asdeps $deplist; then
  1040. error "$(gettext "'%s' failed to install missing dependencies.")" "$PACMAN"
  1041. exit 1 # TODO: error code
  1042. fi
  1043. fi
  1044.  
  1045. # we might need the new system environment
  1046. # save our shell options and turn off extglob
  1047. local shellopts=$(shopt -p)
  1048. shopt -u extglob
  1049. source /etc/profile &>/dev/null
  1050. eval "$shellopts"
  1051.  
  1052. return $R_DEPS_SATISFIED
  1053. }
  1054.  
  1055. resolve_deps() {
  1056. local R_DEPS_SATISFIED=0
  1057. local R_DEPS_MISSING=1
  1058.  
  1059. # deplist cannot be declared like this: local deplist=$(foo)
  1060. # Otherwise, the return value will depend on the assignment.
  1061. local deplist
  1062. deplist="$(set +E; check_deps $*)" || exit 1
  1063. [[ -z $deplist ]] && return $R_DEPS_SATISFIED
  1064.  
  1065. if handle_deps $deplist; then
  1066. # check deps again to make sure they were resolved
  1067. deplist="$(set +E; check_deps $*)" || exit 1
  1068. [[ -z $deplist ]] && return $R_DEPS_SATISFIED
  1069. fi
  1070.  
  1071. msg "$(gettext "Missing dependencies:")"
  1072. local dep
  1073. for dep in $deplist; do
  1074. msg2 "$dep"
  1075. done
  1076.  
  1077. return $R_DEPS_MISSING
  1078. }
  1079.  
  1080. remove_deps() {
  1081. (( ! RMDEPS )) && return
  1082.  
  1083. # check for packages removed during dependency install (e.g. due to conflicts)
  1084. # removing all installed packages is risky in this case
  1085. if [[ -n $(grep -xvFf <(printf '%s\n' "${current_packagelist[@]}") \
  1086. <(printf '%s\n' "${original_packagelist[@]}") || true) ]]; then
  1087. warning "$(gettext "Failed to remove installed dependencies.")"
  1088. return 0
  1089. fi
  1090.  
  1091. local deplist
  1092. deplist=($(grep -xvFf <(printf "%s\n" "${original_pkglist[@]}") \
  1093. <(printf "%s\n" "${current_pkglist[@]}") || true))
  1094. if [[ -z $deplist ]]; then
  1095. return
  1096. fi
  1097.  
  1098. msg "Removing installed dependencies..."
  1099. # exit cleanly on failure to remove deps as package has been built successfully
  1100. if ! run_pacman -Rn ${deplist[@]}; then
  1101. warning "$(gettext "Failed to remove installed dependencies.")"
  1102. return 0
  1103. fi
  1104. }
  1105.  
  1106. get_integlist() {
  1107. local integ
  1108. local integlist=()
  1109.  
  1110. for integ in md5 sha1 sha256 sha384 sha512; do
  1111. local integrity_sums=($(eval echo "\${${integ}sums[@]}"))
  1112. if [[ -n "$integrity_sums" ]]; then
  1113. integlist=(${integlist[@]} $integ)
  1114. fi
  1115. done
  1116.  
  1117. if (( ${#integlist[@]} > 0 )); then
  1118. printf "%s\n" "${integlist[@]}"
  1119. else
  1120. printf "%s\n" "${INTEGRITY_CHECK[@]}"
  1121. fi
  1122. }
  1123.  
  1124. generate_checksums() {
  1125. msg "$(gettext "Generating checksums for source files...")"
  1126.  
  1127. if ! type -p openssl >/dev/null; then
  1128. error "$(gettext "Cannot find the %s binary required for generating sourcefile checksums.")" "openssl"
  1129. exit 1 # $E_MISSING_PROGRAM
  1130. fi
  1131.  
  1132. local integlist
  1133. if (( $# == 0 )); then
  1134. integlist=$(get_integlist)
  1135. else
  1136. integlist=$@
  1137. fi
  1138.  
  1139. local integ
  1140. for integ in ${integlist[@]}; do
  1141. case "$integ" in
  1142. md5|sha1|sha256|sha384|sha512) : ;;
  1143. *)
  1144. error "$(gettext "Invalid integrity algorithm '%s' specified.")" "$integ"
  1145. exit 1;; # $E_CONFIG_ERROR
  1146. esac
  1147.  
  1148. local ct=0
  1149. local numsrc=${#source[@]}
  1150. printf "%s" "${integ}sums=("
  1151.  
  1152. local i
  1153. local indent=''
  1154. for (( i = 0; i < ${#integ} + 6; i++ )); do
  1155. indent="$indent "
  1156. done
  1157.  
  1158. local netfile
  1159. for netfile in "${source[@]}"; do
  1160. local proto sum
  1161. proto="$(get_protocol "$netfile")"
  1162.  
  1163. case $proto in
  1164. bzr*|git*|hg*|svn*)
  1165. sum="SKIP"
  1166. ;;
  1167. *)
  1168. if [[ ! $netfile = *.@(sig?(n)|asc) ]]; then
  1169. local file
  1170. file="$(get_filepath "$netfile")" || missing_source_file "$netfile"
  1171. sum="$(openssl dgst -${integ} "$file")"
  1172. sum=${sum##* }
  1173. else
  1174. sum="SKIP"
  1175. fi
  1176. ;;
  1177. esac
  1178.  
  1179. (( ct )) && printf "%s" "$indent"
  1180. printf "%s" "'$sum'"
  1181. ct=$(($ct+1))
  1182. (( $ct < $numsrc )) && echo
  1183. done
  1184.  
  1185. echo ")"
  1186. done
  1187. }
  1188.  
  1189. check_checksums() {
  1190. (( SKIPCHECKSUMS )) && return 0
  1191. (( ! ${#source[@]} )) && return 0
  1192.  
  1193. local correlation=0
  1194. local integ required
  1195. for integ in md5 sha1 sha256 sha384 sha512; do
  1196. local integrity_sums=($(eval echo "\${${integ}sums[@]}"))
  1197. if (( ${#integrity_sums[@]} == ${#source[@]} )); then
  1198. msg "$(gettext "Validating source files with %s...")" "${integ}sums"
  1199. correlation=1
  1200. local errors=0
  1201. local idx=0
  1202. local file
  1203. for file in "${source[@]}"; do
  1204. local found=1
  1205. file="$(get_filename "$file")"
  1206. printf "%s" " $file ... " >&2
  1207.  
  1208. if [[ ${integrity_sums[$idx]} = 'SKIP' ]]; then
  1209. echo "$(gettext "Skipped")" >&2
  1210. idx=$((idx + 1))
  1211. continue
  1212. fi
  1213.  
  1214. if ! file="$(get_filepath "$file")"; then
  1215. printf -- "$(gettext "NOT FOUND")\n" >&2
  1216. errors=1
  1217. found=0
  1218. fi
  1219.  
  1220. if (( $found )) ; then
  1221. local expectedsum="${integrity_sums[idx],,}"
  1222. local realsum="$(openssl dgst -${integ} "$file")"
  1223. realsum="${realsum##* }"
  1224. if [[ $expectedsum = "$realsum" ]]; then
  1225. printf -- "$(gettext "Passed")\n" >&2
  1226. else
  1227. printf -- "$(gettext "FAILED")\n" >&2
  1228. errors=1
  1229. fi
  1230. fi
  1231.  
  1232. idx=$((idx + 1))
  1233. done
  1234.  
  1235. if (( errors )); then
  1236. error "$(gettext "One or more files did not pass the validity check!")"
  1237. exit 1 # TODO: error code
  1238. fi
  1239. elif (( ${#integrity_sums[@]} )); then
  1240. error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ"
  1241. exit 1 # TODO: error code
  1242. fi
  1243. done
  1244.  
  1245. if (( ! correlation )); then
  1246. error "$(gettext "Integrity checks are missing.")"
  1247. exit 1 # TODO: error code
  1248. fi
  1249. }
  1250.  
  1251. check_pgpsigs() {
  1252. (( SKIPPGPCHECK )) && return 0
  1253. ! source_has_signatures && return 0
  1254.  
  1255. msg "$(gettext "Verifying source file signatures with %s...")" "gpg"
  1256.  
  1257. local file pubkey
  1258. local warning=0
  1259. local errors=0
  1260. local statusfile=$(mktemp)
  1261.  
  1262. for file in "${source[@]}"; do
  1263. file="$(get_filename "$file")"
  1264. if [[ ! $file = *.@(sig?(n)|asc) ]]; then
  1265. continue
  1266. fi
  1267.  
  1268. printf " %s ... " "${file%.*}" >&2
  1269.  
  1270. if ! file="$(get_filepath "$file")"; then
  1271. printf '%s\n' "$(gettext "SIGNATURE NOT FOUND")" >&2
  1272. errors=1
  1273. continue
  1274. fi
  1275.  
  1276. if ! sourcefile="$(get_filepath "${file%.*}")"; then
  1277. printf '%s\n' "$(gettext "SOURCE FILE NOT FOUND")" >&2
  1278. errors=1
  1279. continue
  1280. fi
  1281.  
  1282. if ! gpg --quiet --batch --status-file "$statusfile" --verify "$file" "$sourcefile" 2> /dev/null; then
  1283. printf '%s' "$(gettext "FAILED")" >&2
  1284. if ! pubkey=$(awk '/NO_PUBKEY/ { print $3; exit 1; }' "$statusfile"); then
  1285. printf ' (%s)' "$(gettext "unknown public key") $pubkey" >&2
  1286. warnings=1
  1287. else
  1288. errors=1
  1289. fi
  1290. printf '\n' >&2
  1291. else
  1292. if grep -q "REVKEYSIG" "$statusfile"; then
  1293. printf '%s (%s)' "$(gettext "FAILED")" "$(gettext "the key has been revoked.")" >&2
  1294. errors=1
  1295. else
  1296. printf '%s' "$(gettext "Passed")" >&2
  1297. if grep -q "EXPSIG" "$statusfile"; then
  1298. printf ' (%s)' "$(gettext "WARNING:") $(gettext "the signature has expired.")" >&2
  1299. warnings=1
  1300. elif grep -q "EXPKEYSIG" "$statusfile"; then
  1301. printf ' (%s)' "$(gettext "WARNING:") $(gettext "the key has expired.")" >&2
  1302. warnings=1
  1303. fi
  1304. fi
  1305. printf '\n' >&2
  1306. fi
  1307. done
  1308.  
  1309. rm -f "$statusfile"
  1310.  
  1311. if (( errors )); then
  1312. error "$(gettext "One or more PGP signatures could not be verified!")"
  1313. exit 1
  1314. fi
  1315.  
  1316. if (( warnings )); then
  1317. warning "$(gettext "Warnings have occurred while verifying the signatures.")"
  1318. plain "$(gettext "Please make sure you really trust them.")"
  1319. fi
  1320. }
  1321.  
  1322. check_source_integrity() {
  1323. if (( SKIPCHECKSUMS && SKIPPGPCHECK )); then
  1324. warning "$(gettext "Skipping all source file integrity checks.")"
  1325. elif (( SKIPCHECKSUMS )); then
  1326. warning "$(gettext "Skipping verification of source file checksums.")"
  1327. check_pgpsigs
  1328. elif (( SKIPPGPCHECK )); then
  1329. warning "$(gettext "Skipping verification of source file PGP signatures.")"
  1330. check_checksums
  1331. else
  1332. check_checksums
  1333. check_pgpsigs
  1334. fi
  1335. }
  1336.  
  1337. extract_sources() {
  1338. msg "$(gettext "Extracting sources...")"
  1339. local netfile
  1340. for netfile in "${source[@]}"; do
  1341. local file=$(get_filename "$netfile")
  1342. if in_array "$file" "${noextract[@]}"; then
  1343. #skip source files in the noextract=() array
  1344. # these are marked explicitly to NOT be extracted
  1345. continue
  1346. fi
  1347. local proto=$(get_protocol "$netfile")
  1348. case "$proto" in
  1349. bzr*)
  1350. extract_bzr "$netfile"
  1351. ;;
  1352. git*)
  1353. extract_git "$netfile"
  1354. ;;
  1355. hg*)
  1356. extract_hg "$netfile"
  1357. ;;
  1358. svn*)
  1359. extract_svn "$netfile"
  1360. ;;
  1361. *)
  1362. extract_file "$file"
  1363. ;;
  1364. esac
  1365. done
  1366.  
  1367. if (( PKGVERFUNC )); then
  1368. update_pkgver
  1369. check_pkgver || exit 1
  1370. check_build_status
  1371. fi
  1372. }
  1373.  
  1374. error_function() {
  1375. if [[ -p $logpipe ]]; then
  1376. rm "$logpipe"
  1377. fi
  1378. # first exit all subshells, then print the error
  1379. if (( ! BASH_SUBSHELL )); then
  1380. error "$(gettext "A failure occurred in %s().")" "$1"
  1381. plain "$(gettext "Aborting...")"
  1382. fi
  1383. exit 2 # $E_BUILD_FAILED
  1384. }
  1385.  
  1386. cd_safe() {
  1387. if ! cd "$1"; then
  1388. error "$(gettext "Failed to change to directory %s")" "$1"
  1389. plain "$(gettext "Aborting...")"
  1390. exit 1
  1391. fi
  1392. }
  1393.  
  1394. source_safe() {
  1395. shopt -u extglob
  1396. if ! source "$@"; then
  1397. error "$(gettext "Failed to source %s")" "$1"
  1398. exit 1
  1399. fi
  1400. shopt -s extglob
  1401. }
  1402.  
  1403. run_function_safe() {
  1404. local restoretrap
  1405.  
  1406. set -e
  1407. set -E
  1408.  
  1409. restoretrap=$(trap -p ERR)
  1410. trap 'error_function $pkgfunc' ERR
  1411.  
  1412. run_function "$1"
  1413.  
  1414. eval $restoretrap
  1415.  
  1416. set +E
  1417. set +e
  1418. }
  1419.  
  1420. run_function() {
  1421. if [[ -z $1 ]]; then
  1422. return 1
  1423. fi
  1424. local pkgfunc="$1"
  1425.  
  1426. # clear user-specified buildflags if requested
  1427. if check_option "buildflags" "n"; then
  1428. unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
  1429. fi
  1430.  
  1431. if check_option "debug" "y"; then
  1432. CFLAGS+=" $DEBUG_CFLAGS"
  1433. CXXFLAGS+=" $DEBUG_CXXFLAGS"
  1434. fi
  1435.  
  1436. # clear user-specified makeflags if requested
  1437. if check_option "makeflags" "n"; then
  1438. unset MAKEFLAGS
  1439. fi
  1440.  
  1441. msg "$(gettext "Starting %s()...")" "$pkgfunc"
  1442. cd_safe "$srcdir"
  1443.  
  1444. # ensure all necessary build variables are exported
  1445. export CPPFLAGS CFLAGS CXXFLAGS LDFLAGS MAKEFLAGS CHOST
  1446. # save our shell options so pkgfunc() can't override what we need
  1447. local shellopts=$(shopt -p)
  1448.  
  1449. local ret=0
  1450. if (( LOGGING )); then
  1451. local fullver=$(get_full_version)
  1452. local BUILDLOG="$LOGDEST/${pkgbase}-${fullver}-${CARCH}-$pkgfunc.log"
  1453. if [[ -f $BUILDLOG ]]; then
  1454. local i=1
  1455. while true; do
  1456. if [[ -f $BUILDLOG.$i ]]; then
  1457. i=$(($i +1))
  1458. else
  1459. break
  1460. fi
  1461. done
  1462. mv "$BUILDLOG" "$BUILDLOG.$i"
  1463. fi
  1464.  
  1465. # ensure overridden package variables survive tee with split packages
  1466. logpipe=$(mktemp -u "$LOGDEST/logpipe.XXXXXXXX")
  1467. mkfifo "$logpipe"
  1468. tee "$BUILDLOG" < "$logpipe" &
  1469. local teepid=$!
  1470.  
  1471. $pkgfunc &>"$logpipe"
  1472.  
  1473. wait $teepid
  1474. rm "$logpipe"
  1475. else
  1476. "$pkgfunc"
  1477. fi
  1478. # reset our shell options
  1479. eval "$shellopts"
  1480. }
  1481.  
  1482. run_prepare() {
  1483. run_function_safe "prepare"
  1484. }
  1485.  
  1486. run_build() {
  1487. # use distcc if it is requested (check buildenv and PKGBUILD opts)
  1488. if check_buildenv "distcc" "y" && ! check_option "distcc" "n"; then
  1489. [[ -d /usr/lib/distcc/bin ]] && export PATH="/usr/lib/distcc/bin:$PATH"
  1490. export DISTCC_HOSTS
  1491. fi
  1492.  
  1493. # use ccache if it is requested (check buildenv and PKGBUILD opts)
  1494. if check_buildenv "ccache" "y" && ! check_option "ccache" "n"; then
  1495. [[ -d /usr/lib/ccache/bin ]] && export PATH="/usr/lib/ccache/bin:$PATH"
  1496. fi
  1497.  
  1498. run_function_safe "build"
  1499. }
  1500.  
  1501. run_check() {
  1502. run_function_safe "check"
  1503. }
  1504.  
  1505. run_package() {
  1506. local pkgfunc
  1507. if [[ -z $1 ]]; then
  1508. pkgfunc="package"
  1509. else
  1510. pkgfunc="package_$1"
  1511. fi
  1512.  
  1513. run_function_safe "$pkgfunc"
  1514. }
  1515.  
  1516. build_id() {
  1517. LANG=C readelf -n $1 | sed -n '/Build ID/ { s/.*: //p; q; }'
  1518. }
  1519.  
  1520. strip_file() {
  1521. local binary=$1; shift
  1522.  
  1523. if check_option "debug" "y"; then
  1524. local bid=$(build_id "$binary")
  1525.  
  1526. # has this file already been stripped
  1527. if [[ -n "$bid" ]]; then
  1528. if [[ -f "$dbgdir/.build_id/${bid:0:2}/${bid:2}.debug" ]]; then
  1529. return
  1530. fi
  1531. elif [[ -f "$dbgdir/$binary.debug" ]]; then
  1532. return
  1533. fi
  1534.  
  1535. mkdir -p "$dbgdir/${binary%/*}"
  1536. objcopy --only-keep-debug "$binary" "$dbgdir/$binary.debug"
  1537. objcopy --add-gnu-debuglink="$dbgdir/${binary#/}.debug" "$binary"
  1538.  
  1539. # create any needed hardlinks
  1540. while read -d '' file ; do
  1541. if [[ "${binary}" -ef "${file}" && ! -f "$dbgdir/${file}.debug" ]]; then
  1542. mkdir -p "$dbgdir/${file%/*}"
  1543. ln "$dbgdir/${binary}.debug" "$dbgdir/${file}.debug"
  1544. fi
  1545. done < <(find . -type f -perm -u+w -print0 2>/dev/null)
  1546.  
  1547. if [[ -n "$bid" ]]; then
  1548. local target
  1549. mkdir -p "$dbgdir/.build_id/${bid:0:2}"
  1550.  
  1551. target="../../../../../${binary#./}"
  1552. target="${target/..\/..\/usr\/lib\/}"
  1553. target="${target/..\/usr\/}"
  1554. ln -s "$target" "$dbgdir/.build_id/${bid:0:2}/${bid:2}"
  1555.  
  1556. target="../../${binary#./}.debug"
  1557. ln -s "$target" "$dbgdir/.build_id/${bid:0:2}/${bid:2}.debug"
  1558. fi
  1559. fi
  1560.  
  1561. strip $@ "$binary"
  1562. }
  1563.  
  1564. tidy_install() {
  1565. cd_safe "$pkgdir"
  1566. msg "$(gettext "Tidying install...")"
  1567.  
  1568. if check_option "docs" "n" && [[ -n ${DOC_DIRS[*]} ]]; then
  1569. msg2 "$(gettext "Removing doc files...")"
  1570. rm -rf -- ${DOC_DIRS[@]}
  1571. fi
  1572.  
  1573. if check_option "purge" "y" && [[ -n ${PURGE_TARGETS[*]} ]]; then
  1574. msg2 "$(gettext "Purging unwanted files...")"
  1575. local pt
  1576. for pt in "${PURGE_TARGETS[@]}"; do
  1577. if [[ ${pt} = "${pt//\/}" ]]; then
  1578. find . ! -type d -name "${pt}" -exec rm -f -- '{}' +
  1579. else
  1580. rm -f ${pt}
  1581. fi
  1582. done
  1583. fi
  1584.  
  1585. if check_option "libtool" "n"; then
  1586. msg2 "$(gettext "Removing "%s" files...")" "libtool"
  1587. find . ! -type d -name "*.la" -exec rm -f -- '{}' +
  1588. fi
  1589.  
  1590. if check_option "staticlibs" "n"; then
  1591. msg2 "$(gettext "Removing "%s" files...")" "static library"
  1592. find . ! -type d -name "*.a" -exec rm -f -- '{}' +
  1593. fi
  1594.  
  1595. if check_option "emptydirs" "n"; then
  1596. msg2 "$(gettext "Removing empty directories...")"
  1597. find . -depth -type d -exec rmdir '{}' + 2>/dev/null
  1598. fi
  1599.  
  1600. # check existence of backup files
  1601. local file
  1602. for file in "${backup[@]}"; do
  1603. if [[ ! -f $file ]]; then
  1604. warning "$(gettext "%s entry file not in package : %s")" "backup" "$file"
  1605. fi
  1606. done
  1607.  
  1608. # check for references to the build and package directory
  1609. if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${srcdir}" ; then
  1610. warning "$(gettext "Package contains reference to %s")" "\$srcdir"
  1611. fi
  1612. if find "${pkgdir}" -type f -print0 | xargs -0 grep -q -I "${pkgdirbase}" ; then
  1613. warning "$(gettext "Package contains reference to %s")" "\$pkgdir"
  1614. fi
  1615.  
  1616. if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
  1617. msg2 "$(gettext "Compressing man and info pages...")"
  1618. local file files inode link
  1619. while read -rd ' ' inode; do
  1620. read file
  1621. find ${MAN_DIRS[@]} -type l 2>/dev/null |
  1622. while read link ; do
  1623. if [[ "${file}" -ef "${link}" ]] ; then
  1624. rm -f "$link" "${link}.gz"
  1625. if [[ ${file%/*} = ${link%/*} ]]; then
  1626. ln -s -- "${file##*/}.gz" "${link}.gz"
  1627. else
  1628. ln -s -- "/${file}.gz" "${link}.gz"
  1629. fi
  1630. fi
  1631. done
  1632. if [[ -z ${files[$inode]} ]]; then
  1633. files[$inode]=$file
  1634. gzip -9 -n -f "$file"
  1635. else
  1636. rm -f "$file"
  1637. ln "${files[$inode]}.gz" "${file}.gz"
  1638. chmod 644 "${file}.gz"
  1639. fi
  1640. done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
  1641. -exec stat -c '%i %n' '{}' + 2>/dev/null)
  1642. fi
  1643.  
  1644. if check_option "strip" "y"; then
  1645. msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
  1646. # make sure library stripping variables are defined to prevent excess stripping
  1647. [[ -z ${STRIP_SHARED+x} ]] && STRIP_SHARED="-S"
  1648. [[ -z ${STRIP_STATIC+x} ]] && STRIP_STATIC="-S"
  1649.  
  1650. if check_option "debug" "y"; then
  1651. dbgdir="$pkgdir-debug/usr/lib/debug"
  1652. mkdir -p "$dbgdir"
  1653. fi
  1654.  
  1655. local binary strip_flags
  1656. find . -type f -perm -u+w -print0 2>/dev/null | while read -d '' binary ; do
  1657. case "$(file -bi "$binary")" in
  1658. *application/x-sharedlib*) # Libraries (.so)
  1659. strip_flags="$STRIP_SHARED";;
  1660. *application/x-archive*) # Libraries (.a)
  1661. strip_flags="$STRIP_STATIC";;
  1662. *application/x-executable*) # Binaries
  1663. strip_flags="$STRIP_BINARIES";;
  1664. *)
  1665. continue ;;
  1666. esac
  1667. strip_file "$binary" ${strip_flags}
  1668. done
  1669. fi
  1670.  
  1671. if check_option "upx" "y"; then
  1672. msg2 "$(gettext "Compressing binaries with %s...")" "UPX"
  1673. local binary
  1674. find . -type f -perm -u+w 2>/dev/null | while read binary ; do
  1675. if [[ $(file -bi "$binary") = *'application/x-executable'* ]]; then
  1676. upx $UPXFLAGS "$binary" &>/dev/null ||
  1677. warning "$(gettext "Could not compress binary : %s")" "${binary/$pkgdir\//}"
  1678. fi
  1679. done
  1680. fi
  1681. }
  1682.  
  1683. find_libdepends() {
  1684. local d sodepends;
  1685.  
  1686. sodepends=0;
  1687. for d in "${depends[@]}"; do
  1688. if [[ $d = *.so ]]; then
  1689. sodepends=1;
  1690. break;
  1691. fi
  1692. done
  1693.  
  1694. if (( sodepends == 0 )); then
  1695. printf '%s\n' "${depends[@]}"
  1696. return;
  1697. fi
  1698.  
  1699. local libdeps filename soarch sofile soname soversion;
  1700. declare -A libdeps;
  1701.  
  1702. while read filename; do
  1703. # get architecture of the file; if soarch is empty it's not an ELF binary
  1704. soarch=$(LC_ALL=C readelf -h "$filename" 2>/dev/null | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
  1705. [[ -n "$soarch" ]] || continue
  1706.  
  1707. # process all libraries needed by the binary
  1708. for sofile in $(LC_ALL=C readelf -d "$filename" 2>/dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p')
  1709. do
  1710. # extract the library name: libfoo.so
  1711. soname="${sofile%.so?(+(.+([0-9])))}".so
  1712. # extract the major version: 1
  1713. soversion="${sofile##*\.so\.}"
  1714.  
  1715. if [[ ${libdeps[$soname]} ]]; then
  1716. if [[ ${libdeps[$soname]} != *${soversion}-${soarch}* ]]; then
  1717. libdeps[$soname]+=" ${soversion}-${soarch}"
  1718. fi
  1719. else
  1720. libdeps[$soname]="${soversion}-${soarch}"
  1721. fi
  1722. done
  1723. done < <(find "$pkgdir" -type f -perm -u+x)
  1724.  
  1725. local libdepends v
  1726. for d in "${depends[@]}"; do
  1727. case "$d" in
  1728. *.so)
  1729. if [[ ${libdeps[$d]} ]]; then
  1730. for v in ${libdeps[$d]}; do
  1731. libdepends+=("$d=$v")
  1732. done
  1733. else
  1734. warning "$(gettext "Library listed in %s is not required by any files: %s")" "'depends'" "$d"
  1735. libdepends+=("$d")
  1736. fi
  1737. ;;
  1738. *)
  1739. libdepends+=("$d")
  1740. ;;
  1741. esac
  1742. done
  1743.  
  1744. printf '%s\n' "${libdepends[@]}"
  1745. }
  1746.  
  1747.  
  1748. find_libprovides() {
  1749. local p libprovides missing
  1750. for p in "${provides[@]}"; do
  1751. missing=0
  1752. case "$p" in
  1753. *.so)
  1754. mapfile -t filename < <(find "$pkgdir" -type f -name $p\*)
  1755. if [[ $filename ]]; then
  1756. # packages may provide multiple versions of the same library
  1757. for fn in "${filename[@]}"; do
  1758. # check if we really have a shared object
  1759. if LC_ALL=C readelf -h "$fn" 2>/dev/null | grep -q '.*Type:.*DYN (Shared object file).*'; then
  1760. # get the string binaries link to (e.g. libfoo.so.1.2 -> libfoo.so.1)
  1761. local sofile=$(LC_ALL=C readelf -d "$fn" 2>/dev/null | sed -n 's/.*Library soname: \[\(.*\)\].*/\1/p')
  1762. if [[ -z "$sofile" ]]; then
  1763. warning "$(gettext "Library listed in %s is not versioned: %s")" "'provides'" "$p"
  1764. libprovides+=("$p")
  1765. continue
  1766. fi
  1767.  
  1768. # get the library architecture (32 or 64 bit)
  1769. local soarch=$(LC_ALL=C readelf -h "$fn" | sed -n 's/.*Class.*ELF\(32\|64\)/\1/p')
  1770.  
  1771. # extract the library major version
  1772. local soversion="${sofile##*\.so\.}"
  1773.  
  1774. libprovides+=("${p}=${soversion}-${soarch}")
  1775. else
  1776. warning "$(gettext "Library listed in %s is not a shared object: %s")" "'provides'" "$p"
  1777. libprovides+=("$p")
  1778. fi
  1779. done
  1780. else
  1781. libprovides+=("$p")
  1782. missing=1
  1783. fi
  1784. ;;
  1785. *)
  1786. libprovides+=("$p")
  1787. ;;
  1788. esac
  1789.  
  1790. if (( missing )); then
  1791. warning "$(gettext "Cannot find library listed in %s: %s")" "'provides'" "$p"
  1792. fi
  1793. done
  1794.  
  1795. printf '%s\n' "${libprovides[@]}"
  1796. }
  1797.  
  1798. check_license() {
  1799. # TODO maybe remove this at some point
  1800. # warn if license array is not present or empty
  1801. if [[ -z $license ]]; then
  1802. warning "$(gettext "Please add a license line to your %s!")" "$BUILDSCRIPT"
  1803. plain "$(gettext "Example for GPL\'ed software: %s.")" "license=('GPL')"
  1804. fi
  1805. }
  1806.  
  1807. write_pkginfo() {
  1808. local builddate=$(date -u "+%s")
  1809. if [[ -n $PACKAGER ]]; then
  1810. local packager="$PACKAGER"
  1811. else
  1812. local packager="Unknown Packager"
  1813. fi
  1814.  
  1815. local size="$(/usr/bin/du -sk --apparent-size)"
  1816. size="$(( ${size%%[^0-9]*} * 1024 ))"
  1817.  
  1818. msg2 "$(gettext "Generating %s file...")" ".PKGINFO"
  1819. printf "# Generated by makepkg %s\n" "$makepkg_version"
  1820. (( INFAKEROOT )) && printf "# using %s\n" "$(fakeroot -v)"
  1821. printf "# %s\n" "$(LC_ALL=C date -u)"
  1822. printf "pkgname = %s\n" "$pkgname"
  1823. (( SPLITPKG )) && printf "pkgbase = %s\n" "$pkgbase"
  1824. printf "pkgver = %s\n" "$(get_full_version)"
  1825. printf "pkgdesc = %s\n" "${pkgdesc//+([[:space:]])/ }"
  1826. printf "url = %s\n" "$url"
  1827. printf "builddate = %s\n" "$builddate"
  1828. printf "packager = %s\n" "$packager"
  1829. printf "size = %s\n" "$size"
  1830. printf "arch = %s\n" "$pkgarch"
  1831.  
  1832. mapfile -t provides < <(find_libprovides)
  1833. mapfile -t depends < <(find_libdepends)
  1834.  
  1835. [[ $license ]] && printf "license = %s\n" "${license[@]}"
  1836. [[ $replaces ]] && printf "replaces = %s\n" "${replaces[@]}"
  1837. [[ $groups ]] && printf "group = %s\n" "${groups[@]}"
  1838. [[ $conflicts ]] && printf "conflict = %s\n" "${conflicts[@]}"
  1839. [[ $provides ]] && printf "provides = %s\n" "${provides[@]}"
  1840. [[ $backup ]] && printf "backup = %s\n" "${backup[@]}"
  1841. [[ $depends ]] && printf "depend = %s\n" "${depends[@]}"
  1842. [[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]//+([[:space:]])/ }"
  1843. [[ $makedepends ]] && printf "makedepend = %s\n" "${makedepends[@]}"
  1844. [[ $checkdepends ]] && printf "checkdepend = %s\n" "${checkdepends[@]}"
  1845.  
  1846. local it
  1847. for it in "${packaging_options[@]}"; do
  1848. check_option "$it" "y"
  1849. case $? in
  1850. 0)
  1851. printf "makepkgopt = %s\n" "$it"
  1852. ;;
  1853. 1)
  1854. printf "makepkgopt = %s\n" "!$it"
  1855. ;;
  1856. esac
  1857. done
  1858.  
  1859. check_license
  1860. }
  1861.  
  1862. create_package() {
  1863. if [[ ! -d $pkgdir ]]; then
  1864. error "$(gettext "Missing %s directory.")" "pkg/"
  1865. plain "$(gettext "Aborting...")"
  1866. exit 1 # $E_MISSING_PKGDIR
  1867. fi
  1868.  
  1869. cd_safe "$pkgdir"
  1870. msg "$(gettext "Creating package \"%s\"...")" "$pkgname"
  1871.  
  1872. pkgarch=$(get_pkg_arch)
  1873.  
  1874. write_pkginfo > .PKGINFO
  1875.  
  1876. local comp_files=('.PKGINFO')
  1877.  
  1878. # check for changelog/install files
  1879. for i in 'changelog/.CHANGELOG' 'install/.INSTALL'; do
  1880. IFS='/' read -r orig dest < <(printf '%s\n' "$i")
  1881.  
  1882. if [[ -n ${!orig} ]]; then
  1883. msg2 "$(gettext "Adding %s file...")" "$orig"
  1884. cp "$startdir/${!orig}" "$dest"
  1885. chmod 644 "$dest"
  1886. comp_files+=("$dest")
  1887. fi
  1888. done
  1889.  
  1890. # tar it up
  1891. local fullver=$(get_full_version)
  1892. local pkg_file="$PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT}"
  1893. local ret=0
  1894.  
  1895. [[ -f $pkg_file ]] && rm -f "$pkg_file"
  1896. [[ -f $pkg_file.sig ]] && rm -f "$pkg_file.sig"
  1897.  
  1898. # when fileglobbing, we want * in an empty directory to expand to
  1899. # the null string rather than itself
  1900. shopt -s nullglob
  1901.  
  1902. msg2 "$(gettext "Generating .MTREE file...")"
  1903. bsdtar -czf .MTREE --format=mtree \
  1904. --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' \
  1905. "${comp_files[@]}" *
  1906. comp_files+=(".MTREE")
  1907.  
  1908. msg2 "$(gettext "Compressing package...")"
  1909. # TODO: Maybe this can be set globally for robustness
  1910. shopt -s -o pipefail
  1911. # bsdtar's gzip compression always saves the time stamp, making one
  1912. # archive created using the same command line distinct from another.
  1913. # Disable bsdtar compression and use gzip -n for now.
  1914. bsdtar -cf - "${comp_files[@]}" * |
  1915. case "$PKGEXT" in
  1916. *tar.gz) ${COMPRESSGZ[@]:-gzip -c -f -n} ;;
  1917. *tar.bz2) ${COMPRESSBZ2[@]:-bzip2 -c -f} ;;
  1918. *tar.xz) ${COMPRESSXZ[@]:-xz -c -z -} ;;
  1919. *tar.lrz) ${COMPRESSLRZ[@]:-lrzip -q} ;;
  1920. *tar.lzo) ${COMPRESSLZO[@]:-lzop -q} ;;
  1921. *tar.Z) ${COMPRESSZ[@]:-compress -c -f} ;;
  1922. *tar) cat ;;
  1923. *) warning "$(gettext "'%s' is not a valid archive extension.")" \
  1924. "$PKGEXT"; cat ;;
  1925. esac > "${pkg_file}" || ret=$?
  1926.  
  1927. shopt -u nullglob
  1928. shopt -u -o pipefail
  1929.  
  1930. if (( ret )); then
  1931. error "$(gettext "Failed to create package file.")"
  1932. exit 1 # TODO: error code
  1933. fi
  1934.  
  1935. create_signature "$pkg_file"
  1936.  
  1937. if (( ! ret )) && [[ ! "$PKGDEST" -ef "${startdir}" ]]; then
  1938. rm -f "${pkg_file/$PKGDEST/$startdir}"
  1939. ln -s "${pkg_file}" "${pkg_file/$PKGDEST/$startdir}"
  1940. ret=$?
  1941. if [[ -f $pkg_file.sig ]]; then
  1942. rm -f "${pkg_file/$PKGDEST/$startdir}.sig"
  1943. ln -s "$pkg_file.sig" "${pkg_file/$PKGDEST/$startdir}.sig"
  1944. fi
  1945. fi
  1946.  
  1947. if (( ret )); then
  1948. warning "$(gettext "Failed to create symlink to package file.")"
  1949. fi
  1950. }
  1951.  
  1952. create_debug_package() {
  1953. # check if a debug package was requested
  1954. if ! check_option "debug" "y" || ! check_option "strip" "y"; then
  1955. return
  1956. fi
  1957.  
  1958. pkgdir="${pkgdir}-debug"
  1959.  
  1960. # check if we have any debug symbols to package
  1961. if dir_is_empty "$pkgdir/usr/lib/debug"; then
  1962. return
  1963. fi
  1964.  
  1965. depends=("$pkgname=$(get_full_version)")
  1966. pkgdesc="Detached debugging symbols for $pkgname"
  1967. pkgname=$pkgname-debug
  1968.  
  1969. unset groups optdepends provides conflicts replaces backup install changelog
  1970.  
  1971. create_package
  1972. }
  1973.  
  1974. create_signature() {
  1975. if [[ $SIGNPKG != 'y' ]]; then
  1976. return
  1977. fi
  1978. local ret=0
  1979. local filename="$1"
  1980. msg "$(gettext "Signing package...")"
  1981.  
  1982. local SIGNWITHKEY=""
  1983. if [[ -n $GPGKEY ]]; then
  1984. SIGNWITHKEY="-u ${GPGKEY}"
  1985. fi
  1986. # The signature will be generated directly in ascii-friendly format
  1987. gpg --detach-sign --use-agent ${SIGNWITHKEY} "$filename" &>/dev/null || ret=$?
  1988.  
  1989.  
  1990. if (( ! ret )); then
  1991. msg2 "$(gettext "Created signature file %s.")" "$filename.sig"
  1992. else
  1993. warning "$(gettext "Failed to sign package file.")"
  1994. fi
  1995. }
  1996.  
  1997. create_srcpackage() {
  1998. local ret=0
  1999. msg "$(gettext "Creating source package...")"
  2000. local srclinks="$(mktemp -d "$startdir"/srclinks.XXXXXXXXX)"
  2001. mkdir "${srclinks}"/${pkgbase}
  2002.  
  2003. check_license
  2004.  
  2005. msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT"
  2006. ln -s "${BUILDFILE}" "${srclinks}/${pkgbase}/${BUILDSCRIPT}"
  2007.  
  2008. local file
  2009. for file in "${source[@]}"; do
  2010. if [[ "$file" = "$(get_filename "$file")" ]] || (( SOURCEONLY == 2 )); then
  2011. local absfile
  2012. absfile=$(get_filepath "$file") || missing_source_file "$file"
  2013. msg2 "$(gettext "Adding %s...")" "${absfile##*/}"
  2014. ln -s "$absfile" "$srclinks/$pkgbase"
  2015. fi
  2016. done
  2017.  
  2018. local i
  2019. for i in 'changelog' 'install'; do
  2020. local file
  2021. while read -r file; do
  2022. # evaluate any bash variables used
  2023. eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
  2024. if [[ $file && ! -f "${srclinks}/${pkgbase}/$file" ]]; then
  2025. msg2 "$(gettext "Adding %s file (%s)...")" "$i" "${file}"
  2026. ln -s "${startdir}/$file" "${srclinks}/${pkgbase}/"
  2027. fi
  2028. done < <(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE")
  2029. done
  2030.  
  2031. local TAR_OPT
  2032. case "$SRCEXT" in
  2033. *tar.gz) TAR_OPT="-z" ;;
  2034. *tar.bz2) TAR_OPT="-j" ;;
  2035. *tar.xz) TAR_OPT="-J" ;;
  2036. *tar.lrz) TAR_OPT="--lrzip" ;;
  2037. *tar.lzo) TAR_OPT="--lzop" ;;
  2038. *tar.Z) TAR_OPT="-Z" ;;
  2039. *tar) TAR_OPT="" ;;
  2040. *) warning "$(gettext "'%s' is not a valid archive extension.")" \
  2041. "$SRCEXT" ;;
  2042. esac
  2043.  
  2044. local fullver=$(get_full_version)
  2045. local pkg_file="$SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT}"
  2046.  
  2047. # tar it up
  2048. msg2 "$(gettext "Compressing source package...")"
  2049. cd_safe "${srclinks}"
  2050. if ! bsdtar -cL ${TAR_OPT} -f "$pkg_file" ${pkgbase}; then
  2051. error "$(gettext "Failed to create source package file.")"
  2052. exit 1 # TODO: error code
  2053. fi
  2054.  
  2055. if [[ ! "$SRCPKGDEST" -ef "${startdir}" ]]; then
  2056. rm -f "${pkg_file/$SRCPKGDEST/$startdir}"
  2057. ln -s "${pkg_file}" "${pkg_file/$SRCPKGDEST/$startdir}"
  2058. ret=$?
  2059. fi
  2060.  
  2061. if (( ret )); then
  2062. warning "$(gettext "Failed to create symlink to source package file.")"
  2063. fi
  2064.  
  2065. cd_safe "${startdir}"
  2066. rm -rf "${srclinks}"
  2067. }
  2068.  
  2069. install_package() {
  2070. (( ! INSTALL )) && return
  2071.  
  2072. if (( ! SPLITPKG )); then
  2073. msg "$(gettext "Installing package %s with %s...")" "$pkgname" "$PACMAN -U"
  2074. else
  2075. msg "$(gettext "Installing %s package group with %s...")" "$pkgbase" "$PACMAN -U"
  2076. fi
  2077.  
  2078. local fullver pkgarch pkg pkglist
  2079. (( ASDEPS )) && pkglist+=('--asdeps')
  2080. (( NEEDED )) && pkglist+=('--needed')
  2081.  
  2082. for pkg in ${pkgname[@]}; do
  2083. fullver=$(get_full_version $pkg)
  2084. pkgarch=$(get_pkg_arch $pkg)
  2085. pkglist+=("$PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT}")
  2086.  
  2087. if [[ -f "$PKGDEST/${pkg}-debug-${fullver}-${pkgarch}${PKGEXT}" ]]; then
  2088. pkglist+=("$PKGDEST/${pkg}-debug-${fullver}-${pkgarch}${PKGEXT}")
  2089. fi
  2090. done
  2091.  
  2092. if ! run_pacman -U ${pkglist[@]}; then
  2093. warning "$(gettext "Failed to install built package(s).")"
  2094. return 0
  2095. fi
  2096. }
  2097.  
  2098. check_sanity() {
  2099. # check for no-no's in the build script
  2100. local i
  2101. local ret=0
  2102. for i in 'pkgname' 'pkgrel'; do
  2103. if [[ -z ${!i} ]]; then
  2104. error "$(gettext "%s is not allowed to be empty.")" "$i"
  2105. ret=1
  2106. fi
  2107. done
  2108.  
  2109. for i in "${pkgname[@]}"; do
  2110. if [[ ${i:0:1} = "-" ]]; then
  2111. error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgname"
  2112. ret=1
  2113. fi
  2114. if [[ ${i:0:1} = "." ]]; then
  2115. error "$(gettext "%s is not allowed to start with a dot.")" "pkgname"
  2116. ret=1
  2117. fi
  2118. if [[ $i = *[^[:alnum:]+_.@-]* ]]; then
  2119. error "$(gettext "%s contains invalid characters: '%s'")" \
  2120. 'pkgname' "${pkgname//[[:alnum:]+_.@-]}"
  2121. ret=1
  2122. fi
  2123. done
  2124.  
  2125. if [[ ${pkgbase:0:1} = "-" ]]; then
  2126. error "$(gettext "%s is not allowed to start with a hyphen.")" "pkgbase"
  2127. ret=1
  2128. fi
  2129.  
  2130. if (( ! PKGVERFUNC )) ; then
  2131. check_pkgver || ret=1
  2132. fi
  2133.  
  2134. awk -F'=' '$1 ~ /^[[:space:]]*pkgrel$/' "$BUILDFILE" | sed "s/[[:space:]]*#.*//" |
  2135. while IFS='=' read -r _ i; do
  2136. eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
  2137. if [[ $i != +([0-9])?(.+([0-9])) ]]; then
  2138. error "$(gettext "%s must be a decimal.")" "pkgrel"
  2139. return 1
  2140. fi
  2141. done || ret=1
  2142.  
  2143. awk -F'=' '$1 ~ /^[[:space:]]*epoch$/' "$BUILDFILE" |
  2144. while IFS='=' read -r _ i; do
  2145. eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
  2146. if [[ $i != *([[:digit:]]) ]]; then
  2147. error "$(gettext "%s must be an integer.")" "epoch"
  2148. return 1
  2149. fi
  2150. done || ret=1
  2151.  
  2152. if [[ $arch != 'any' ]]; then
  2153. if ! in_array $CARCH ${arch[@]}; then
  2154. if (( ! IGNOREARCH )); then
  2155. error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgbase" "$CARCH"
  2156. plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT"
  2157. plain "$(gettext "such as %s.")" "arch=('$CARCH')"
  2158. ret=1
  2159. fi
  2160. fi
  2161. fi
  2162.  
  2163. if (( ${#pkgname[@]} > 1 )); then
  2164. for i in ${pkgname[@]}; do
  2165. local arch_list=""
  2166. eval $(declare -f package_${i} | sed -n 's/\(^[[:space:]]*arch=\)/arch_list=/p')
  2167. if [[ ${arch_list[@]} && ${arch_list} != 'any' ]]; then
  2168. if ! in_array $CARCH ${arch_list[@]}; then
  2169. if (( ! IGNOREARCH )); then
  2170. error "$(gettext "%s is not available for the '%s' architecture.")" "$i" "$CARCH"
  2171. ret=1
  2172. fi
  2173. fi
  2174. fi
  2175. done
  2176. fi
  2177.  
  2178. local provides_list=()
  2179. eval $(awk '/^[[:space:]]*provides=/,/\)/' "$BUILDFILE" | \
  2180. sed -e "s/provides=/provides_list+=/" -e "s/#.*//" -e 's/\\$//')
  2181. for i in ${provides_list[@]}; do
  2182. if [[ $i == *['<>']* ]]; then
  2183. error "$(gettext "%s array cannot contain comparison (< or >) operators.")" "provides"
  2184. ret=1
  2185. fi
  2186. done
  2187.  
  2188. local backup_list=()
  2189. eval $(awk '/^[[:space:]]*backup=/,/\)/' "$BUILDFILE" | \
  2190. sed -e "s/backup=/backup_list+=/" -e "s/#.*//" -e 's/\\$//')
  2191. for i in "${backup_list[@]}"; do
  2192. if [[ ${i:0:1} = "/" ]]; then
  2193. error "$(gettext "%s entry should not contain leading slash : %s")" "backup" "$i"
  2194. ret=1
  2195. fi
  2196. done
  2197.  
  2198. local optdepends_list=()
  2199. eval $(awk '/^[[:space:]]*optdepends=\(/,/\)[[:space:]]*(#.*)?$/' "$BUILDFILE" | \
  2200. sed -e "s/optdepends=/optdepends_list+=/" -e "s/#.*//" -e 's/\\$//')
  2201. for i in "${optdepends_list[@]}"; do
  2202. local pkg=${i%%:[[:space:]]*}
  2203. # the '-' character _must_ be first or last in the character range
  2204. if [[ $pkg != +([-[:alnum:]><=.+_:]) ]]; then
  2205. error "$(gettext "Invalid syntax for %s : '%s'")" "optdepend" "$i"
  2206. ret=1
  2207. fi
  2208. done
  2209.  
  2210. for i in 'changelog' 'install'; do
  2211. local file
  2212. while read -r file; do
  2213. # evaluate any bash variables used
  2214. eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
  2215. if [[ $file && ! -f $file ]]; then
  2216. error "$(gettext "%s file (%s) does not exist.")" "$i" "$file"
  2217. ret=1
  2218. fi
  2219. done < <(sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE")
  2220. done
  2221.  
  2222. local valid_options=1
  2223. local known kopt options_list
  2224. eval $(awk '/^[[:space:]]*options=/,/\)/' "$BUILDFILE" | \
  2225. sed -e "s/options=/options_list+=/" -e "s/#.*//" -e 's/\\$//')
  2226. for i in ${options_list[@]}; do
  2227. known=0
  2228. # check if option matches a known option or its inverse
  2229. for kopt in ${packaging_options[@]} ${other_options[@]}; do
  2230. if [[ ${i} = "${kopt}" || ${i} = "!${kopt}" ]]; then
  2231. known=1
  2232. fi
  2233. done
  2234. if (( ! known )); then
  2235. error "$(gettext "%s array contains unknown option '%s'")" "options" "$i"
  2236. valid_options=0
  2237. fi
  2238. done
  2239. if (( ! valid_options )); then
  2240. ret=1
  2241. fi
  2242.  
  2243. if (( ${#pkgname[@]} > 1 )); then
  2244. for i in ${pkgname[@]}; do
  2245. if ! declare -f package_${i} >/dev/null; then
  2246. error "$(gettext "Missing %s function for split package '%s'")" "package_$i()" "$i"
  2247. ret=1
  2248. fi
  2249. done
  2250. fi
  2251.  
  2252. for i in ${PKGLIST[@]}; do
  2253. if ! in_array $i ${pkgname[@]}; then
  2254. error "$(gettext "Requested package %s is not provided in %s")" "$i" "$BUILDFILE"
  2255. ret=1
  2256. fi
  2257. done
  2258.  
  2259. return $ret
  2260. }
  2261.  
  2262. check_pkgver() {
  2263. local ret=0
  2264.  
  2265. if [[ -z ${pkgver} ]]; then
  2266. error "$(gettext "%s is not allowed to be empty.")" "pkgver"
  2267. ret=1
  2268. fi
  2269.  
  2270. awk -F'=' '$1 ~ /^[[:space:]]*pkgver$/' "$BUILDFILE" | sed "s/[[:space:]]*#.*//" |
  2271. while IFS='=' read -r _ i; do
  2272. eval i=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
  2273. if [[ $i = *[[:space:]:-]* ]]; then
  2274. error "$(gettext "%s is not allowed to contain colons, hyphens or whitespace.")" "pkgver"
  2275. return 1
  2276. fi
  2277. done || ret=1
  2278.  
  2279. return $ret
  2280. }
  2281.  
  2282. check_software() {
  2283. # check for needed software
  2284. local ret=0
  2285.  
  2286. # check for PACMAN if we need it
  2287. if (( ! INFAKEROOT && ( ! NODEPS || DEP_BIN || RMDEPS || INSTALL ) )); then
  2288. if [[ -z $PACMAN_PATH ]]; then
  2289. error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN"
  2290. ret=1
  2291. fi
  2292. fi
  2293.  
  2294. # check for sudo if we will need it during makepkg execution
  2295. if (( ! ( ASROOT || INFAKEROOT ) && ( DEP_BIN || RMDEPS || INSTALL ) )); then
  2296. if ! type -p sudo >/dev/null; then
  2297. warning "$(gettext "Cannot find the %s binary. Will use %s to acquire root privileges.")" "sudo" "su"
  2298. fi
  2299. fi
  2300.  
  2301. # fakeroot - building as non-root user
  2302. if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then
  2303. if ! type -p fakeroot >/dev/null; then
  2304. error "$(gettext "Cannot find the %s binary required for building as non-root user.")" "fakeroot"
  2305. ret=1
  2306. fi
  2307. fi
  2308.  
  2309. # gpg - package signing
  2310. if [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; then
  2311. if ! type -p gpg >/dev/null; then
  2312. error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg"
  2313. ret=1
  2314. fi
  2315. fi
  2316.  
  2317. # gpg - source verification
  2318. if (( ! SKIPPGPCHECK )) && source_has_signatures; then
  2319. if ! type -p gpg >/dev/null; then
  2320. error "$(gettext "Cannot find the %s binary required for verifying source files.")" "gpg"
  2321. ret=1
  2322. fi
  2323. fi
  2324.  
  2325. # openssl - checksum operations
  2326. if (( ! SKIPCHECKSUMS )); then
  2327. if ! type -p openssl >/dev/null; then
  2328. error "$(gettext "Cannot find the %s binary required for validating sourcefile checksums.")" "openssl"
  2329. ret=1
  2330. fi
  2331. fi
  2332.  
  2333. # upx - binary compression
  2334. if check_option "upx" "y"; then
  2335. if ! type -p upx >/dev/null; then
  2336. error "$(gettext "Cannot find the %s binary required for compressing binaries.")" "upx"
  2337. ret=1
  2338. fi
  2339. fi
  2340.  
  2341. # distcc - compilation with distcc
  2342. if check_buildenv "distcc" "y" && ! check_option "distcc" "n" ]]; then
  2343. if ! type -p distcc >/dev/null; then
  2344. error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc"
  2345. ret=1
  2346. fi
  2347. fi
  2348.  
  2349. # ccache - compilation with ccache
  2350. if check_buildenv "ccache" "y" && ! check_option "ccache" "n"; then
  2351. if ! type -p ccache >/dev/null; then
  2352. error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache"
  2353. ret=1
  2354. fi
  2355. fi
  2356.  
  2357. # strip - strip symbols from binaries/libraries
  2358. if check_option "strip" "y"; then
  2359. if ! type -p strip >/dev/null; then
  2360. error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip"
  2361. ret=1
  2362. fi
  2363. fi
  2364.  
  2365. # gzip - compressig man and info pages
  2366. if check_option "zipman" "y"; then
  2367. if ! type -p gzip >/dev/null; then
  2368. error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip"
  2369. ret=1
  2370. fi
  2371. fi
  2372.  
  2373. return $ret
  2374. }
  2375.  
  2376. check_build_status() {
  2377. if (( ! SPLITPKG )); then
  2378. fullver=$(get_full_version)
  2379. pkgarch=$(get_pkg_arch)
  2380. if [[ -f $PKGDEST/${pkgname}-${fullver}-${pkgarch}${PKGEXT} ]] \
  2381. && ! (( FORCE || SOURCEONLY || NOBUILD )); then
  2382. if (( INSTALL )); then
  2383. warning "$(gettext "A package has already been built, installing existing package...")"
  2384. install_package
  2385. exit $?
  2386. else
  2387. error "$(gettext "A package has already been built. (use %s to overwrite)")" "-f"
  2388. exit 1
  2389. fi
  2390. fi
  2391. else
  2392. allpkgbuilt=1
  2393. somepkgbuilt=0
  2394. for pkg in ${pkgname[@]}; do
  2395. fullver=$(get_full_version $pkg)
  2396. pkgarch=$(get_pkg_arch $pkg)
  2397. if [[ -f $PKGDEST/${pkg}-${fullver}-${pkgarch}${PKGEXT} ]]; then
  2398. somepkgbuilt=1
  2399. else
  2400. allpkgbuilt=0
  2401. fi
  2402. done
  2403. if ! (( FORCE || SOURCEONLY || NOBUILD )); then
  2404. if (( allpkgbuilt )); then
  2405. if (( INSTALL )); then
  2406. warning "$(gettext "The package group has already been built, installing existing packages...")"
  2407. install_package
  2408. exit $?
  2409. else
  2410. error "$(gettext "The package group has already been built. (use %s to overwrite)")" "-f"
  2411. exit 1
  2412. fi
  2413. fi
  2414. if (( somepkgbuilt && ! PKGVERFUNC )); then
  2415. error "$(gettext "Part of the package group has already been built. (use %s to overwrite)")" "-f"
  2416. exit 1
  2417. fi
  2418. fi
  2419. unset allpkgbuilt somepkgbuilt
  2420. fi
  2421. }
  2422.  
  2423. backup_package_variables() {
  2424. local var
  2425. for var in ${splitpkg_overrides[@]}; do
  2426. local indirect="${var}_backup"
  2427. eval "${indirect}=(\"\${$var[@]}\")"
  2428. done
  2429. }
  2430.  
  2431. restore_package_variables() {
  2432. local var
  2433. for var in ${splitpkg_overrides[@]}; do
  2434. local indirect="${var}_backup"
  2435. if [[ -n ${!indirect} ]]; then
  2436. eval "${var}=(\"\${$indirect[@]}\")"
  2437. else
  2438. unset ${var}
  2439. fi
  2440. done
  2441. }
  2442.  
  2443. run_split_packaging() {
  2444. local pkgname_backup=${pkgname[@]}
  2445. for pkgname in ${pkgname_backup[@]}; do
  2446. pkgdir="$pkgdirbase/$pkgname"
  2447. mkdir "$pkgdir"
  2448. backup_package_variables
  2449. run_package $pkgname
  2450. tidy_install
  2451. create_package
  2452. create_debug_package
  2453. restore_package_variables
  2454. done
  2455. pkgname=${pkgname_backup[@]}
  2456. }
  2457.  
  2458. # Canonicalize a directory path if it exists
  2459. canonicalize_path() {
  2460. local path="$1";
  2461.  
  2462. if [[ -d $path ]]; then
  2463. (
  2464. cd_safe "$path"
  2465. pwd -P
  2466. )
  2467. else
  2468. printf "%s\n" "$path"
  2469. fi
  2470. }
  2471.  
  2472. dir_is_empty() {
  2473. (
  2474. shopt -s dotglob nullglob
  2475. files=("$1"/*)
  2476. (( ${#files} == 0 ))
  2477. )
  2478. }
  2479.  
  2480. # getopt-like parser
  2481. parseopts() {
  2482. local opt= optarg= i= shortopts=$1
  2483. local -a longopts=() unused_argv=()
  2484.  
  2485. shift
  2486. while [[ $1 && $1 != '--' ]]; do
  2487. longopts+=("$1")
  2488. shift
  2489. done
  2490. shift
  2491.  
  2492. longoptmatch() {
  2493. local o longmatch=()
  2494. for o in "${longopts[@]}"; do
  2495. if [[ ${o%:} = "$1" ]]; then
  2496. longmatch=("$o")
  2497. break
  2498. fi
  2499. [[ ${o%:} = "$1"* ]] && longmatch+=("$o")
  2500. done
  2501.  
  2502. case ${#longmatch[*]} in
  2503. 1)
  2504. # success, override with opt and return arg req (0 == none, 1 == required)
  2505. opt=${longmatch%:}
  2506. if [[ $longmatch = *: ]]; then
  2507. return 1
  2508. else
  2509. return 0
  2510. fi ;;
  2511. 0)
  2512. # fail, no match found
  2513. return 255 ;;
  2514. *)
  2515. # fail, ambiguous match
  2516. printf "makepkg: $(gettext "option '%s' is ambiguous; possibilities:")" "--$1"
  2517. printf " '%s'" "${longmatch[@]%:}"
  2518. printf '\n'
  2519. return 254 ;;
  2520. esac >&2
  2521. }
  2522.  
  2523. while (( $# )); do
  2524. case $1 in
  2525. --) # explicit end of options
  2526. shift
  2527. break
  2528. ;;
  2529. -[!-]*) # short option
  2530. for (( i = 1; i < ${#1}; i++ )); do
  2531. opt=${1:i:1}
  2532.  
  2533. # option doesn't exist
  2534. if [[ $shortopts != *$opt* ]]; then
  2535. printf "makepkg: $(gettext "invalid option") -- '%s'\n" "$opt" >&2
  2536. OPTRET=(--)
  2537. return 1
  2538. fi
  2539.  
  2540. OPTRET+=("-$opt")
  2541. # option requires optarg
  2542. if [[ $shortopts = *$opt:* ]]; then
  2543. # if we're not at the end of the option chunk, the rest is the optarg
  2544. if (( i < ${#1} - 1 )); then
  2545. OPTRET+=("${1:i+1}")
  2546. break
  2547. # if we're at the end, grab the the next positional, if it exists
  2548. elif (( i == ${#1} - 1 )) && [[ $2 ]]; then
  2549. OPTRET+=("$2")
  2550. shift
  2551. break
  2552. # parse failure
  2553. else
  2554. printf "makepkg: $(gettext "option requires an argument") -- '%s'\n" "$opt" >&2
  2555. OPTRET=(--)
  2556. return 1
  2557. fi
  2558. fi
  2559. done
  2560. ;;
  2561. --?*=*|--?*) # long option
  2562. IFS='=' read -r opt optarg <<< "${1#--}"
  2563. longoptmatch "$opt"
  2564. case $? in
  2565. 0)
  2566. # parse failure
  2567. if [[ $optarg ]]; then
  2568. printf "makepkg: $(gettext "option '%s' does not allow an argument")\n" "--$opt" >&2
  2569. OPTRET=(--)
  2570. return 1
  2571. # --longopt
  2572. else
  2573. OPTRET+=("--$opt")
  2574. fi
  2575. ;;
  2576. 1)
  2577. # --longopt=optarg
  2578. if [[ $optarg ]]; then
  2579. OPTRET+=("--$opt" "$optarg")
  2580. # --longopt optarg
  2581. elif [[ $2 ]]; then
  2582. OPTRET+=("--$opt" "$2" )
  2583. shift
  2584. # parse failure
  2585. else
  2586. printf "makepkg: $(gettext "option '%s' requires an argument")\n" "--$opt" >&2
  2587. OPTRET=(--)
  2588. return 1
  2589. fi
  2590. ;;
  2591. 254)
  2592. # ambiguous option -- error was reported for us by longoptmatch()
  2593. OPTRET=(--)
  2594. return 1
  2595. ;;
  2596. 255)
  2597. # parse failure
  2598. printf "makepkg: $(gettext "invalid option") '--%s'\n" "$opt" >&2
  2599. OPTRET=(--)
  2600. return 1
  2601. ;;
  2602. esac
  2603. ;;
  2604. *) # non-option arg encountered, add it as a parameter
  2605. unused_argv+=("$1")
  2606. ;;
  2607. esac
  2608. shift
  2609. done
  2610.  
  2611. # add end-of-opt terminator and any leftover positional parameters
  2612. OPTRET+=('--' "${unused_argv[@]}" "$@")
  2613. unset longoptmatch
  2614.  
  2615. return 0
  2616. }
  2617.  
  2618.  
  2619. usage() {
  2620. printf "makepkg (pacman) %s\n" "$makepkg_version"
  2621. echo
  2622. printf -- "$(gettext "Usage: %s [options]")\n" "$0"
  2623. echo
  2624. printf -- "$(gettext "Options:")\n"
  2625. printf -- "$(gettext " -A, --ignorearch Ignore incomplete %s field in %s")\n" "arch" "$BUILDSCRIPT"
  2626. printf -- "$(gettext " -c, --clean Clean up work files after build")\n"
  2627. printf -- "$(gettext " -d, --nodeps Skip all dependency checks")\n"
  2628. printf -- "$(gettext " -e, --noextract Do not extract source files (use existing %s dir)")\n" "src/"
  2629. printf -- "$(gettext " -f, --force Overwrite existing package")\n"
  2630. printf -- "$(gettext " -g, --geninteg Generate integrity checks for source files")\n"
  2631. printf -- "$(gettext " -h, --help Show this help message and exit")\n"
  2632. printf -- "$(gettext " -i, --install Install package after successful build")\n"
  2633. printf -- "$(gettext " -L, --log Log package build process")\n"
  2634. printf -- "$(gettext " -m, --nocolor Disable colorized output messages")\n"
  2635. printf -- "$(gettext " -o, --nobuild Download and extract files only")\n"
  2636. printf -- "$(gettext " -p <file> Use an alternate build script (instead of '%s')")\n" "$BUILDSCRIPT"
  2637. printf -- "$(gettext " -r, --rmdeps Remove installed dependencies after a successful build")\n"
  2638. printf -- "$(gettext " -R, --repackage Repackage contents of the package without rebuilding")\n"
  2639. printf -- "$(gettext " -s, --syncdeps Install missing dependencies with %s")\n" "pacman"
  2640. printf -- "$(gettext " -S, --source Generate a source-only tarball without downloaded sources")\n"
  2641. printf -- "$(gettext " -V, --version Show version information and exit")\n"
  2642. printf -- "$(gettext " --allsource Generate a source-only tarball including downloaded sources")\n"
  2643. printf -- "$(gettext " --verifysource Download source files (if needed) and perform integrity checks")\n"
  2644. printf -- "$(gettext " --asroot Allow %s to run as root user")\n" "makepkg"
  2645. printf -- "$(gettext " --check Run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
  2646. printf -- "$(gettext " --config <file> Use an alternate config file (instead of '%s')")\n" "$confdir/makepkg.conf"
  2647. printf -- "$(gettext " --holdver Do not update VCS sources")\n"
  2648. printf -- "$(gettext " --key <key> Specify a key to use for %s signing instead of the default")\n" "gpg"
  2649. printf -- "$(gettext " --nocheck Do not run the %s function in the %s")\n" "check()" "$BUILDSCRIPT"
  2650. printf -- "$(gettext " --nosign Do not create a signature for the package")\n"
  2651. printf -- "$(gettext " --pkg <list> Only build listed packages from a split package")\n"
  2652. printf -- "$(gettext " --sign Sign the resulting package with %s")\n" "gpg"
  2653. printf -- "$(gettext " --skipchecksums Do not verify checksums of the source files")\n"
  2654. printf -- "$(gettext " --skipinteg Do not perform any verification checks on source files")\n"
  2655. printf -- "$(gettext " --skippgpcheck Do not verify source files with PGP signatures")\n"
  2656. echo
  2657. printf -- "$(gettext "These options can be passed to %s:")\n" "pacman"
  2658. echo
  2659. printf -- "$(gettext " --asdeps Install packages as non-explicitly installed")\n"
  2660. printf -- "$(gettext " --noconfirm Do not ask for confirmation when resolving dependencies")\n"
  2661. printf -- "$(gettext " --needed Do not reinstall the targets that are already up to date")\n"
  2662. printf -- "$(gettext " --noprogressbar Do not show a progress bar when downloading files")\n"
  2663. echo
  2664. printf -- "$(gettext "If %s is not specified, %s will look for '%s'")\n" "-p" "makepkg" "$BUILDSCRIPT"
  2665. echo
  2666. }
  2667.  
  2668. version() {
  2669. printf "makepkg (pacman) %s\n" "$makepkg_version"
  2670. printf -- "$(gettext "\
  2671. Copyright (c) 2006-2013 Pacman Development Team <pacman-dev@archlinux.org>.\n\
  2672. Copyright (C) 2002-2006 Judd Vinet <jvinet@zeroflux.org>.\n\n\
  2673. This is free software; see the source for copying conditions.\n\
  2674. There is NO WARRANTY, to the extent permitted by law.\n")"
  2675. }
  2676.  
  2677. # PROGRAM START
  2678.  
  2679. # determine whether we have gettext; make it a no-op if we do not
  2680. if ! type -p gettext >/dev/null; then
  2681. gettext() {
  2682. printf "%s\n" "$@"
  2683. }
  2684. fi
  2685.  
  2686. ARGLIST=("$@")
  2687.  
  2688. # Parse Command Line Options.
  2689. OPT_SHORT="AcdefFghiLmop:rRsSV"
  2690. OPT_LONG=('allsource' 'asroot' 'check' 'clean' 'config:' 'force' 'geninteg'
  2691. 'help' 'holdver' 'ignorearch' 'install' 'key:' 'log' 'nobuild' 'nocolor'
  2692. 'nocheck' 'nodeps' 'noextract' 'nosign' 'pkg:' 'repackage' 'rmdeps'
  2693. 'sign' 'skipchecksums' 'skipinteg' 'skippgpcheck' 'source' 'syncdeps'
  2694. 'verifysource' 'version')
  2695.  
  2696. # Pacman Options
  2697. OPT_LONG+=('asdeps' 'noconfirm' 'needed' 'noprogressbar')
  2698.  
  2699. if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then
  2700. exit 1 # E_INVALID_OPTION;
  2701. fi
  2702. set -- "${OPTRET[@]}"
  2703. unset OPT_SHORT OPT_LONG OPTRET
  2704.  
  2705. while true; do
  2706. case "$1" in
  2707. # Pacman Options
  2708. --asdeps) ASDEPS=1;;
  2709. --noconfirm) PACMAN_OPTS+=" --noconfirm" ;;
  2710. --needed) NEEDED=1;;
  2711. --noprogressbar) PACMAN_OPTS+=" --noprogressbar" ;;
  2712.  
  2713. # Makepkg Options
  2714. --allsource) SOURCEONLY=2 ;;
  2715. --asroot) ASROOT=1 ;;
  2716. -A|--ignorearch) IGNOREARCH=1 ;;
  2717. -c|--clean) CLEANUP=1 ;;
  2718. --check) RUN_CHECK='y' ;;
  2719. --config) shift; MAKEPKG_CONF=$1 ;;
  2720. -d|--nodeps) NODEPS=1 ;;
  2721. -e|--noextract) NOEXTRACT=1 ;;
  2722. -f|--force) FORCE=1 ;;
  2723. -F) INFAKEROOT=1 ;;
  2724. -g|--geninteg) GENINTEG=1 ;;
  2725. --holdver) HOLDVER=1 ;;
  2726. -i|--install) INSTALL=1 ;;
  2727. --key) shift; GPGKEY=$1 ;;
  2728. -L|--log) LOGGING=1 ;;
  2729. -m|--nocolor) USE_COLOR='n' ;;
  2730. --nocheck) RUN_CHECK='n' ;;
  2731. --nosign) SIGNPKG='n' ;;
  2732. -o|--nobuild) NOBUILD=1 ;;
  2733. -p) shift; BUILDFILE=$1 ;;
  2734. --pkg) shift; IFS=, read -ra p <<<"$1"; PKGLIST+=("${p[@]}"); unset p ;;
  2735. -r|--rmdeps) RMDEPS=1 ;;
  2736. -R|--repackage) REPKG=1 ;;
  2737. --skipchecksums) SKIPCHECKSUMS=1 ;;
  2738. --skipinteg) SKIPCHECKSUMS=1; SKIPPGPCHECK=1 ;;
  2739. --skippgpcheck) SKIPPGPCHECK=1;;
  2740. --sign) SIGNPKG='y' ;;
  2741. -s|--syncdeps) DEP_BIN=1 ;;
  2742. -S|--source) SOURCEONLY=1 ;;
  2743. --verifysource) VERIFYSOURCE=1 ;;
  2744.  
  2745. -h|--help) usage; exit 0 ;; # E_OK
  2746. -V|--version) version; exit 0 ;; # E_OK
  2747.  
  2748. --) OPT_IND=0; shift; break 2;;
  2749. esac
  2750. shift
  2751. done
  2752.  
  2753. # setup signal traps
  2754. trap 'clean_up' 0
  2755. for signal in TERM HUP QUIT; do
  2756. trap "trap_exit $signal \"$(gettext "%s signal caught. Exiting...")\" \"$signal\"" "$signal"
  2757. done
  2758. gettext "%s signal caught. Exiting...")\" \"$signal\""
  2759. gettext "%s signal caught. Exiting...")" "$signal"
  2760. gettext "%s signal caught. Exiting..."
  2761. gettext "%s signal caught. Exiting...")\" \"$signal\""
  2762. gettext "%s signal caught. Exiting...")" "$signal"
  2763. gettext "%s signal caught. Exiting..."
  2764. gettext "%s signal caught. Exiting...")\" \"$signal\""
  2765. gettext "%s signal caught. Exiting...")" "$signal"
  2766. gettext "%s signal caught. Exiting..."
  2767. trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
  2768. trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
  2769.  
  2770. # preserve environment variables and canonicalize path
  2771. [[ -n ${PKGDEST} ]] && _PKGDEST=$(canonicalize_path ${PKGDEST})
  2772. [[ -n ${SRCDEST} ]] && _SRCDEST=$(canonicalize_path ${SRCDEST})
  2773. [[ -n ${SRCPKGDEST} ]] && _SRCPKGDEST=$(canonicalize_path ${SRCPKGDEST})
  2774. [[ -n ${LOGDEST} ]] && _LOGDEST=$(canonicalize_path ${LOGDEST})
  2775. [[ -n ${BUILDDIR} ]] && _BUILDDIR=$(canonicalize_path ${BUILDDIR})
  2776. [[ -n ${PKGEXT} ]] && _PKGEXT=${PKGEXT}
  2777. [[ -n ${SRCEXT} ]] && _SRCEXT=${SRCEXT}
  2778. [[ -n ${GPGKEY} ]] && _GPGKEY=${GPGKEY}
  2779. [[ -n ${PACKAGER} ]] && _PACKAGER=${PACKAGER}
  2780.  
  2781. # default config is makepkg.conf
  2782. MAKEPKG_CONF=${MAKEPKG_CONF:-$confdir/makepkg.conf}
  2783.  
  2784. # Source the config file; fail if it is not found
  2785. if [[ -r $MAKEPKG_CONF ]]; then
  2786. source_safe "$MAKEPKG_CONF"
  2787. else
  2788. error "$(gettext "%s not found.")" "$MAKEPKG_CONF"
  2789. plain "$(gettext "Aborting...")"
  2790. exit 1 # $E_CONFIG_ERROR
  2791. fi
  2792. #
  2793. # /etc/makepkg.conf
  2794. #
  2795.  
  2796. #########################################################################
  2797. # SOURCE ACQUISITION
  2798. #########################################################################
  2799. #
  2800. #-- The download utilities that makepkg should use to acquire sources
  2801. # Format: 'protocol::agent'
  2802. DLAGENTS=('ftp::/usr/bin/curl -fC - --ftp-pasv --retry 3 --retry-delay 3 -o %o %u'
  2803. 'http::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
  2804. 'https::/usr/bin/curl -fLC - --retry 3 --retry-delay 3 -o %o %u'
  2805. 'rsync::/usr/bin/rsync --no-motd -z %u %o'
  2806. 'scp::/usr/bin/scp -C %u %o')
  2807.  
  2808. # Other common tools:
  2809. # /usr/bin/snarf
  2810. # /usr/bin/lftpget -c
  2811. # /usr/bin/wget
  2812.  
  2813. #########################################################################
  2814. # ARCHITECTURE, COMPILE FLAGS
  2815. #########################################################################
  2816. #
  2817. CARCH="x86_64"
  2818. CHOST="x86_64-unknown-linux-gnu"
  2819.  
  2820. #-- Compiler and Linker Flags
  2821. # -march (or -mcpu) builds exclusively for an architecture
  2822. # -mtune optimizes for an architecture, but builds for whole processor family
  2823. CPPFLAGS="-D_FORTIFY_SOURCE=2"
  2824. CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
  2825. CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
  2826. LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
  2827. #-- Make Flags: change this for DistCC/SMP systems
  2828. #MAKEFLAGS="-j2"
  2829. #-- Debugging flags
  2830. DEBUG_CFLAGS="-g -fvar-tracking-assignments"
  2831. DEBUG_CXXFLAGS="-g -fvar-tracking-assignments"
  2832.  
  2833. #########################################################################
  2834. # BUILD ENVIRONMENT
  2835. #########################################################################
  2836. #
  2837. # Defaults: BUILDENV=(fakeroot !distcc color !ccache check !sign)
  2838. # A negated environment option will do the opposite of the comments below.
  2839. #
  2840. #-- fakeroot: Allow building packages as a non-root user
  2841. #-- distcc: Use the Distributed C/C++/ObjC compiler
  2842. #-- color: Colorize output messages
  2843. #-- ccache: Use ccache to cache compilation
  2844. #-- check: Run the check() function if present in the PKGBUILD
  2845. #-- sign: Generate PGP signature file
  2846. #
  2847. BUILDENV=(fakeroot !distcc color !ccache check !sign)
  2848. #
  2849. #-- If using DistCC, your MAKEFLAGS will also need modification. In addition,
  2850. #-- specify a space-delimited list of hosts running in the DistCC cluster.
  2851. #DISTCC_HOSTS=""
  2852. #
  2853. #-- Specify a directory for package building.
  2854. #BUILDDIR=/tmp/makepkg
  2855.  
  2856. #########################################################################
  2857. # GLOBAL PACKAGE OPTIONS
  2858. # These are default values for the options=() settings
  2859. #########################################################################
  2860. #
  2861. # Default: OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx !debug)
  2862. # A negated option will do the opposite of the comments below.
  2863. #
  2864. #-- strip: Strip symbols from binaries/libraries
  2865. #-- docs: Save doc directories specified by DOC_DIRS
  2866. #-- libtool: Leave libtool (.la) files in packages
  2867. #-- staticlibs: Leave static library (.a) files in packages
  2868. #-- emptydirs: Leave empty directories in packages
  2869. #-- zipman: Compress manual (man and info) pages in MAN_DIRS with gzip
  2870. #-- purge: Remove files specified by PURGE_TARGETS
  2871. #-- upx: Compress binary executable files using UPX
  2872. #-- debug: Add debugging flags as specified in DEBUG_* variables
  2873. #
  2874. OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx !debug)
  2875.  
  2876. #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
  2877. INTEGRITY_CHECK=(md5)
  2878. #-- Options to be used when stripping binaries. See `man strip' for details.
  2879. STRIP_BINARIES="--strip-all"
  2880. #-- Options to be used when stripping shared libraries. See `man strip' for details.
  2881. STRIP_SHARED="--strip-unneeded"
  2882. #-- Options to be used when stripping static libraries. See `man strip' for details.
  2883. STRIP_STATIC="--strip-debug"
  2884. #-- Manual (man and info) directories to compress (if zipman is specified)
  2885. MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info})
  2886. #-- Doc directories to remove (if !docs is specified)
  2887. DOC_DIRS=(usr/{,local/}{,share/}{doc,gtk-doc} opt/*/{doc,gtk-doc})
  2888. #-- Files to be removed from all packages (if purge is specified)
  2889. PURGE_TARGETS=(usr/{,share}/info/dir .packlist *.pod)
  2890.  
  2891. #########################################################################
  2892. # PACKAGE OUTPUT
  2893. #########################################################################
  2894. #
  2895. # Default: put built package and cached source in build directory
  2896. #
  2897. #-- Destination: specify a fixed directory where all packages will be placed
  2898. #PKGDEST=/home/packages
  2899. #-- Source cache: specify a fixed directory where source files will be cached
  2900. #SRCDEST=/home/sources
  2901. #-- Source packages: specify a fixed directory where all src packages will be placed
  2902. #SRCPKGDEST=/home/srcpackages
  2903. #-- Log files: specify a fixed directory where all log files will be placed
  2904. #LOGDEST=/home/makepkglogs
  2905. #-- Packager: name/email of the person or organization building packages
  2906. #PACKAGER="John Doe <john@doe.com>"
  2907. #-- Specify a key to use for package signing
  2908. #GPGKEY=""
  2909.  
  2910. #########################################################################
  2911. # COMPRESSION DEFAULTS
  2912. #########################################################################
  2913. #
  2914. COMPRESSGZ=(gzip -c -f -n)
  2915. COMPRESSBZ2=(bzip2 -c -f)
  2916. COMPRESSXZ=(xz -c -z -)
  2917. COMPRESSLRZ=(lrzip -q)
  2918. COMPRESSLZO=(lzop -q)
  2919. COMPRESSZ=(compress -c -f)
  2920.  
  2921. #########################################################################
  2922. # EXTENSION DEFAULTS
  2923. #########################################################################
  2924. #
  2925. # WARNING: Do NOT modify these variables unless you know what you are
  2926. # doing.
  2927. #
  2928. PKGEXT='.pkg.tar.xz'
  2929. SRCEXT='.src.tar.gz'
  2930.  
  2931. # vim: set ft=sh ts=2 sw=2 et:
  2932.  
  2933. # Source user-specific makepkg.conf overrides, but only if no override config
  2934. # file was specified
  2935. if [[ $MAKEPKG_CONF = "$confdir/makepkg.conf" && -r ~/.makepkg.conf ]]; then
  2936. source_safe ~/.makepkg.conf
  2937. fi
  2938.  
  2939. # set pacman command if not already defined
  2940. PACMAN=${PACMAN:-pacman}
  2941. # save full path to command as PATH may change when sourcing /etc/profile
  2942. PACMAN_PATH=$(type -P $PACMAN) || true
  2943. type -P $PACMAN)
  2944. type -P $PACMAN
  2945.  
  2946. # check if messages are to be printed using color
  2947. unset ALL_OFF BOLD BLUE GREEN RED YELLOW
  2948. if [[ -t 2 && ! $USE_COLOR = "n" ]] && check_buildenv "color" "y"; then
  2949. # prefer terminal safe colored and bold text when tput is supported
  2950. if tput setaf 0 &>/dev/null; then
  2951. ALL_OFF="$(tput sgr0)"
  2952. BOLD="$(tput bold)"
  2953. BLUE="${BOLD}$(tput setaf 4)"
  2954. GREEN="${BOLD}$(tput setaf 2)"
  2955. RED="${BOLD}$(tput setaf 1)"
  2956. YELLOW="${BOLD}$(tput setaf 3)"
  2957. else
  2958. ALL_OFF="\e[1;0m"
  2959. BOLD="\e[1;1m"
  2960. BLUE="${BOLD}\e[1;34m"
  2961. GREEN="${BOLD}\e[1;32m"
  2962. RED="${BOLD}\e[1;31m"
  2963. YELLOW="${BOLD}\e[1;33m"
  2964. fi
  2965. fi
  2966. readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
  2967.  
  2968. # override settings with an environment variable for batch processing
  2969. BUILDDIR=${_BUILDDIR:-$BUILDDIR}
  2970. BUILDDIR=${BUILDDIR:-$startdir} #default to $startdir if undefined
  2971. if [[ ! -d $BUILDDIR ]]; then
  2972. if ! mkdir -p "$BUILDDIR"; then
  2973. error "$(gettext "You do not have write permission to create packages in %s.")" "$BUILDDIR"
  2974. plain "$(gettext "Aborting...")"
  2975. exit 1
  2976. fi
  2977. chmod a-s "$BUILDDIR"
  2978. fi
  2979. if [[ ! -w $BUILDDIR ]]; then
  2980. error "$(gettext "You do not have write permission to create packages in %s.")" "$BUILDDIR"
  2981. plain "$(gettext "Aborting...")"
  2982. exit 1
  2983. fi
  2984.  
  2985. PKGDEST=${_PKGDEST:-$PKGDEST}
  2986. PKGDEST=${PKGDEST:-$startdir} #default to $startdir if undefined
  2987. if (( ! (NOBUILD || GENINTEG) )) && [[ ! -w $PKGDEST ]]; then
  2988. error "$(gettext "You do not have write permission to store packages in %s.")" "$PKGDEST"
  2989. plain "$(gettext "Aborting...")"
  2990. exit 1
  2991. fi
  2992.  
  2993. SRCDEST=${_SRCDEST:-$SRCDEST}
  2994. SRCDEST=${SRCDEST:-$startdir} #default to $startdir if undefined
  2995. if [[ ! -w $SRCDEST ]] ; then
  2996. error "$(gettext "You do not have write permission to store downloads in %s.")" "$SRCDEST"
  2997. plain "$(gettext "Aborting...")"
  2998. exit 1
  2999. fi
  3000.  
  3001. SRCPKGDEST=${_SRCPKGDEST:-$SRCPKGDEST}
  3002. SRCPKGDEST=${SRCPKGDEST:-$startdir} #default to $startdir if undefined
  3003. if (( SOURCEONLY )) && [[ ! -w $SRCPKGDEST ]]; then
  3004. error "$(gettext "You do not have write permission to store source tarballs in %s.")" "$SRCPKGDEST"
  3005. plain "$(gettext "Aborting...")"
  3006. exit 1
  3007. fi
  3008.  
  3009. LOGDEST=${_LOGDEST:-$LOGDEST}
  3010. LOGDEST=${LOGDEST:-$startdir} #default to $startdir if undefined
  3011. if (( LOGGING )) && [[ ! -w $LOGDEST ]]; then
  3012. error "$(gettext "You do not have write permission to store logs in %s.")" "$LOGDEST"
  3013. plain "$(gettext "Aborting...")"
  3014. exit 1
  3015. fi
  3016.  
  3017. PKGEXT=${_PKGEXT:-$PKGEXT}
  3018. SRCEXT=${_SRCEXT:-$SRCEXT}
  3019. GPGKEY=${_GPGKEY:-$GPGKEY}
  3020. PACKAGER=${_PACKAGER:-$PACKAGER}
  3021.  
  3022. if (( ! INFAKEROOT )); then
  3023. if (( EUID == 0 && ! ASROOT )); then
  3024. # Warn those who like to live dangerously.
  3025. error "$(gettext "Running %s as root is a BAD idea and can cause permanent,\n\
  3026. catastrophic damage to your system. If you wish to run as root, please\n\
  3027. use the %s option.")" "makepkg" "--asroot"
  3028. exit 1 # $E_USER_ABORT
  3029. elif (( EUID > 0 && ASROOT )); then
  3030. # Warn those who try to use the --asroot option when they are not root
  3031. error "$(gettext "The %s option is meant for the root user only. Please\n\
  3032. rerun %s without the %s flag.")" "--asroot" "makepkg" "--asroot"
  3033. exit 1 # $E_USER_ABORT
  3034. elif (( EUID > 0 )) && ! check_buildenv "fakeroot" "y"; then
  3035. warning "$(gettext "Running %s as an unprivileged user will result in non-root\n\
  3036. ownership of the packaged files. Try using the %s environment by\n\
  3037. placing %s in the %s array in %s.")" "makepkg" "fakeroot" "'fakeroot'" "BUILDENV" "$MAKEPKG_CONF"
  3038. sleep 1
  3039. fi
  3040. else
  3041. if [[ -z $FAKEROOTKEY ]]; then
  3042. error "$(gettext "Do not use the %s option. This option is only for use by %s.")" "'-F'" "makepkg"
  3043. exit 1 # TODO: error code
  3044. fi
  3045. fi
  3046.  
  3047. unset pkgname pkgbase pkgver pkgrel epoch pkgdesc url license groups provides
  3048. unset md5sums replaces depends conflicts backup source install changelog build
  3049. unset makedepends optdepends options noextract
  3050.  
  3051. BUILDFILE=${BUILDFILE:-$BUILDSCRIPT}
  3052. if [[ ! -f $BUILDFILE ]]; then
  3053. if [[ -t 0 ]]; then
  3054. error "$(gettext "%s does not exist.")" "$BUILDFILE"
  3055. exit 1
  3056. else
  3057. # PKGBUILD passed through a pipe
  3058. BUILDFILE=/dev/stdin
  3059. source_safe "$BUILDFILE"
  3060. fi
  3061. else
  3062. crlftest=$(file "$BUILDFILE" | grep -F 'CRLF' || true)
  3063. if [[ -n $crlftest ]]; then
  3064. error "$(gettext "%s contains %s characters and cannot be sourced.")" "$BUILDFILE" "CRLF"
  3065. exit 1
  3066. fi
  3067.  
  3068. if [[ ${BUILDFILE:0:1} != "/" ]]; then
  3069. BUILDFILE="$startdir/$BUILDFILE"
  3070. fi
  3071. source_safe "$BUILDFILE"
  3072. fi
  3073. file "$BUILDFILE" | grep -F 'CRLF' || true)
  3074. file "$BUILDFILE" | grep -F 'CRLF' || true
  3075. # Contributor: tuxce <tuxce.net@gmail.com>
  3076. pkgname=package-query
  3077. pkgver=1.2
  3078. pkgrel=2
  3079. pkgdesc="Query ALPM and AUR"
  3080. arch=('i686' 'x86_64' 'mips64el' 'armv6h' 'armv7h')
  3081. url="http://gitweb.archlinux.fr/package-query.git/"
  3082. license=('GPL')
  3083. depends=('pacman>=4.1' 'pacman<4.2' curl 'yajl>=2.0')
  3084. source=(http://mir.archlinux.fr/~tuxce/releases/$pkgname/$pkgname-$pkgver.tar.gz)
  3085. md5sums=('270f1743e8b78a99cb4cc99057aec091')
  3086.  
  3087. build() {
  3088. cd "$srcdir/$pkgname-$pkgver"
  3089. ./configure --localstatedir=/var --prefix=/usr --sysconfdir=/etc --with-aur-url=https://aur.archlinux.org
  3090. make
  3091. }
  3092.  
  3093. package ()
  3094. {
  3095. cd "$srcdir/$pkgname-$pkgver"
  3096. make DESTDIR="$pkgdir" install
  3097. }
  3098.  
  3099. # vim:set ts=2 sw=2 et:
  3100.  
  3101.  
  3102. # set defaults if they weren't specified in buildfile
  3103. pkgbase=${pkgbase:-${pkgname[0]}}
  3104. epoch=${epoch:-0}
  3105.  
  3106. if [[ $BUILDDIR = "$startdir" ]]; then
  3107. srcdir="$BUILDDIR/src"
  3108. pkgdirbase="$BUILDDIR/pkg"
  3109. else
  3110. srcdir="$BUILDDIR/$pkgbase/src"
  3111. pkgdirbase="$BUILDDIR/$pkgbase/pkg"
  3112.  
  3113. fi
  3114.  
  3115. # set pkgdir to something "sensible" for (not recommended) use during build()
  3116. pkgdir="$pkgdirbase/$pkgbase"
  3117.  
  3118. if (( GENINTEG )); then
  3119. mkdir -p "$srcdir"
  3120. chmod a-s "$srcdir"
  3121. cd_safe "$srcdir"
  3122. download_sources fast
  3123. generate_checksums
  3124. exit 0 # $E_OK
  3125. fi
  3126.  
  3127. if declare -f pkgver >/dev/null; then
  3128. PKGVERFUNC=1
  3129. fi
  3130.  
  3131. # check the PKGBUILD for some basic requirements
  3132. check_sanity || exit 1
  3133. sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
  3134. sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
  3135. sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}"
  3136. i="1.2"
  3137. sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
  3138. sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}")\"
  3139. sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "${i%%+([[:space:]])}"
  3140. i="2"
  3141. awk '/^[[:space:]]*provides=/,/\)/' "$BUILDFILE" | sed -e "s/provides=/provides_list+=/" -e "s/#.*//" -e 's/\\$//')
  3142. awk '/^[[:space:]]*provides=/,/\)/' "$BUILDFILE" | sed -e "s/provides=/provides_list+=/" -e "s/#.*//" -e 's/\\$//'
  3143. awk '/^[[:space:]]*backup=/,/\)/' "$BUILDFILE" | sed -e "s/backup=/backup_list+=/" -e "s/#.*//" -e 's/\\$//')
  3144. awk '/^[[:space:]]*backup=/,/\)/' "$BUILDFILE" | sed -e "s/backup=/backup_list+=/" -e "s/#.*//" -e 's/\\$//'
  3145. awk '/^[[:space:]]*optdepends=\(/,/\)[[:space:]]*(#.*)?$/' "$BUILDFILE" | sed -e "s/optdepends=/optdepends_list+=/" -e "s/#.*//" -e 's/\\$//')
  3146. awk '/^[[:space:]]*optdepends=\(/,/\)[[:space:]]*(#.*)?$/' "$BUILDFILE" | sed -e "s/optdepends=/optdepends_list+=/" -e "s/#.*//" -e 's/\\$//'
  3147. sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE"
  3148. sed -n "s/^[[:space:]]*$i=//p" "$BUILDFILE"
  3149. awk '/^[[:space:]]*options=/,/\)/' "$BUILDFILE" | sed -e "s/options=/options_list+=/" -e "s/#.*//" -e 's/\\$//')
  3150. awk '/^[[:space:]]*options=/,/\)/' "$BUILDFILE" | sed -e "s/options=/options_list+=/" -e "s/#.*//" -e 's/\\$//'
  3151.  
  3152. # check we have the software required to process the PKGBUILD
  3153. check_software || exit 1
  3154.  
  3155. if (( ${#pkgname[@]} > 1 )); then
  3156. SPLITPKG=1
  3157. fi
  3158.  
  3159. # test for available PKGBUILD functions
  3160. if declare -f prepare >/dev/null; then
  3161. PREPAREFUNC=1
  3162. fi
  3163. if declare -f build >/dev/null; then
  3164. BUILDFUNC=1
  3165. fi
  3166. if declare -f check >/dev/null; then
  3167. # "Hide" check() function if not going to be run
  3168. if [[ $RUN_CHECK = 'y' ]] || { ! check_buildenv "check" "n" && [[ $RUN_CHECK != "n" ]]; }; then
  3169. CHECKFUNC=1
  3170. fi
  3171. fi
  3172. if declare -f package >/dev/null; then
  3173. PKGFUNC=1
  3174. elif [[ $SPLITPKG -eq 0 ]] && declare -f package_${pkgname} >/dev/null; then
  3175. SPLITPKG=1
  3176. fi
  3177.  
  3178. if [[ -n "${PKGLIST[@]}" ]]; then
  3179. unset pkgname
  3180. pkgname=("${PKGLIST[@]}")
  3181. fi
  3182.  
  3183. # check if gpg signature is to be created and if signing key is valid
  3184. if { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; } || [[ $SIGNPKG == 'y' ]]; then
  3185. SIGNPKG='y'
  3186. if ! gpg --list-key ${GPGKEY} &>/dev/null; then
  3187. if [[ ! -z $GPGKEY ]]; then
  3188. error "$(gettext "The key %s does not exist in your keyring.")" "${GPGKEY}"
  3189. else
  3190. error "$(gettext "There is no key in your keyring.")"
  3191. fi
  3192. exit 1
  3193. fi
  3194. fi
  3195.  
  3196. if (( ! PKGVERFUNC )); then
  3197. check_build_status
  3198. fi
  3199. get_full_version)
  3200. get_full_version
  3201. get_pkg_arch)
  3202. get_pkg_arch
  3203.  
  3204. # Run the bare minimum in fakeroot
  3205. if (( INFAKEROOT )); then
  3206. if (( SOURCEONLY )); then
  3207. create_srcpackage
  3208. msg "$(gettext "Leaving %s environment.")" "fakeroot"
  3209. exit 0 # $E_OK
  3210. fi
  3211.  
  3212. chmod 755 "$pkgdirbase"
  3213. if (( ! SPLITPKG )); then
  3214. pkgdir="$pkgdirbase/$pkgname"
  3215. mkdir "$pkgdir"
  3216. if (( ! PKGFUNC )); then
  3217. if (( ! REPKG )); then
  3218. if (( BUILDFUNC )); then
  3219. run_build
  3220. (( CHECKFUNC )) && run_check
  3221. fi
  3222. else
  3223. warning "$(gettext "Repackaging without the use of a %s function is deprecated.")" "package()"
  3224. plain "$(gettext "File permissions may not be preserved.")"
  3225. fi
  3226. else
  3227. run_package
  3228. fi
  3229. tidy_install
  3230. create_package
  3231. create_debug_package
  3232. else
  3233. run_split_packaging
  3234. fi
  3235.  
  3236. msg "$(gettext "Leaving %s environment.")" "fakeroot"
  3237. exit 0 # $E_OK
  3238. fi
  3239.  
  3240. fullver=$(get_full_version)
  3241. get_full_version)
  3242. get_full_version
  3243. msg "$(gettext "Making package: %s")" "$pkgbase $fullver ($(date))"
  3244. gettext "Making package: %s")"
  3245. gettext "Making package: %s")
  3246. gettext "Making package: %s"
  3247. date))"
  3248. date))
  3249. date
  3250. ==> Making package: package-query 1.2-2 (Sat Jan 18 09:41:41 CET 2014)
  3251.  
  3252. if (( !PKGFUNC && !SPLITPKG )); then
  3253. warning "$(gettext "Using a %s without a %s function is deprecated.")" "$BUILDSCRIPT" "package()"
  3254. fi
  3255.  
  3256. # if we are creating a source-only package, go no further
  3257. if (( SOURCEONLY )); then
  3258. if [[ -f $SRCPKGDEST/${pkgbase}-${fullver}${SRCEXT} ]] \
  3259. && (( ! FORCE )); then
  3260. error "$(gettext "A source package has already been built. (use %s to overwrite)")" "-f"
  3261. exit 1
  3262. fi
  3263.  
  3264. # Get back to our src directory so we can begin with sources.
  3265. mkdir -p "$srcdir"
  3266. chmod a-s "$srcdir"
  3267. cd_safe "$srcdir"
  3268. if (( SOURCEONLY == 2 )); then
  3269. download_sources
  3270. elif ( (( ! SKIPCHECKSUMS )) || \
  3271. ( (( ! SKIPPGPCHECK )) && source_has_signatures ) ); then
  3272. download_sources fast
  3273. fi
  3274. check_source_integrity
  3275. cd_safe "$startdir"
  3276.  
  3277. # if we are root or if fakeroot is not enabled, then we don't use it
  3278. if ! check_buildenv "fakeroot" "y" || (( EUID == 0 )); then
  3279. create_srcpackage
  3280. else
  3281. enter_fakeroot
  3282. fi
  3283.  
  3284. msg "$(gettext "Source package created: %s")" "$pkgbase ($(date))"
  3285. exit 0
  3286. fi
  3287.  
  3288. if (( NODEPS || (NOBUILD && !DEP_BIN ) )); then
  3289. # no warning message needed for nobuild
  3290. if (( NODEPS )); then
  3291. warning "$(gettext "Skipping dependency checks.")"
  3292. fi
  3293. else
  3294. if (( RMDEPS && ! INSTALL )); then
  3295. original_pkglist=($(run_pacman -Qq)) # required by remove_dep
  3296. fi
  3297. deperr=0
  3298.  
  3299. msg "$(gettext "Checking runtime dependencies...")"
  3300. resolve_deps ${depends[@]} || deperr=1
  3301.  
  3302. if (( RMDEPS && INSTALL )); then
  3303. original_pkglist=($(run_pacman -Qq)) # required by remove_dep
  3304. fi
  3305.  
  3306. msg "$(gettext "Checking buildtime dependencies...")"
  3307. resolve_deps ${makedepends[@]} || deperr=1
  3308.  
  3309. if (( CHECKFUNC )); then
  3310. resolve_deps ${checkdepends[@]} || deperr=1
  3311. fi
  3312.  
  3313. if (( RMDEPS )); then
  3314. current_pkglist=($(run_pacman -Qq)) # required by remove_deps
  3315. fi
  3316.  
  3317. if (( deperr )); then
  3318. error "$(gettext "Could not resolve all dependencies.")"
  3319. exit 1
  3320. fi
  3321. fi
  3322. gettext "Checking runtime dependencies...")"
  3323. gettext "Checking runtime dependencies...")
  3324. gettext "Checking runtime dependencies..."
  3325. ==> Checking runtime dependencies...
  3326. set +E; check_deps $*)"
  3327. set +E; check_deps $*)
  3328. set +E; check_deps $*
  3329. run_pacman -T "$@")
  3330. run_pacman -T "$@"
  3331. gettext "Checking buildtime dependencies...")"
  3332. gettext "Checking buildtime dependencies...")
  3333. gettext "Checking buildtime dependencies..."
  3334. ==> Checking buildtime dependencies...
  3335. set +E; check_deps $*)"
  3336. set +E; check_deps $*)
  3337. set +E; check_deps $*
  3338.  
  3339. # ensure we have a sane umask set
  3340. umask 0022
  3341.  
  3342. # get back to our src directory so we can begin with sources
  3343. mkdir -p "$srcdir"
  3344. chmod a-s "$srcdir"
  3345. cd_safe "$srcdir"
  3346.  
  3347. if (( NOEXTRACT && ! VERIFYSOURCE )); then
  3348. warning "$(gettext "Using existing %s tree")" "src/"
  3349. elif (( REPKG )); then
  3350. if (( ! PKGFUNC && ! SPLITPKG )) \
  3351. && { [[ ! -d $pkgdirbase ]] || dir_is_empty "$pkgdirbase"; }; then
  3352. error "$(gettext "The package directory is empty, there is nothing to repackage!")"
  3353. plain "$(gettext "Aborting...")"
  3354. exit 1
  3355. fi
  3356. else
  3357. download_sources
  3358. check_source_integrity
  3359. (( VERIFYSOURCE )) && exit 0 # $E_OK
  3360. extract_sources
  3361. if (( PREPAREFUNC )); then
  3362. run_prepare
  3363. fi
  3364. fi
  3365. gettext "Retrieving sources...")"
  3366. gettext "Retrieving sources...")
  3367. gettext "Retrieving sources..."
  3368. ==> Retrieving sources...
  3369. get_protocol "$netfile")
  3370. get_protocol "$netfile"
  3371. get_filepath "$netfile")
  3372. get_filepath "$netfile"
  3373. get_filename "$1")"
  3374. get_filename "$1")
  3375. get_filename "$1"
  3376. get_protocol "$netfile")
  3377. get_protocol "$netfile"
  3378. get_protocol "$1")"
  3379. get_protocol "$1")
  3380. get_protocol "$1"
  3381. gettext "Found %s")"
  3382. gettext "Found %s")
  3383. gettext "Found %s"
  3384. -> Found package-query-1.2.tar.gz
  3385. eval echo "\${${integ}sums[@]}")
  3386. eval echo "\${${integ}sums[@]}")
  3387. eval echo "\${${integ}sums[@]}"
  3388. echo ${md5sums[@]}
  3389. gettext "Validating source files with %s...")"
  3390. gettext "Validating source files with %s...")
  3391. gettext "Validating source files with %s..."
  3392. ==> Validating source files with md5sums...
  3393. get_filename "$file")"
  3394. get_filename "$file")
  3395. get_filename "$file"
  3396. get_protocol "$netfile")
  3397. get_protocol "$netfile"
  3398. package-query-1.2.tar.gz ... get_filepath "$file")"
  3399. get_filepath "$file")
  3400. get_filepath "$file"
  3401. get_filename "$1")"
  3402. get_filename "$1")
  3403. get_filename "$1"
  3404. get_protocol "$netfile")
  3405. get_protocol "$netfile"
  3406. get_protocol "$1")"
  3407. get_protocol "$1")
  3408. get_protocol "$1"
  3409. openssl dgst -${integ} "$file")"
  3410. openssl dgst -${integ} "$file")
  3411. openssl dgst -${integ} "$file"
  3412. gettext "Passed")\n"
  3413. gettext "Passed")\n
  3414. gettext "Passed"
  3415. Passed
  3416. eval echo "\${${integ}sums[@]}")
  3417. eval echo "\${${integ}sums[@]}")
  3418. eval echo "\${${integ}sums[@]}"
  3419. echo ${sha1sums[@]}
  3420. eval echo "\${${integ}sums[@]}")
  3421. eval echo "\${${integ}sums[@]}")
  3422. eval echo "\${${integ}sums[@]}"
  3423. echo ${sha256sums[@]}
  3424. eval echo "\${${integ}sums[@]}")
  3425. eval echo "\${${integ}sums[@]}")
  3426. eval echo "\${${integ}sums[@]}"
  3427. echo ${sha384sums[@]}
  3428. eval echo "\${${integ}sums[@]}")
  3429. eval echo "\${${integ}sums[@]}")
  3430. eval echo "\${${integ}sums[@]}"
  3431. echo ${sha512sums[@]}
  3432. gettext "Extracting sources...")"
  3433. gettext "Extracting sources...")
  3434. gettext "Extracting sources..."
  3435. ==> Extracting sources...
  3436. get_filename "$netfile")
  3437. get_filename "$netfile"
  3438. get_protocol "$netfile")
  3439. get_protocol "$netfile"
  3440. get_protocol "$netfile")
  3441. get_protocol "$netfile"
  3442. file -bizL "$file")
  3443. file -bizL "$file"
  3444. gettext "Extracting %s with %s")"
  3445. gettext "Extracting %s with %s")
  3446. gettext "Extracting %s with %s"
  3447. -> Extracting package-query-1.2.tar.gz with bsdtar
  3448.  
  3449. if (( NOBUILD )); then
  3450. msg "$(gettext "Sources are ready.")"
  3451. exit 0 #E_OK
  3452. else
  3453. # check for existing pkg directory; don't remove if we are repackaging
  3454. if [[ -d $pkgdirbase ]] && (( ! REPKG || PKGFUNC || SPLITPKG )); then
  3455. msg "$(gettext "Removing existing %s directory...")" "pkg/"
  3456. rm -rf "$pkgdirbase"
  3457. fi
  3458. mkdir -p "$pkgdirbase"
  3459. chmod a-srwx "$pkgdirbase"
  3460. cd_safe "$startdir"
  3461.  
  3462. # if we are root or if fakeroot is not enabled, then we don't use it
  3463. if ! check_buildenv "fakeroot" "y" || (( EUID == 0 )); then
  3464. if (( ! REPKG )); then
  3465. if (( ! ( SPLITPKG || PKGFUNC ) )); then
  3466. chmod 755 "$pkgdirbase"
  3467. mkdir -p "$pkgdir"
  3468. fi
  3469. (( BUILDFUNC )) && run_build
  3470. (( CHECKFUNC )) && run_check
  3471. fi
  3472. chmod 755 "$pkgdirbase"
  3473. if (( ! SPLITPKG )); then
  3474. pkgdir="$pkgdirbase/$pkgname"
  3475. mkdir -p "$pkgdir"
  3476. if (( PKGFUNC )); then
  3477. run_package
  3478. elif (( REPKG )); then
  3479. warning "$(gettext "Repackaging without the use of a %s function is deprecated.")" "package()"
  3480. plain "$(gettext "File permissions may not be preserved.")"
  3481. fi
  3482. tidy_install
  3483. create_package
  3484. create_debug_package
  3485. else
  3486. run_split_packaging
  3487. fi
  3488. else
  3489. if (( ! REPKG && ( PKGFUNC || SPLITPKG ) )); then
  3490. (( BUILDFUNC )) && run_build
  3491. (( CHECKFUNC )) && run_check
  3492. cd_safe "$startdir"
  3493. fi
  3494.  
  3495. enter_fakeroot
  3496. fi
  3497. fi
  3498. trap -p ERR)
  3499. trap -p ERR
  3500. gettext "Starting %s()...")"
  3501. gettext "Starting %s()...")
  3502. gettext "Starting %s()..."
  3503. ==> Starting build()...
  3504. shopt -p)
  3505. shopt -p
  3506. checking for a BSD-compatible install... /usr/bin/install -c
  3507. checking whether build environment is sane... yes
  3508. /home/watnuss/downloads/package-query/src/package-query-1.2/missing: Unknown `--is-lightweight' option
  3509. Try `/home/watnuss/downloads/package-query/src/package-query-1.2/missing --help' for more information
  3510. configure: WARNING: 'missing' script is too old or missing
  3511. checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
  3512. checking for gawk... gawk
  3513. checking whether make sets $(MAKE)... yes
  3514. checking whether make supports nested variables... yes
  3515. checking for gcc... gcc
  3516. checking whether the C compiler works... yes
  3517. checking for C compiler default output file name... a.out
  3518. checking for suffix of executables...
  3519. checking whether we are cross compiling... no
  3520. checking for suffix of object files... o
  3521. checking whether we are using the GNU C compiler... yes
  3522. checking whether gcc accepts -g... yes
  3523. checking for gcc option to accept ISO C89... none needed
  3524. checking for style of include used by make... GNU
  3525. checking dependency style of gcc... gcc3
  3526. checking build system type... x86_64-unknown-linux-gnu
  3527. checking host system type... x86_64-unknown-linux-gnu
  3528. checking how to print strings... printf
  3529. checking for a sed that does not truncate output... /usr/bin/sed
  3530. checking for grep that handles long lines and -e... /usr/bin/grep
  3531. checking for egrep... /usr/bin/grep -E
  3532. checking for fgrep... /usr/bin/grep -F
  3533. checking for ld used by gcc... /usr/bin/ld
  3534. checking if the linker (/usr/bin/ld) is GNU ld... yes
  3535. checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
  3536. checking the name lister (/usr/bin/nm -B) interface... BSD nm
  3537. checking whether ln -s works... yes
  3538. checking the maximum length of command line arguments... 1572864
  3539. checking whether the shell understands some XSI constructs... yes
  3540. checking whether the shell understands "+="... yes
  3541. checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
  3542. checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
  3543. checking for /usr/bin/ld option to reload object files... -r
  3544. checking for objdump... objdump
  3545. checking how to recognize dependent libraries... pass_all
  3546. checking for dlltool... no
  3547. checking how to associate runtime and link libraries... printf %s\n
  3548. checking for ar... ar
  3549. checking for archiver @FILE support... @
  3550. checking for strip... strip
  3551. checking for ranlib... ranlib
  3552. checking command to parse /usr/bin/nm -B output from gcc object... ok
  3553. checking for sysroot... no
  3554. checking for mt... no
  3555. checking if : is a manifest tool... no
  3556. checking how to run the C preprocessor... gcc -E
  3557. checking for ANSI C header files... yes
  3558. checking for sys/types.h... yes
  3559. checking for sys/stat.h... yes
  3560. checking for stdlib.h... yes
  3561. checking for string.h... yes
  3562. checking for memory.h... yes
  3563. checking for strings.h... yes
  3564. checking for inttypes.h... yes
  3565. checking for stdint.h... yes
  3566. checking for unistd.h... yes
  3567. checking for dlfcn.h... yes
  3568. checking for objdir... .libs
  3569. checking if gcc supports -fno-rtti -fno-exceptions... no
  3570. checking for gcc option to produce PIC... -fPIC -DPIC
  3571. checking if gcc PIC flag -fPIC -DPIC works... yes
  3572. checking if gcc static flag -static works... yes
  3573. checking if gcc supports -c -o file.o... yes
  3574. checking if gcc supports -c -o file.o... (cached) yes
  3575. checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
  3576. checking whether -lc should be explicitly linked in... no
  3577. checking dynamic linker characteristics... GNU/Linux ld.so
  3578. checking how to hardcode library paths into programs... immediate
  3579. checking whether stripping libraries is possible... yes
  3580. checking if libtool supports shared libraries... yes
  3581. checking whether to build shared libraries... yes
  3582. checking whether to build static libraries... yes
  3583. checking ctype.h usability... yes
  3584. checking ctype.h presence... yes
  3585. checking for ctype.h... yes
  3586. checking getopt.h usability... yes
  3587. checking getopt.h presence... yes
  3588. checking for getopt.h... yes
  3589. checking libintl.h usability... yes
  3590. checking libintl.h presence... yes
  3591. checking for libintl.h... yes
  3592. checking limits.h usability... yes
  3593. checking limits.h presence... yes
  3594. checking for limits.h... yes
  3595. checking locale.h usability... yes
  3596. checking locale.h presence... yes
  3597. checking for locale.h... yes
  3598. checking sys/ioctl.h usability... yes
  3599. checking sys/ioctl.h presence... yes
  3600. checking for sys/ioctl.h... yes
  3601. checking sys/utsname.h usability... yes
  3602. checking sys/utsname.h presence... yes
  3603. checking for sys/utsname.h... yes
  3604. checking for alpm_version in -lalpm... yes
  3605. checking for yajl_free in -lyajl... yes
  3606. checking for gawk... (cached) gawk
  3607. checking for curl-config... /usr/bin/curl-config
  3608. checking for the version of libcurl... 7.34.0
  3609. checking for libcurl >= version 7.19.4... yes
  3610. checking whether libcurl is usable... yes
  3611. checking for curl_free... yes
  3612. checking whether NLS is requested... yes
  3613. checking for msgfmt... /usr/bin/msgfmt
  3614. checking for gmsgfmt... /usr/bin/msgfmt
  3615. checking for xgettext... /usr/bin/xgettext
  3616. checking for msgmerge... /usr/bin/msgmerge
  3617. checking for ld used by GCC... /usr/bin/ld -m elf_x86_64
  3618. checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
  3619. checking for shared library run path origin... done
  3620. checking for CFPreferencesCopyAppValue... no
  3621. checking for CFLocaleCopyCurrent... no
  3622. checking for GNU gettext in libc... yes
  3623. checking whether to use NLS... yes
  3624. checking where the gettext function comes from... libc
  3625. checking for git... git
  3626. checking for .git/... no
  3627. checking that generated files are newer than configure... done
  3628. configure: creating ./config.status
  3629. config.status: creating src/Makefile
  3630. config.status: creating doc/Makefile
  3631. config.status: creating Makefile
  3632. config.status: creating config.h
  3633. config.status: executing depfiles commands
  3634. config.status: executing libtool commands
  3635. config.status: executing po-directories commands
  3636.  
  3637. package-query:
  3638.  
  3639. Build information:
  3640. source code location : .
  3641. prefix : /usr
  3642. sysconfdir : /etc
  3643. conf file : /etc/pacman.conf
  3644. localstatedir : /var
  3645. database dir : /var/lib/pacman/
  3646. compiler : gcc
  3647. compiler flags : -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4
  3648.  
  3649. package-query version : 1.2
  3650. using git version : no
  3651. git ver :
  3652.  
  3653. Variable information:
  3654. root working directory : /
  3655. aur base url : https://aur.archlinux.org
  3656.  
  3657. make all-recursive
  3658. make[1]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2'
  3659. Making all in src
  3660. make[2]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2/src'
  3661. gcc -DLOCALEDIR=\"/usr/share/locale\" -DCONFFILE=\"/etc/pacman.conf\" -DROOTDIR=\"/\" -DDBPATH=\"/var/lib/pacman/\" -DAUR_BASE_URL=\"https://aur.archlinux.org\" -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -MT aur.o -MD -MP -MF .deps/aur.Tpo -c -o aur.o aur.c
  3662. mv -f .deps/aur.Tpo .deps/aur.Po
  3663. gcc -DLOCALEDIR=\"/usr/share/locale\" -DCONFFILE=\"/etc/pacman.conf\" -DROOTDIR=\"/\" -DDBPATH=\"/var/lib/pacman/\" -DAUR_BASE_URL=\"https://aur.archlinux.org\" -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -MT alpm-query.o -MD -MP -MF .deps/alpm-query.Tpo -c -o alpm-query.o alpm-query.c
  3664. alpm-query.c: In function ‘alpm_pkg_get_realsize’:
  3665. alpm-query.c:486:9: warning: ignoring return value of ‘chdir’, declared with attribute warn_unused_result [-Wunused-result]
  3666. chdir (alpm_option_get_root(config.handle));
  3667. ^
  3668. mv -f .deps/alpm-query.Tpo .deps/alpm-query.Po
  3669. gcc -DLOCALEDIR=\"/usr/share/locale\" -DCONFFILE=\"/etc/pacman.conf\" -DROOTDIR=\"/\" -DDBPATH=\"/var/lib/pacman/\" -DAUR_BASE_URL=\"https://aur.archlinux.org\" -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -MT util.o -MD -MP -MF .deps/util.Tpo -c -o util.o util.c
  3670. util.c: In function ‘string_fcat’:
  3671. util.c:342:11: warning: ignoring return value of ‘vasprintf’, declared with attribute warn_unused_result [-Wunused-result]
  3672. vasprintf(&s, format, args);
  3673. ^
  3674. util.c: In function ‘concat_backup_list’:
  3675. util.c:480:12: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
  3676. asprintf (&b_str, "%s\t%s", backup->name, backup->hash);
  3677. ^
  3678. util.c: In function ‘itostr’:
  3679. util.c:525:11: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
  3680. asprintf (&is, "%d", i);
  3681. ^
  3682. util.c: In function ‘ltostr’:
  3683. util.c:532:11: warning: ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]
  3684. asprintf (&is, "%ld", i);
  3685. ^
  3686. mv -f .deps/util.Tpo .deps/util.Po
  3687. gcc -DLOCALEDIR=\"/usr/share/locale\" -DCONFFILE=\"/etc/pacman.conf\" -DROOTDIR=\"/\" -DDBPATH=\"/var/lib/pacman/\" -DAUR_BASE_URL=\"https://aur.archlinux.org\" -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -MT color.o -MD -MP -MF .deps/color.Tpo -c -o color.o color.c
  3688. mv -f .deps/color.Tpo .deps/color.Po
  3689. gcc -DLOCALEDIR=\"/usr/share/locale\" -DCONFFILE=\"/etc/pacman.conf\" -DROOTDIR=\"/\" -DDBPATH=\"/var/lib/pacman/\" -DAUR_BASE_URL=\"https://aur.archlinux.org\" -DHAVE_CONFIG_H -I. -I.. -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -MT package-query.o -MD -MP -MF .deps/package-query.Tpo -c -o package-query.o package-query.c
  3690. mv -f .deps/package-query.Tpo .deps/package-query.Po
  3691. /bin/sh ../libtool --tag=CC --mode=link gcc -D_GNU_SOURCE -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -lcurl -Wl,-O1,--sort-common,--as-needed,-z,relro -o package-query aur.o alpm-query.o util.o color.o package-query.o -lyajl -lalpm
  3692. libtool: link: gcc -D_GNU_SOURCE -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z -Wl,relro -o package-query aur.o alpm-query.o util.o color.o package-query.o -lcurl -lyajl -lalpm
  3693. make[2]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2/src'
  3694. Making all in doc
  3695. make[2]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2/doc'
  3696. make[2]: Nothing to be done for 'all'.
  3697. make[2]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2/doc'
  3698. make[2]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2'
  3699. make[2]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2'
  3700. make[1]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2'
  3701. shopt -u autocd
  3702. shopt -u cdable_vars
  3703. shopt -u cdspell
  3704. shopt -u checkhash
  3705. shopt -u checkjobs
  3706. shopt -u checkwinsize
  3707. shopt -s cmdhist
  3708. shopt -u compat31
  3709. shopt -u compat32
  3710. shopt -u compat40
  3711. shopt -u compat41
  3712. shopt -u direxpand
  3713. shopt -u dirspell
  3714. shopt -u dotglob
  3715. shopt -u execfail
  3716. shopt -u expand_aliases
  3717. shopt -u extdebug
  3718. shopt -s extglob
  3719. shopt -s extquote
  3720. shopt -u failglob
  3721. shopt -s force_fignore
  3722. shopt -u globstar
  3723. shopt -u gnu_errfmt
  3724. shopt -u histappend
  3725. shopt -u histreedit
  3726. shopt -u histverify
  3727. shopt -s hostcomplete
  3728. shopt -u huponexit
  3729. shopt -s interactive_comments
  3730. shopt -u lastpipe
  3731. shopt -u lithist
  3732. shopt -u login_shell
  3733. shopt -u mailwarn
  3734. shopt -u no_empty_cmd_completion
  3735. shopt -u nocaseglob
  3736. shopt -u nocasematch
  3737. shopt -u nullglob
  3738. shopt -s progcomp
  3739. shopt -s promptvars
  3740. shopt -u restricted_shell
  3741. shopt -u shift_verbose
  3742. shopt -s sourcepath
  3743. shopt -u xpg_echo
  3744. gettext "Entering %s environment...")"
  3745. gettext "Entering %s environment...")
  3746. gettext "Entering %s environment..."
  3747. ==> Entering fakeroot environment...
  3748. ==> Starting package()...
  3749. Making install in src
  3750. make[1]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2/src'
  3751. make[2]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2/src'
  3752. /usr/bin/mkdir -p '/home/watnuss/downloads/package-query/pkg/package-query/usr/bin'
  3753. /bin/sh ../libtool --mode=install /usr/bin/install -c package-query '/home/watnuss/downloads/package-query/pkg/package-query/usr/bin'
  3754. libtool: install: /usr/bin/install -c package-query /home/watnuss/downloads/package-query/pkg/package-query/usr/bin/package-query
  3755. make[2]: Nothing to be done for 'install-data-am'.
  3756. make[2]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2/src'
  3757. make[1]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2/src'
  3758. Making install in doc
  3759. make[1]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2/doc'
  3760. make[2]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2/doc'
  3761. make[2]: Nothing to be done for 'install-exec-am'.
  3762. /usr/bin/mkdir -p '/home/watnuss/downloads/package-query/pkg/package-query/usr/share/man/man8'
  3763. /usr/bin/install -c -m 644 package-query.8 '/home/watnuss/downloads/package-query/pkg/package-query/usr/share/man/man8'
  3764. make[2]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2/doc'
  3765. make[1]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2/doc'
  3766. make[1]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2'
  3767. make[2]: Entering directory '/home/watnuss/downloads/package-query/src/package-query-1.2'
  3768. make[2]: Nothing to be done for 'install-exec-am'.
  3769. make[2]: Nothing to be done for 'install-data-am'.
  3770. make[2]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2'
  3771. make[1]: Leaving directory '/home/watnuss/downloads/package-query/src/package-query-1.2'
  3772. ==> Tidying install...
  3773. -> Purging unwanted files...
  3774. -> Removing libtool files...
  3775. -> Removing static library files...
  3776. -> Compressing man and info pages...
  3777. -> Stripping unneeded symbols from binaries and libraries...
  3778. ==> Creating package "package-query"...
  3779. /usr/bin/fakeroot: line 181: 11315 Segmentation fault (core dumped) FAKEROOTKEY=$FAKEROOTKEY LD_LIBRARY_PATH="$PATHS" LD_PRELOAD="$LIB" "$@"
  3780. clean_up
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement