tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
build-support/php: make shellcheck happy
Pol Dellaiera
7 months ago
767ed2a8
bb0c422e
+27
-17
3 changed files
expand all
collapse all
unified
split
pkgs
build-support
php
builders
v2
hooks
composer-install-hook.sh
composer-vendor-hook.sh
php-script-utils.bash
+7
-4
pkgs/build-support/php/builders/v2/hooks/composer-install-hook.sh
···
1
-
declare -g version
0
0
2
declare -g pname
3
declare -g composerVendor
4
declare -g -i composerStrictValidation="${composerStrictValidation:-0}"
···
8
preCheckHooks+=(composerInstallCheckHook)
9
preInstallHooks+=(composerInstallInstallHook)
10
0
11
source @phpScriptUtils@
12
13
composerInstallConfigureHook() {
···
20
exit 1
21
fi
22
23
-
install -Dm644 ${composerVendor}/composer.json .
24
25
if [[ -f "${composerVendor}/composer.lock" ]]; then
26
-
install -Dm644 ${composerVendor}/composer.lock .
27
fi
28
29
if [[ -f "composer.lock" ]]; then
···
52
composerInstallInstallHook() {
53
echo "Executing composerInstallInstallHook"
54
55
-
cp -ar ${composerVendor}/* .
56
57
# Copy the relevant files only in the store.
58
mkdir -p "$out"/share/php/"${pname}"
···
1
+
# shellcheck shell=bash
2
+
3
+
declare -g out
4
declare -g pname
5
declare -g composerVendor
6
declare -g -i composerStrictValidation="${composerStrictValidation:-0}"
···
10
preCheckHooks+=(composerInstallCheckHook)
11
preInstallHooks+=(composerInstallInstallHook)
12
13
+
# shellcheck source=/dev/null
14
source @phpScriptUtils@
15
16
composerInstallConfigureHook() {
···
23
exit 1
24
fi
25
26
+
install -Dm644 "${composerVendor}"/composer.json .
27
28
if [[ -f "${composerVendor}/composer.lock" ]]; then
29
+
install -Dm644 "${composerVendor}"/composer.lock .
30
fi
31
32
if [[ -f "composer.lock" ]]; then
···
55
composerInstallInstallHook() {
56
echo "Executing composerInstallInstallHook"
57
58
+
cp -ar "${composerVendor}"/* .
59
60
# Copy the relevant files only in the store.
61
mkdir -p "$out"/share/php/"${pname}"
+18
-13
pkgs/build-support/php/builders/v2/hooks/composer-vendor-hook.sh
···
0
0
0
1
source @phpScriptUtils@
2
0
0
3
declare -g composerNoDev="${composerNoDev:+--no-dev}"
4
declare -g composerNoPlugins="${composerNoPlugins:+--no-plugins}"
5
declare -g composerNoScripts="${composerNoScripts:+--no-scripts}"
···
20
21
if [[ -e "$composerLock" ]]; then
22
echo -e "\e[32mUsing user provided \`composer.lock\` file from \`$composerLock\`\e[0m"
23
-
install -Dm644 $composerLock ./composer.lock
24
fi
25
26
if [[ ! -f "composer.lock" ]]; then
···
30
--no-interaction \
31
--no-progress \
32
--optimize-autoloader \
33
-
${composerNoDev} \
34
-
${composerNoPlugins} \
35
-
${composerNoScripts} \
36
update
37
38
if [[ -f "composer.lock" ]]; then
39
-
install -Dm644 composer.lock -t $out/
40
41
echo
42
echo -e "\e[31mERROR: No composer.lock found\e[0m"
···
74
--no-interaction \
75
--no-progress \
76
--optimize-autoloader \
77
-
${composerNoDev} \
78
-
${composerNoPlugins} \
79
-
${composerNoScripts} \
80
install
81
82
echo "Finished composerVendorBuildHook"
···
93
composerVendorInstallHook() {
94
echo "Executing composerVendorInstallHook"
95
96
-
mkdir -p $out
97
98
-
cp -ar composer.json $(composer config vendor-dir) $out/
99
mapfile -t installer_paths < <(jq -r -c 'try((.extra."installer-paths") | keys[])' composer.json)
100
101
for installer_path in "${installer_paths[@]}"; do
···
104
out_installer_path="$out/${installer_path/\{\$name\}*/}"
105
# Copy the installer path if it exists
106
if [[ -d "$installer_path" ]]; then
107
-
mkdir -p $(dirname "$out_installer_path")
108
echo -e "\e[32mCopying installer path $installer_path to $out_installer_path\e[0m"
109
cp -ar "$installer_path" "$out_installer_path"
110
# Strip out the git repositories
111
-
find $out_installer_path -name .git -type d -prune -print -exec rm -rf {} ";"
112
fi
113
done
114
115
if [[ -f "composer.lock" ]]; then
116
-
cp -ar composer.lock $out/
117
fi
118
119
echo "Finished composerVendorInstallHook"
···
1
+
# shellcheck shell=bash
2
+
3
+
# shellcheck source=/dev/null
4
source @phpScriptUtils@
5
6
+
declare -g out
7
+
declare -g composerLock
8
declare -g composerNoDev="${composerNoDev:+--no-dev}"
9
declare -g composerNoPlugins="${composerNoPlugins:+--no-plugins}"
10
declare -g composerNoScripts="${composerNoScripts:+--no-scripts}"
···
25
26
if [[ -e "$composerLock" ]]; then
27
echo -e "\e[32mUsing user provided \`composer.lock\` file from \`$composerLock\`\e[0m"
28
+
install -Dm644 "$composerLock" ./composer.lock
29
fi
30
31
if [[ ! -f "composer.lock" ]]; then
···
35
--no-interaction \
36
--no-progress \
37
--optimize-autoloader \
38
+
"${composerNoDev}" \
39
+
"${composerNoPlugins}" \
40
+
"${composerNoScripts}" \
41
update
42
43
if [[ -f "composer.lock" ]]; then
44
+
install -Dm644 composer.lock -t "$out"/
45
46
echo
47
echo -e "\e[31mERROR: No composer.lock found\e[0m"
···
79
--no-interaction \
80
--no-progress \
81
--optimize-autoloader \
82
+
"${composerNoDev}" \
83
+
"${composerNoPlugins}" \
84
+
"${composerNoScripts}" \
85
install
86
87
echo "Finished composerVendorBuildHook"
···
98
composerVendorInstallHook() {
99
echo "Executing composerVendorInstallHook"
100
101
+
mkdir -p "$out"
102
103
+
cp -ar composer.json "$(composer config vendor-dir)" "$out"/
104
mapfile -t installer_paths < <(jq -r -c 'try((.extra."installer-paths") | keys[])' composer.json)
105
106
for installer_path in "${installer_paths[@]}"; do
···
109
out_installer_path="$out/${installer_path/\{\$name\}*/}"
110
# Copy the installer path if it exists
111
if [[ -d "$installer_path" ]]; then
112
+
mkdir -p "$(dirname "$out_installer_path")"
113
echo -e "\e[32mCopying installer path $installer_path to $out_installer_path\e[0m"
114
cp -ar "$installer_path" "$out_installer_path"
115
# Strip out the git repositories
116
+
find "$out_installer_path" -name .git -type d -prune -print -exec rm -rf {} ";"
117
fi
118
done
119
120
if [[ -f "composer.lock" ]]; then
121
+
cp -ar composer.lock "$out"/
122
fi
123
124
echo "Finished composerVendorInstallHook"
+2
pkgs/build-support/php/builders/v2/hooks/php-script-utils.bash
···
0
0
1
declare -g version
2
declare -g -i composerStrictValidation="${composerStrictValidation:-0}"
3
···
1
+
# shellcheck shell=bash
2
+
3
declare -g version
4
declare -g -i composerStrictValidation="${composerStrictValidation:-0}"
5