Merge pull request #1008 from AladW/fetch-rework-iv
[aurutils.git] / lib / aur-build--pkglist
blob23f4e8c59bf39517af8b7187792b0c8bc605b69c
1 #!/bin/bash
2 set -o errexit
3 [[ -v AUR_DEBUG ]] && set -o xtrace
4 argv0=build--pkglist
5 PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
7 # default options
8 lint=0 mode=pkglist
10 usage() {
11 printf >&2 'usage: %s [--srcinfo] [--lint] [--config <file>]' "$argv0"
12 exit 1
15 # mollyguard for sourcing PKGBUILDs
16 if [[ $UID == 0 ]] && ! [[ -v AUR_ASROOT ]]; then
17 printf >&2 'aur-%s is not meant to be run as root.\n' "$argv0"
18 printf >&2 'To proceed anyway, set the %s variable.\n' 'AUR_ASROOT'
19 exit 1
22 source /usr/share/makepkg/util/option.sh
23 source /usr/share/makepkg/util/parseopts.sh
24 source /usr/share/makepkg/util/config.sh
26 # option parsing
27 opt_short='p:'
28 opt_long=('buildscript:' 'config:' 'lint' 'srcinfo' 'full')
29 opt_hidden=('dump-options')
31 if ! parseopts "$opt_short" "${opt_long[@]}" "${opt_hidden[@]}" -- "$@"; then
32 usage
34 set -- "${OPTRET[@]}"
36 unset buildscript makepkg_conf
37 while true; do
38 case "$1" in
39 -p|--buildscript)
40 shift; buildscript=$1 ;;
41 --config)
42 shift; makepkg_conf=$1 ;;
43 --full)
44 mode=pkglist_full ;;
45 --srcinfo)
46 mode=srcinfo ;;
47 --lint)
48 lint=1 ;;
49 --dump-options)
50 printf -- '--%s\n' "${opt_long[@]}" ${AUR_DEBUG+"${opt_hidden[@]}"}
51 printf -- '%s' "${opt_short}" | sed 's/.:\?/-&\n/g'
52 exit ;;
53 --) shift; break ;;
54 esac
55 shift
56 done
58 # shellcheck disable=SC1090
59 source "${buildscript-PKGBUILD}"
60 pkgbase=${pkgbase:-$pkgname}
61 PKGDEST=${PKGDEST:-$PWD}
63 # PKGEXT (packagelist), CARCH (lint)
64 load_makepkg_config "${makepkg_conf-}"
66 if (( lint )); then
67 source /usr/share/makepkg/lint_pkgbuild.sh
68 lint_pkgbuild
71 case $mode in
72 pkglist)
73 source /usr/share/makepkg/util/pkgbuild.sh
74 print_all_package_names
76 pkglist_full)
77 source /usr/share/makepkg/util/pkgbuild.sh
78 print_all_package_names | while IFS= read -r; do
79 printf '%s:%s\n' "$pkgbase" "$REPLY"
80 done ;;
81 srcinfo)
82 source /usr/share/makepkg/srcinfo.sh
83 write_srcinfo_content
85 esac