aboutsummaryrefslogtreecommitdiff
path: root/sbopkglint.d/15-noarch.t.sh
blob: 075fdb1c61572b2f0a545b46c8cf8b52d16f6809 (plain)
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
#!/bin/sh

# sbopkglint test, must be sourced by sbopkglint (not run standalone).

# PKG, PRGNAM, VERSION, ARCH are set by sbopkglint. also the current
# directory is the root of the installed package tree.

########################################################################
# makes sure "noarch" packages really are noarch.
# for packages that aren't noarch, recommend noarch if it looks like one.
# the recommendation is not an error!

# shared libs and executables:
find * -type f -print0 | xargs -0 file -m /etc/file/magic/elf | grep ELF | cut -d: -f1 | xargs -rd "\n" ls -lb > .elfbins.$$

# static libs (for now, just going by filename!)
find * -type f -a -name '*.a' | xargs -rd "\n" ls -lb > .statlibs.$$

if [ "$ARCH" = "noarch" ]; then
	[ -s .elfbins.$$ ] && \
		warn "package claims to be noarch, but contains ELF binaries:" && \
		cat .elfbins.$$
	[ -s .statlibs.$$ ] && \
		warn "package claims to be noarch, but contains static libraries:" && \
		cat .statlibs.$$
elif [ ! -s .statlibs.$$ ] && [ ! -s .elfbins.$$ ] && [ ! -e usr/lib ] && [ ! -e usr/lib64 ]; then
	x="$( find usr/share/pkgconfig -type f -exec grep 'usr/lib' {} \+ 2>/dev/null )"
	[ -z "$x" ] && note "package might be a good candidate for noarch"
fi

rm -f .elfbins.$$ .statlibs.$$