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
|
# Maintainer: Cynthetika <opensourceATcynthetikaDOTcom>
# Contributor: Dimitris Kiziridis <ragouel at outlook dot com>
pkgname=mimemagic
pkgver=1.2.0
pkgrel=1
pkgdesc="Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, XML document namespaces, and tree magic for mounted volumes, generated from the XDG shared-mime-info database"
arch=('any')
url='https://godoc.org/github.com/zRedShift/mimemagic'
license=('GPL2')
depends=('glibc')
makedepends=('go')
conflicts=("$pkgname-git")
source=("$pkgname-$pkgver.tar.gz::https://github.com/zRedShift/$pkgname/archive/v$pkgver.tar.gz")
sha256sums=('7131b6be01748a5a3498ae2f518e53f3a72bfd87e6208b5dc8cc8ecf948d6629')
prepare() {
cd "$pkgname-$pkgver"
# create build output directory if not present
mkdir -p build
# update module fetching method for Go version >1.17
go mod tidy
# download Go module dependencies
go mod download
}
build() {
cd "$pkgname-$pkgver"
# set build flags per Arch hardening recommendations
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="-Wl,-O1,--sort-common,-z,relro,-z,now"
export GOFLAGS=" \
-buildmode=pie \
-trimpath \
-ldflags=-linkmode=external \
-ldflags=-extldflags=-Wl,-O1,--sort-common,-z,relro,-z,now \
-mod=readonly \
-modcacherw \
"
# recursively build all project binaries
go build -o build ./cmd/...
}
check() {
cd "$pkgname-$pkgver"
# run build test
go test
}
package() {
cd "$pkgname-$pkgver"
# install built Go binaries
install -Dm 755 -t "$pkgdir/usr/bin" build/$pkgname
install -Dm 755 -t "$pkgdir/usr/bin" build/parser
# install project "readme" documentation
install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
}
|