blob: d8c3377d4b41d37c33617d63676e7e24ec114afa (
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
153
154
155
|
# Maintainer: Claudia Pellegrino <aur ät cpellegrino.de>
pkgbase=attune
pkgname=(
'attune-cli'
'attune-controlplane'
)
pkgver=0.1.0
pkgrel=1
pkgdesc='Tool for publishing and hosting Linux packages'
arch=('x86_64')
url='https://github.com/attunehq/attune'
license=('Apache-2.0')
makedepends=('bzip2' 'cargo' 'go' 'postgresql')
checkdepends=('coreutils' 'procps-ng' 'openbsd-netcat' 'pifpaf' 'postgresql')
options=('!lto')
source=(
"${pkgbase}-${pkgver}.tar.gz::https://github.com/attunehq/attune/archive/v${pkgver}.tar.gz"
'attune-controlplane.service'
)
sha512sums=(
'6645c465cea68620dd6bdf3a224b03c268e7e3a99ce9892b566d69c0430473b072e540994e6913949e0fcc99a638d855dfdbc6d0d730adebf8d235b576b04c25'
'47babf31ba8cb3fbd15d04d8494a62596aad4ac7ebd17bab66f4af7eaf70af7f07e37bc345fa2d45693d81780f6d0bd37187feb85c042ebe6404ca40d8e2e3fd'
)
prepare() {
cd "${pkgbase}-${pkgver}"
mkdir -p cli/build
echo >&2 'Stripping configuration file'
awk > 'attune-controlplane.env' \
-e '/environment variables used by the CLI/ { exit }' \
-e '{ print }' \
'.env.example'
echo >&2 'Downloading dependencies'
export RUSTUP_TOOLCHAIN=stable
env -C controlplane cargo fetch \
--locked --target "$(rustc -vV | sed -n 's/host: //p')"
}
build() {
cd "${pkgbase}-${pkgver}"
echo >&2 'Building the CLI'
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
env -C cli go build -o build ./cmd/attune
echo >&2 'Building the control plane'
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
env -C controlplane cargo build --frozen --release --all-features
}
check() {
cd "${pkgbase}-${pkgver}"
echo >&2 'Testing the control plane'
export RUSTUP_TOOLCHAIN=stable
env -C controlplane cargo test --frozen --all-features
echo >&2 'Spawning a database instance for the control plane'
#shellcheck disable=SC2046 # Word splitting is what we actually want
eval $(pifpaf run postgresql --host localhost)
#shellcheck disable=SC2016 # Expansion not intended
timeout 30 bash -c 'until nc -z localhost ${PGPORT?}; do sleep 0.5; done'
echo >&2 'Initializing the database'
psql -v ON_ERROR_STOP=1 -f controlplane/migrations/*_init.sql
echo >&2 'Spawning the control plane'
ATTUNE_SECRET=attune \
ATTUNE_DATABASE_URL="${PIFPAF_POSTGRESQL_URL?}" \
controlplane/target/release/attune-controlplane &
timeout 30 bash -c 'until nc -z localhost 3000; do sleep 0.5; done'
echo >&2 'Testing the CLI'
ATTUNE_API_ENDPOINT=http://localhost:3000 \
cli/build/attune repo create -d sid -u 'http://localhost' \
> actual.txt || true
if ! grep -qF 'Created new repository:' actual.txt; then
printf >&2 '%s\n' 'Unexpected test output:' '==='
cat >&2 actual.txt
printf >&2 '\n%s\n' '==='
exit 1
fi
echo >&2 'Stopping the control plane'
pkill -f controlplane/target/release/attune-controlplane || true
echo >&2 'Stopping the database'
pifpaf_stop || true
}
# shellcheck disable=SC2128
package_attune-cli() {
pkgdesc='Command-line tool for publishing and hosting Linux packages'
depends=('glibc')
optdepends=('attune-controlplane: manage S3 buckets that contain repositories')
cd "${pkgbase}-${pkgver}"
echo >&2 'Packaging the executable'
install -D -m 755 -t "${pkgdir}/usr/bin" 'cli/build/attune'
echo >&2 'Packaging the documentation'
install -D -m 644 -t "${pkgdir}/usr/share/doc/${pkgname}" \
docs/user-guide/README.md
echo >&2 'Packaging the license'
install -D -m 644 -t "${pkgdir}/usr/share/licenses/${pkgname}" \
LICENSE
}
# shellcheck disable=SC2128
package_attune-controlplane() {
pkgdesc='Control plane for publishing and hosting Linux packages'
depends=('bzip2' 'gcc-libs' 'glibc' 'postgresql')
optdepends=('minio: S3-compatible backend to host packages locally')
install='attune-controlplane.install'
cd "${pkgbase}-${pkgver}"
echo >&2 'Packaging the executable'
install -D -m 755 -t "${pkgdir}/usr/bin" \
'controlplane/target/release/attune-controlplane'
echo >&2 'Packaging configuration'
install -D -m 644 -T 'attune-controlplane.env' \
"${pkgdir}/etc/default/attune-controlplane"
install -d -m 755 "${pkgdir}/etc/attune-controlplane.d"
echo >&2 'Packaging migration scripts'
install -d -m 755 "${pkgdir}/usr/share/${pkgname}"
cp -R --preserve=mode -t "${pkgdir}/usr/share/${pkgname}" \
controlplane/migrations
echo >&2 'Packaging the systemd unit file'
install -D -m 755 -t "${pkgdir}/usr/lib/systemd/system" \
'../attune-controlplane.service'
echo >&2 'Packaging the documentation'
install -D -m 644 -t "${pkgdir}/usr/share/doc/${pkgname}" \
docs/user-guide/README.md
echo >&2 'Packaging the license'
install -D -m 644 -t "${pkgdir}/usr/share/licenses/${pkgname}" \
LICENSE
}
|