Skip to content

Commit 980816a

Browse files
committed
Changes to the _install_license() logic
So far we've simply installed the LICENSE.TXT file located in the LLVM root as the sole license file. However, as seen in #10, there are other license files too. In fact, there are also license files in some of the subdirectories, which is also indicated in the LICENSE.TXT itself. The new `_install_licenses()` tries to be a tiny bit smart about the issue by `find`-ing all appropriate license files. Please note that the new function does require a path as an argument.
1 parent a1a35ea commit 980816a

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

PKGBUILD

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,30 @@ _install_python_bindings() {
9595
_compile_python_files "${pkgdir}${_py_sitepkg_dir}/${1##*/}"
9696
}
9797

98-
# Install the license file for a package
99-
# Arguments: NONE
100-
_install_license() {
101-
install -D -m 0644 "${srcdir}/${_pkgname}/LICENSE.TXT" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
98+
# Install the license files for a package
99+
# Arguments: source_directory_to_install_from
100+
# Notes: We prune some directories that are inserted into the tree in prepare()
101+
# in order to eliminate possible duplicates. We also use NULL-terminated
102+
# strings, just in case we have paths including spaces. Finally, we opt
103+
# for a flat directory structure, so all license files in subdirectories
104+
# get their names from the relative path with '/'s replaced by dashes.
105+
# Not the most elegant solution, but should be working well enough.
106+
_install_licenses() {
107+
find "${1}" \
108+
\( \
109+
-path "${srcdir}/${_pkgname}/tools/clang" -o \
110+
-path "${srcdir}/${_pkgname}/projects/compiler-rt" \
111+
\) -prune -o \
112+
\( \
113+
-iname 'license*' -o \
114+
-iname 'credits*' -o \
115+
-iname 'copyright*' \
116+
\) -printf '%P\0' \
117+
| while read -d $'\0' license_file; do
118+
install -D -m 0644 \
119+
"${1}/${license_file}" \
120+
"${pkgdir}/usr/share/licenses/${pkgname}/${license_file//\//-}"
121+
done
102122
}
103123

104124
#
@@ -121,6 +141,7 @@ pkgver() {
121141
prepare() {
122142
cd "${srcdir}/${_pkgname}"
123143

144+
# Anything added here should also be pruned in _install_licenses() above.
124145
svn export --force "${srcdir}/clang" tools/clang
125146
svn export --force "${srcdir}/clang-tools-extra" tools/clang/tools/extra
126147
svn export --force "${srcdir}/compiler-rt" projects/compiler-rt
@@ -221,7 +242,7 @@ package_llvm-svn() {
221242

222243
_install_python_bindings "${srcdir}/llvm/bindings/python/llvm"
223244

224-
_install_license
245+
_install_licenses "${srcdir}/llvm"
225246
}
226247

227248
package_llvm-libs-svn() {
@@ -257,7 +278,7 @@ package_llvm-libs-svn() {
257278
# libLLVM-3.8.0svn-r123456.so
258279
ln -s "libLLVM-${_sover}.so" "${pkgdir}/usr/lib/libLLVM-$(echo ${pkgver} | tr _ -).so"
259280

260-
_install_license
281+
_install_licenses "${srcdir}/llvm"
261282
}
262283

263284
package_llvm-ocaml-svn() {
@@ -278,7 +299,7 @@ package_llvm-ocaml-svn() {
278299
cp -a "${srcdir}/ocaml.lib" "${pkgdir}/usr/lib/ocaml"
279300
cp -a "${srcdir}/ocaml.doc" "${pkgdir}/usr/share/doc/llvm/ocaml-html"
280301

281-
_install_license
302+
_install_licenses "${srcdir}/llvm"
282303
}
283304

284305
package_clang-svn() {
@@ -361,7 +382,7 @@ package_clang-svn() {
361382

362383
_install_python_bindings "${srcdir}/llvm/tools/clang/bindings/python/clang"
363384

364-
_install_license
385+
_install_licenses "${srcdir}/clang"
365386
}
366387

367388
package_clang-analyzer-svn() {
@@ -388,7 +409,7 @@ package_clang-analyzer-svn() {
388409

389410
_compile_python_files "${pkgdir}/usr/share/scan-view"
390411

391-
_install_license
412+
_install_licenses "${srcdir}/clang"
392413
}
393414

394415
package_clang-compiler-rt-svn() {
@@ -406,7 +427,7 @@ package_clang-compiler-rt-svn() {
406427

407428
make DESTDIR="${pkgdir}" install
408429

409-
_install_license
430+
_install_licenses "${srcdir}/compiler-rt"
410431
}
411432

412433
package_clang-tools-extra-svn() {
@@ -424,7 +445,7 @@ package_clang-tools-extra-svn() {
424445

425446
make DESTDIR="${pkgdir}" install
426447

427-
_install_license
448+
_install_licenses "${srcdir}/clang-tools-extra"
428449
}
429450

430451
# vim:set ts=4 sts=4 sw=4 et:

0 commit comments

Comments
 (0)