Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/Mk/Scripts/create-manifest.sh
16461 views
1
#!/bin/sh
2
#
3
# MAINTAINER: [email protected]
4
5
set -e
6
set -o pipefail
7
8
. "${dp_SCRIPTSDIR}/functions.sh"
9
10
validate_env dp_ACTUAL_PACKAGE_DEPENDS dp_CATEGORIES dp_COMMENT \
11
dp_COMPLETE_OPTIONS_LIST dp_DEPRECATED dp_DESCR dp_EXPIRATION_DATE \
12
dp_GROUPS dp_LICENSE dp_LICENSE_COMB dp_MAINTAINER dp_METADIR \
13
dp_NO_ARCH dp_PKGBASE dp_PKGDEINSTALL dp_PKGINSTALL dp_PKGMESSAGES \
14
dp_PKGORIGIN dp_PKGPOSTDEINSTALL dp_PKGPOSTINSTALL dp_PKGPREDEINSTALL \
15
dp_PKGPREINSTALL dp_PKGVERSION dp_PKG_BIN dp_PKG_IGNORE_DEPENDS \
16
dp_PKG_NOTES dp_PORT_OPTIONS dp_PREFIX dp_USERS dp_WWW dp_VITAL
17
18
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_CREATE_MANIFEST}" ] && set -x
19
20
set -u
21
22
listcontains() {
23
local str lst elt
24
str=$1
25
lst=$2
26
27
for elt in ${lst} ; do
28
if [ ${elt} = ${str} ]; then
29
return 0
30
fi
31
done
32
return 1
33
}
34
35
mkdir -p ${dp_METADIR}
36
37
# Save stdout and redirect it to the manifest file.
38
exec 3>&1 >${dp_METADIR}/+MANIFEST
39
40
# First, all the required bits
41
cat <<EOT
42
name: "${dp_PKGBASE}"
43
version: "${dp_PKGVERSION}"
44
origin: ${dp_PKGORIGIN}
45
comment: <<EOD
46
${dp_COMMENT}
47
EOD
48
maintainer: ${dp_MAINTAINER}
49
prefix: ${dp_PREFIX}
50
categories: [ ${dp_CATEGORIES} ]
51
licenselogic: ${dp_LICENSE_COMB:-single}
52
EOT
53
54
# Then, the optional bits
55
[ -z "${dp_WWW}" ] || echo "www: \"${dp_WWW%% *}\""
56
[ -z "${dp_LICENSE}" ] || echo "licenses: [ ${dp_LICENSE} ]"
57
[ -z "${dp_USERS}" ] || echo "users: [ ${dp_USERS} ]"
58
[ -z "${dp_GROUPS}" ] || echo "groups: [ ${dp_GROUPS} ]"
59
[ -n "${dp_NO_ARCH}" ] && echo "arch : $(${dp_PKG_BIN} config abi | tr '[:upper:]' '[:lower:]' | cut -d: -f1,2):*"
60
[ -n "${dp_NO_ARCH}" ] && echo "abi : $(${dp_PKG_BIN} config abi | cut -d: -f1,2):*"
61
[ -n "${dp_VITAL}" ] && echo "vital : true"
62
63
# Then the key/values sections
64
echo "deps: { "
65
# Ignore grep's return value.
66
eval ${dp_ACTUAL_PACKAGE_DEPENDS} | { grep -v -E ${dp_PKG_IGNORE_DEPENDS} || :; } | sort -u
67
echo "}"
68
69
echo "options: {"
70
for opt in ${dp_COMPLETE_OPTIONS_LIST}; do
71
if listcontains ${opt} "${dp_PORT_OPTIONS}"; then
72
echo " ${opt}: on,"
73
else
74
echo " ${opt}: off,"
75
fi
76
done
77
echo "}"
78
79
if [ -n "${dp_PKG_NOTES}" ]; then
80
echo "annotations: {"
81
for note in ${dp_PKG_NOTES}; do
82
echo " ${note}: <<EOD"
83
eval "echo \"\${dp_PKG_NOTE_${note}}\""
84
echo "EOD"
85
done
86
echo "}"
87
fi
88
89
# Copy the pkg-descr file
90
cp ${dp_DESCR} ${dp_METADIR}/+DESC
91
92
# Concatenate all the scripts
93
output_files=
94
for stage in INSTALL DEINSTALL; do
95
for prepost in '' PRE POST; do
96
output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}
97
[ -f "${output}" ] && output_files="${output_files:+${output_files} }${output}"
98
done
99
done
100
[ -n "${output_files}" ] && rm -f ${output_files}
101
102
for stage in INSTALL DEINSTALL; do
103
for prepost in '' PRE POST; do
104
eval files="\${dp_PKG${prepost}${stage}}"
105
output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}
106
for input in ${files}; do
107
[ -f "${input}" ] && cat ${input} >> ${output}
108
[ -f "${input}.lua" ] && cp ${input}.lua ${dp_METADIR}
109
done
110
done
111
done
112
113
# *** STARTING NOW, STDOUT is +DISPLAY ***
114
115
exec >${dp_METADIR}/+DISPLAY
116
117
echo '['
118
for message in ${dp_PKGMESSAGES}; do
119
if [ -f "${message}" ]; then
120
#if if starts with [ then it is ucl and we do drop last and first line
121
if head -1 "${message}" | grep -q '^\['; then
122
sed '1d;$d' "${message}"
123
else
124
echo '{type: install, message=<<EOD'
125
cat "${message}"
126
printf 'EOD\n},\n'
127
fi
128
fi
129
done
130
131
# Try and keep these messages in sync with check-deprecated
132
if [ ${dp_MAINTAINER} = "[email protected]" ]; then
133
cat <<-EOT
134
{ message=<<EOD
135
===> NOTICE:
136
137
The ${dp_PKGBASE} port currently does not have a maintainer. As a result, it is
138
more likely to have unresolved issues, not be up-to-date, or even be removed in
139
the future. To volunteer to maintain this port, please create an issue at:
140
141
https://bugs.freebsd.org/bugzilla
142
143
More information about port maintainership is available at:
144
145
https://docs.freebsd.org/en/articles/contributing/#ports-contributing
146
EOD
147
},
148
EOT
149
fi
150
151
if [ -n "${dp_DEPRECATED}" ]; then
152
cat <<-EOT
153
{ message=<<EOD
154
===> NOTICE:
155
156
This port is deprecated; you may wish to reconsider installing it:
157
158
${dp_DEPRECATED}.
159
160
EOT
161
162
if [ -n "${dp_EXPIRATION_DATE}" ]; then
163
cat <<-EOT
164
It is scheduled to be removed on or after ${dp_EXPIRATION_DATE}.
165
166
EOT
167
fi
168
printf 'EOD\n},\n'
169
fi
170
echo ']'
171
172