Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-gnome
Path: blob/main/Mk/Scripts/create-manifest.sh
16124 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
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
62
# Then the key/values sections
63
echo "deps: { "
64
# Ignore grep's return value.
65
eval ${dp_ACTUAL_PACKAGE_DEPENDS} | { grep -v -E ${dp_PKG_IGNORE_DEPENDS} || :; } | sort -u
66
echo "}"
67
68
echo "options: {"
69
for opt in ${dp_COMPLETE_OPTIONS_LIST}; do
70
if listcontains ${opt} "${dp_PORT_OPTIONS}"; then
71
echo " ${opt}: on,"
72
else
73
echo " ${opt}: off,"
74
fi
75
done
76
echo "}"
77
78
if [ -n "${dp_PKG_NOTES}" ]; then
79
echo "annotations: {"
80
for note in ${dp_PKG_NOTES}; do
81
echo " ${note}: <<EOD"
82
eval "echo \"\${dp_PKG_NOTE_${note}}\""
83
echo "EOD"
84
done
85
echo "}"
86
fi
87
88
# Copy the pkg-descr file
89
cp ${dp_DESCR} ${dp_METADIR}/+DESC
90
91
# Concatenate all the scripts
92
output_files=
93
for stage in INSTALL DEINSTALL; do
94
for prepost in '' PRE POST; do
95
output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}
96
[ -f "${output}" ] && output_files="${output_files:+${output_files} }${output}"
97
done
98
done
99
[ -n "${output_files}" ] && rm -f ${output_files}
100
101
for stage in INSTALL DEINSTALL; do
102
for prepost in '' PRE POST; do
103
eval files="\${dp_PKG${prepost}${stage}}"
104
output=${dp_METADIR}/+${prepost:+${prepost}_}${stage}
105
for input in ${files}; do
106
[ -f "${input}" ] && cat ${input} >> ${output}
107
[ -f "${input}.lua" ] && cp ${input}.lua ${dp_METADIR}
108
done
109
done
110
done
111
112
# *** STARTING NOW, STDOUT is +DISPLAY ***
113
114
exec >${dp_METADIR}/+DISPLAY
115
116
echo '['
117
for message in ${dp_PKGMESSAGES}; do
118
if [ -f "${message}" ]; then
119
#if if starts with [ then it is ucl and we do drop last and first line
120
if head -1 "${message}" | grep -q '^\['; then
121
sed '1d;$d' "${message}"
122
else
123
echo '{type: install, message=<<EOD'
124
cat "${message}"
125
printf 'EOD\n},\n'
126
fi
127
fi
128
done
129
130
# Try and keep these messages in sync with check-deprecated
131
if [ ${dp_MAINTAINER} = "[email protected]" ]; then
132
cat <<-EOT
133
{ message=<<EOD
134
===> NOTICE:
135
136
The ${dp_PKGBASE} port currently does not have a maintainer. As a result, it is
137
more likely to have unresolved issues, not be up-to-date, or even be removed in
138
the future. To volunteer to maintain this port, please create an issue at:
139
140
https://bugs.freebsd.org/bugzilla
141
142
More information about port maintainership is available at:
143
144
https://www.freebsd.org/doc/en/articles/contributing/ports-contributing.html#maintain-port
145
EOD
146
},
147
EOT
148
fi
149
150
if [ -n "${dp_DEPRECATED}" ]; then
151
cat <<-EOT
152
{ message=<<EOD
153
===> NOTICE:
154
155
This port is deprecated; you may wish to reconsider installing it:
156
157
${dp_DEPRECATED}.
158
159
EOT
160
161
if [ -n "${dp_EXPIRATION_DATE}" ]; then
162
cat <<-EOT
163
It is scheduled to be removed on or after ${dp_EXPIRATION_DATE}.
164
165
EOT
166
fi
167
printf 'EOD\n},\n'
168
fi
169
echo ']'
170
171