-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
mpbb-list-subports
88 lines (72 loc) · 2.77 KB
/
mpbb-list-subports
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# -*- coding: utf-8; mode: sh; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=sh:et:sw=4:ts=4:sts=4
# Note:
# This script is sourced by the mpbb wrapper script.
# Do not execute this directly!
list-subports-usage() {
# "prog" is defined in mpbb-help.
# shellcheck disable=SC2154
cat <<EOF
usage: $prog [<global opts>] list-subports [<opts>] <port> [<port2> [...]]
Print the name and subports of each given port to standard output.
Options:
--archive-site=<URL>
URL to check for preexisting public archives. Defaults to
\`https://packages.macports.org'.
--archive-site-private=<URL>
URL to check for preexisting private archives. Defaults to
\`https://packages-private.macports.org'.
Run \`$prog help' for global options and a list of other subcommands.
EOF
}
print-subports() {
local archive_site_public=$1
local archive_site_private=$2
local include_deps=$3
local portnames=$4
# $option_prefix is set in mpbb
# shellcheck disable=SC2154
tclsh=$(readlink "${option_prefix}/bin/port-tclsh")
# $option_prefix is set in mpbb
# shellcheck disable=SC2154
if [ "${include_deps}" = "yes" ]; then
include_deps=--include_deps
else
include_deps=
fi
"${tclsh}" "${thisdir}/tools/sort-with-subports.tcl" --jobs_dir "${option_jobs_dir}" \
--license_db_dir "${option_license_db_dir}" --failcache_dir "${option_failcache_dir}" \
--archive_site_public "${archive_site_public}" \
--archive_site_private "${archive_site_private}" ${include_deps} \
${portnames} || return
}
list-subports() {
# $option_log_dir is set in mpbb
# shellcheck disable=SC2154
local log_subports_progress="${option_log_dir}/ports-progress.txt"
local args
parseopt archive-site:,archive-site-private:,include-deps: "$@" || return
# $option_archive_site is set by parseopt
# shellcheck disable=SC2154
: "${option_archive_site=https://packages.macports.org}"
# $option_archive_site_private is set by parseopt
# shellcheck disable=SC2154
: "${option_archive_site_private=https://packages-private.macports.org}"
# $option_include_deps is set by parseopt
# shellcheck disable=SC2154
: "${option_include_deps=yes}"
set -- ${args+"${args[@]}"}
if [ $# -le 0 ]; then
err "Must specify at least one port"
return 1
fi
success=0
# prepare the log file and make sure to start with an empty one
mkdir -p "$option_log_dir"
> "$log_subports_progress"
print-subports "${option_archive_site}" "${option_archive_site_private}" "${option_include_deps}" "$*" && success=1
if [ $success -eq 0 ]; then
err "None of the specified ports were found in the port index."
return 1
fi
}