-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathportmaster.patch
267 lines (243 loc) · 9.67 KB
/
portmaster.patch
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
--- /usr/local/sbin/portmaster.orig 2021-07-27 23:36:40.000000000 -0500
+++ /usr/local/sbin/portmaster 2021-08-14 20:43:28.000000000 -0500
@@ -299,6 +299,9 @@
echo "num_of_deps='$num_of_deps'" >> $IPC_SAVE
echo "build_l='$build_l'" >> $IPC_SAVE
[ -z "$NO_DEP_UPDATES" ] && echo 'unset NO_DEP_UPDATES' >> $IPC_SAVE
+
+ # Save list of ports to be built from source
+ echo "PM_BUILD_FROM_SOURCE='$PM_BUILD_FROM_SOURCE'" >> $IPC_SAVE
fi
echo "CUR_DEPS='$CUR_DEPS'" >> $IPC_SAVE
echo "dep_of_deps='$dep_of_deps'" >> $IPC_SAVE
@@ -633,23 +636,25 @@
packages_init () {
local e1 e2 e3
- e1="The -P/--packages and -PP/--packages-only options are mutually exclusive"
- e2="The --packages-build option and the -P[P] options are mutually exclusive"
+ e1="The -P/--packages, -PP/--packages-only, and --packages-if-stock options are mutually exclusive"
+ e2="The --packages-build, -P[P], and --packages-if-stock options are mutually exclusive"
e3="The --packages-if-newer and -PP/--packages-only options are mutually exclusive"
case "$1" in
- first) [ "$PM_PACKAGES" = only ] && fail $e1
+ first) case "$PM_PACKAGES" in only|stock) fail $e1 ;; esac
[ -n "$PM_PACKAGES_BUILD" ] && fail $e2
[ -z "$PM_PACKAGES" ] && { PM_PACKAGES=first ; export PM_PACKAGES; } ;;
- only) [ "$PM_PACKAGES" = first ] && fail $e1
+ only) case "$PM_PACKAGES" in first|stock) fail $e1 ;; esac
[ "$PM_PACKAGES" = newer ] && fail $e3
[ -n "$PM_PACKAGES_BUILD" ] && fail $e2 ;;
- build) case "$PM_PACKAGES" in first|only) fail $e2 ;; esac ;;
+ build) case "$PM_PACKAGES" in first|only|stock) fail $e2 ;; esac ;;
newer) [ "$PM_PACKAGES" = only ] && fail $e3
[ -z "$PM_PACKAGES" -a -z "$PM_PACKAGES_BUILD" ] && {
PM_PACKAGES=newer ; export PM_PACKAGES; } ;;
local) [ -z "$PM_PACKAGES" -a -z "$PM_PACKAGES_BUILD" ] && {
PM_PACKAGES=local ; export PM_PACKAGES; } ;;
+ stock) case "$PM_PACKAGES" in first|only) fail $e1 ;; esac
+ [ -n "$PM_PACKAGES_BUILD" ] && fail $e2 ;;
esac
}
@@ -680,6 +685,8 @@
--packages-if-newer) packages_init newer
PM_PACKAGES_NEWER=pmp_newer
export PM_PACKAGES_NEWER ;;
+ --packages-if-stock) packages_init stock
+ PM_PACKAGES=stock ; export PM_PACKAGES ;;
--packages-local) packages_init local
PM_PACKAGES_LOCAL=pmp_local
export PM_PACKAGES_LOCAL ;;
@@ -1270,6 +1277,38 @@
esac
}
+# $1: port origin with optional flavor (e.g. dns/py-dnspython@py37, textproc/libxml2)
+get_modified_options() {
+ local default_value description effective_value effective_values i IFS \
+ name option options origin
+
+ origin="$pd/$(dir_part "$portdir")"
+ options=$(PORT_DBDIR=/dev/null make -C "$origin" showconfig | egrep '=(off|on)')
+ effective_values=$(make -C "$origin" showconfig | egrep -o '=(off|on)')
+
+ i=1 ; IFS='
+' ; for option in $options; do
+ IFS='=:' read name default_value description <<-EOF
+ $option
+ EOF
+ effective_value=$(echo "$effective_values" | sed -n "${i}p")
+ if [ "${effective_value#=}" != "$default_value" ]; then
+ echo " ${name##* }: $default_value => ${effective_value#=} (${description# })"
+ fi
+ i=$((i + 1))
+ done
+}
+
+# $1: port origin with optional flavor (e.g. dns/py-dnspython@py37, textproc/libxml2)
+should_build_from_source() {
+ for portdir in $PM_BUILD_FROM_SOURCE; do
+ if [ "$portdir" = "$1" ]; then
+ echo 1
+ return
+ fi
+ done
+}
+
#=============== End functions relevant to --features and main ===============
#=============== Begin code relevant only to --features ===============
@@ -2206,7 +2245,7 @@
}
update_build_l () {
- local originflavor origin flavor iport make_target
+ local originflavor origin flavor iport make_target provenance
originflavor=$1 ; update_pm_nu $originflavor
origin=$(dir_part "$originflavor")
@@ -2216,13 +2255,15 @@
[ -n "$PM_NO_CONFIRM" ] && return
+ [ $(should_build_from_source "$originflavor") ] && provenance='source' || provenance='package'
+
if [ -z "$iport" ]; then
case "$build_l" in *\ $origin\\*) return ;; esac
case $make_target in
install)
- build_l="${build_l}\tInstall $originflavor\n" ;;
+ build_l="${build_l}\tInstall $originflavor from $provenance\n" ;;
*)
- build_l="${build_l}\tExecute make $make_target for $originflavor\n" ;;
+ build_l="${build_l}\tExecute make $make_target for $originflavor from $provenance\n" ;;
esac
return
fi
@@ -2232,10 +2273,10 @@
find_new_port "$originflavor" # sets global variable new_port
case `$PKG_CMD version -t $iport $new_port 2>/dev/null` in
- \<) build_l="${build_l}\tUpgrade $iport to $new_port\n" ;;
- =) build_l="${build_l}\tRe-install $iport\n" ;;
- \>) build_l="${build_l}\tDowngrade $iport to $new_port\n" ;;
- *) build_l="${build_l}\tUpgrade $iport\n" ;;
+ \<) build_l="${build_l}\tUpgrade $iport to $new_port from $provenance\n" ;;
+ =) build_l="${build_l}\tRe-install $iport from $provenance\n" ;;
+ \>) build_l="${build_l}\tDowngrade $iport to $new_port from $provenance\n" ;;
+ *) build_l="${build_l}\tUpgrade $iport from $provenance\n" ;;
esac
}
@@ -2898,7 +2939,8 @@
CUR_DEPS=':' ; DISPLAY_LIST='' ; INSTALLED_LIST=''
PM_DEPTH='' ; pm_mktemp IPC_SAVE ; IPC_SAVE=$pm_mktemp_file
PM_FIRST_PASS=pm_first_pass ; PM_NEEDS_UPDATE=' ' # Used with -F for multiport and -a
- export CUR_DEPS DISPLAY_LIST INSTALLED_LIST PM_DEPTH IPC_SAVE PM_FIRST_PASS PM_NEEDS_UPDATE
+ PM_BUILD_FROM_SOURCE=''
+ export CUR_DEPS DISPLAY_LIST INSTALLED_LIST PM_DEPTH IPC_SAVE PM_FIRST_PASS PM_NEEDS_UPDATE PM_BUILD_FROM_SOURCE
if [ -n "$LOCALBASE" ]; then
LOCALBASE_COMPAT="$LOCALBASE/lib/compat/pkg"
@@ -3273,8 +3315,6 @@
fi
fi
fi
-
- update_build_l "$portdir" "$upg_port" "$make_target"
elif [ -n "$FETCH_ONLY" -a -n "$PM_PACKAGES" ]; then
update_pm_nu $portdir
fi
@@ -3349,15 +3389,53 @@
[ "$$" -eq "$PM_PARENT_PID" -a -n "$PM_BUILD_ONLY_LIST" ] &&
PM_BUILD_ONLY_LIST=pmp_doing_build_deps
- if [ -z "$PM_PACKAGES" ]; then
- [ -z "$PM_NO_MAKE_CONFIG" ] && make_config
+ # check whether the port has stock or custom configuration
+ if [ "$PM_PACKAGES" = 'stock' ]; then
+ PM_CUSTOM_CONFIG=$(get_modified_options "$portdir")
+ fi
+ # run `make config` when:
+ # - using only ports (i.e. no --packages* options given)
+ # - using --packages-if-stock and port has custom configuration
+ # - using --packages-if-stock and port is not already installed
+ if [ \( -z "$PM_PACKAGES" -o -n "$PM_CUSTOM_CONFIG" -o -z "$upg_port" \) -a \
+ -z "$PM_NO_MAKE_CONFIG" ]; then
+ make_config
+ # reanalyze configuration in case stock vs. custom state has changed
+ if [ "$PM_PACKAGES" = 'stock' ]; then
+ PM_CUSTOM_CONFIG=$(get_modified_options "$portdir")
+ fi
+ fi
+
+ # build from source when:
+ # - using only ports (i.e. no --packages* options given)
+ # - using --packages-if-stock and port has custom configuration
+ # install from package otherwise
+ if [ -z "$PM_PACKAGES" -o -n "$PM_CUSTOM_CONFIG" ]; then
+ if [ "$PM_PACKAGES" = 'stock' ]; then
+ echo -e "===>>> Modified options found; building from source\n$PM_CUSTOM_CONFIG\n"
+ fi
+ PM_BUILD_FROM_SOURCE="$PM_BUILD_FROM_SOURCE $portdir"
dep_check_type='build-depends-list run-depends-list'
[ -n "$PM_THOROUGH" ] && dep_check_type=all-depends-list
else
+ if [ "$PM_PACKAGES" = 'stock' ]; then
+ echo "===>>> No modified options; installing from package"
+ #configuration_path="$port_dbdir/$(dir_part $portdir | sed 's/\//_/')"
+ #if [ -d "$configuration_path" ]; then
+ # echo "--->>> Deleting redundant configuration at $configuration_path"
+ # pm_rm_s -rf "$configuration_path"
+ #fi
+ echo
+ fi
dep_check_type=run-depends-list
fi
+ # add entry to list of outstanding actions
+ if [ -z "$FETCH_ONLY" ]; then
+ update_build_l "$portdir" "$upg_port" "$make_target"
+ fi
+
dependency_check "$dep_check_type"
[ -n "$PM_URB" -o -n "$PM_URB_UP" ] &&
@@ -3385,14 +3463,14 @@
if [ -z "$NO_DEP_UPDATES" ]; then
if [ -z "$PM_THOROUGH" ]; then
- if [ -z "$PM_PACKAGES" ]; then
+ if [ -z "$PM_PACKAGES" -o $(should_build_from_source "$portdir") ]; then
echo "===>>> Starting check for build dependencies"
dependency_check build-depends-list
fi
else
echo "===>>> Starting check for all dependencies"
- if [ -z "$PM_PACKAGES" ]; then
+ if [ -z "$PM_PACKAGES" -o $(should_build_from_source "$portdir") ]; then
dependency_check all-depends-list
else
dependency_check run-depends-list
@@ -3411,7 +3489,8 @@
find_new_port $portdir
-if [ -n "$PM_PACKAGES" -o "$PM_PACKAGES_BUILD" = doing_build_only_dep ]; then
+if [ \( -n "$PM_PACKAGES" -o "$PM_PACKAGES_BUILD" = doing_build_only_dep \) -a \
+ ! $(should_build_from_source "$portdir") ]; then
case `pm_make_b -V PT_NO_INSTALL_PACKAGE` in
'') pm_package_time=yes ;;
*) if [ "$PM_PACKAGES" = 'only' ]; then
@@ -3640,7 +3719,9 @@
fi # [ -n "$pm_package_time" ]
if [ -z "$use_package" ]; then
- if [ -n "$PM_PACKAGES" ]; then
+ # if this was supposed to be a package install but no viable package was found,
+ # run `make config` and resolve dependencies for the first time now
+ if [ -n "$PM_PACKAGES" -a ! $(should_build_from_source "$portdir") ]; then
[ -z "$PM_NO_MAKE_CONFIG" ] && make_config
if [ -z "$PM_THOROUGH" ]; then
@@ -3950,16 +4031,16 @@
$PM_SU_CMD $PKG_CMD set -yo $ro_opd:$portdir
fi
-
+[ -z "$use_package" ] && provenance='source' || provenance='package'
if [ -n "$upg_port" ]; then
upg_port=$(dir_part $upg_port)
if [ ! "$upg_port" = "$new_port" ]; then
- ilist="Upgrade of $upg_port to $new_port"
+ ilist="Upgrade of $upg_port to $new_port from $provenance"
else
- ilist="Re-installation of $upg_port"
+ ilist="Re-installation of $upg_port from $provenance"
fi
else
- ilist="Installation of $portdir ($new_port)"
+ ilist="Installation of $portdir ($new_port) from $provenance"
fi
if [ "$$" -ne "$PM_PARENT_PID" -o -n "$PM_URB" ]; then