Skip to content

Commit b09a138

Browse files
committed
Use authoring tools only when available
For example, perldocker installs Dist::Zilla only from Perl v5.20 onwards. Authoring tools are executed when their config file exists and either: - the authoring tool is available, or - no Build.PL or Makefile.PL is available
1 parent 1050024 commit b09a138

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

bin/build-dist

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,41 @@ set -e -u -o pipefail
55
: "${BUILD_DIR:=build_dir}"
66

77
main() (
8-
if [[ -e dist.ini ]]; then dzil-build
9-
elif [[ -e minil.toml ]]; then minil-build
8+
if can-run-dzil-build; then dzil-build
9+
elif can-run-minil-build; then minil-build
1010
elif [[ -e Build.PL ]]; then build-pl
1111
elif [[ -e Makefile.PL ]]; then std-perl-build
1212
fi
1313
)
1414

15+
SUCCESS=0
16+
FAILURE=1
17+
18+
can-run-authoring-tool () {
19+
local file="$1"
20+
local tool="$2"
21+
22+
# file doesn't exist ? => don't
23+
# is authoring tool available ? => run
24+
# does build file exist ? => don't
25+
# othwerwise run and fail
26+
27+
[[ -e "$file" ]] || return $FAILURE
28+
which "$tool" && return $SUCCESS
29+
[[ -e Build.PL ]] && return $FAILURE
30+
[[ -e Makefile.PL ]] && return $FAILURE
31+
32+
return $SUCCESS
33+
}
34+
35+
can-run-dzil-build() {
36+
can-run-authoring-tool dist.ini dzil
37+
}
38+
39+
can-run-minil-build() {
40+
can-run-authoring-tool minil.toml minil
41+
}
42+
1543
dzil-build() (
1644
dzil build --no-tgz --in "$BUILD_DIR"
1745
)

0 commit comments

Comments
 (0)