blob: 1c3ef902a616d5263c76581806bf5b8d977a1896 (
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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# Maintainer: @RubenKelevra <cyrond@gmail.com>
# Contributor: Johannes Löthberg <johannes@kyriasis.com>
# Contributor: Anatol Pomozov
# Contributor: kpcyrd <git@rxv.cc>
# Contributor: Frederik “Freso” S. Olesen <freso.dk@gmail.com>
# Contributor: Jakub "Kubuxu" Sztandera <kubuxu@protonmail.ch>
# Contributor: Frederik “Freso” S. Olesen <freso.dk@gmail.com>
# Contributor: kpcyrd <git@rxv.cc>
# Contributor: Ian Naval <ianonavy@gmail.com>
DEBUG=0
_pkgname=go-ipfs
pkgname=$_pkgname-git
pkgver=0.13.1.r0.g8ffc7a8a6
pkgrel=1
epoch=2
pkgdesc='A peer-to-peer hypermedia distribution protocol'
url="https://github.com/ipfs/$_pkgname"
arch=('i686' 'x86_64' 'armv7h' 'aarch64')
license=(MIT)
depends=(glibc)
makedepends=(go git)
optdepends=('bash-completion: bash completion support')
provides=("$_pkgname")
conflicts=("$_pkgname")
install="$pkgname.install"
source=("git+$url.git#tag=v0.13.1"
# https://github.com/ipfs/go-ipfs/pull/8213#issuecomment-881866789
rb.patch
strip.patch)
b2sums=('SKIP'
'e806cac9fbfa396bdfad6e236bbfe4141b41b81da0a4c92b045b82c5c7237af7048bc16db4d9078c7351dbc4d82e658bb78f07bbc48b603c0589bca59c63f02d'
'5146f8e5ee5bc5894e4200ea6a5074f569e71b353f6f8235e0577c09564587b97d1d4af9077b465e04e504f5ce1573a8e52c02359a6cb0e4d2b20736930d6400')
prepare() {
cd "$srcdir/$_pkgname"
patch -Np1 -i ../rb.patch
if [ "$DEBUG" -eq 0 ]; then
patch -Np1 -i ../strip.patch
fi
cd "$srcdir/.."
# check if it was wiped due to enabled optimizations
if [ ! -f "./go/wiped" ] && [ -d "./go" ]; then
chmod u+w -R "./go" 2>/dev/null || true
rm -fdR ./go 2>/dev/null || true
fi
mkdir -p "go"
touch go/wiped
export GOPATH="$(pwd)/go"
# make sure GOPATH is set to writeable
chmod u+w -R "$GOPATH"
cd "$srcdir/$_pkgname"
export CGO_LDFLAGS="$LDFLAGS"
export CGO_CFLAGS="$CFLAGS"
export CGO_CPPFLAGS="$CPPFLAGS"
export CGO_CXXFLAGS="$CXXFLAGS"
export GOFLAGS="-buildmode=pie -modcacherw"
# dirty fix go1.18
sed -i -r 's,^go 1\.[0-9]+,go 1.18,' go.mod
go mod tidy
go mod vendor
# go get -d -v ./... # old fetch
}
pkgver() {
EXCLUDE_TAGS="floodsub|sharding-pre|-dev"
cd "$srcdir/$_pkgname"
VERSION=$(git tag | grep -vE "$EXCLUDE_TAGS" | sed 's/-/~/g' | sort --version-sort --reverse | sed 's/~/-/g' | head -n1)
COUNT=$(git rev-list "$VERSION.." --count)
CHKSUM="$(git rev-parse --short HEAD)"
VERSION=$(echo "$VERSION" | sed 's/^v//' | sed 's/-//')
printf "%s.%s.%s" "$VERSION" "r$COUNT" "g$CHKSUM"
}
build() {
cd "$srcdir/$_pkgname"
export CGO_LDFLAGS="$LDFLAGS"
export CGO_CFLAGS="$CFLAGS"
export CGO_CPPFLAGS="$CPPFLAGS"
export CGO_CXXFLAGS="$CXXFLAGS"
export GOFLAGS="-buildmode=pie -trimpath -modcacherw"
if [ "$DEBUG" -eq 0 ]; then
export CGO_ENABLED=0
# only run detection on x86_64 and if makepkg.conf contains no value
if [ "$CARCH" == "x86_64" ] && [ -z "$GOAMD64" ]; then
# detect cpu feature level
version_4="$(/lib/ld-linux-x86-64.so.2 --help | grep supported | grep x86-64-v4 | wc -l)"
version_3="$(/lib/ld-linux-x86-64.so.2 --help | grep supported | grep x86-64-v3 | wc -l)"
version_2="$(/lib/ld-linux-x86-64.so.2 --help | grep supported | grep x86-64-v2 | wc -l)"
if [ "$version_4" -gt 0 ]; then
export GOAMD64="v4"
elif [ "$version_3" -gt 0 ]; then
export GOAMD64="v3"
elif [ "$version_2" -gt 0 ]; then
export GOAMD64="v2"
else
export GOAMD64="v1"
fi
fi
fi
echo "using x86_64 optimization level: $GOAMD64"
make nofuse
cmd/ipfs/ipfs commands completion bash > "$srcdir"/ipfs-completion.bash
### Patch service file ###
# set IPFS_PATH if not set by upstream already
sed -i '/StateDirectory=ipfs/,/ExecStart=\/usr\/bin\/ipfs daemon --init --migrate/c StateDirectory=ipfs\nEnvironment=IPFS_PATH=\~\nExecStart=\/usr\/bin\/ipfs daemon --init --migrate' "misc/systemd/ipfs-hardened.service"
# remove --init and --migrate (handled by install file)
sed -i 's/ExecStart=\/usr\/bin\/ipfs daemon /ExecStart=\/usr\/bin\/ipfs daemon /g' "misc/systemd/ipfs-hardened.service"
# enable gc and pubsub by default (sane defaults)
sed -i 's/ExecStart=\/usr\/bin\/ipfs daemon/ExecStart=\/usr\/bin\/ipfs daemon --enable-gc --enable-pubsub-experiment --enable-namesys-pubsub/g' "misc/systemd/ipfs-hardened.service"
# increase timeouts (see #7283)
sed -i 's/MemorySwapMax=0/MemorySwapMax=0\n\nTimeoutStopSec=15min\nTimeoutAbortSec=15min/' "misc/systemd/ipfs-hardened.service"
}
package() {
cd "$srcdir/$_pkgname"
install -Dm 755 cmd/ipfs/ipfs "$pkgdir/usr/bin/ipfs"
install -Dm 644 misc/systemd/ipfs-api.socket "$pkgdir/usr/lib/systemd/system/ipfs-api.socket"
install -Dm 644 misc/systemd/ipfs-gateway.socket "$pkgdir/usr/lib/systemd/system/ipfs-gateway.socket"
# use the hardened service file
install -Dm 644 misc/systemd/ipfs-hardened.service "$pkgdir/usr/lib/systemd/system/ipfs.service"
install -Dm 644 misc/systemd/ipfs-sysusers.conf "${pkgdir}/usr/lib/sysusers.d/ipfs.conf"
install -Dm 644 "$srcdir"/ipfs-completion.bash "$pkgdir/usr/share/bash-completion/completions/ipfs"
install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname/MIT" LICENSE-MIT
install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname/APACHE" LICENSE-APACHE
install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md
}
|