blob: 9f13360235f7c5d741c9afe84341c0ee443dc40f (
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
|
# Maintainer: Callum Parsey <neoninteger@protonmail.com>
pkgname=turtl-core-rs
pkgver=0.1.2
pkgrel=2
pkgdesc="Turtl's logic core, built in Rust"
arch=("i686" "x86_64")
url="https://github.com/turtl/core-rs"
license=("GPL3")
depends=("libsodium" "openssl-1.0")
makedepends=("rust")
checkdepends=("turtl-server")
# Note: Turtl core-rs is versioned but not with Git tags or releases, the only
# way to download a specific core-rs version is using a commit hash that
# contains modifications to the CHANGELOG.md file.
_commithash="774fa361d021d9ef5237d32d09515ab7b2a32ad2"
source=("https://github.com/turtl/core-rs/archive/${_commithash}.tar.gz"
"config-client.yaml"
"config-server.yaml"
"vars.mk")
sha256sums=("71c1caf3aeb6245040abb0ee063b574dd6ece6314c60edabbe4299a11df49b68"
"f5400e9c80c935915212e818f05eab8d3d542a54ed89e153c20a6c0fa00d8e1a"
"ef42f08759af7ce12a06ba168877e74835e1bcdc2c4dca3aea9435b5983961e2"
"8dd67ffa28f833baa88c57ecabcc0c5e020d53b5a5516034478a0883be29193d")
prepare() {
cp vars.mk "core-rs-${_commithash}"
}
build() {
cd "core-rs-${_commithash}"
make release
}
check() {
cd "core-rs-${_commithash}"
log() {
echo -e " $(tput setaf 4)$(tput bold)->$(tput sgr0) $(tput bold)$@$(tput sgr0)"
}
init_database() {
log "Creating directories and copying configuration files..."
mkdir turtl-db turtl-server turtl-server/config turtl-uploads
cp ../config-client.yaml config.yaml
cp ../config-server.yaml turtl-server/config/config.yaml
log "Initializing PostgreSQL database cluster..."
initdb -D turtl-db -A trust
log "Starting PostgreSQL server..."
pg_ctl start -D turtl-db -o "-c unix_socket_directories=/tmp"
}
configure_turtl_server() {
log "Copying Turtl server files..."
cd turtl-server
cp -r /usr/share/webapps/turtl/controllers controllers
cp -r /usr/share/webapps/turtl/helpers helpers
cp -r /usr/share/webapps/turtl/models models
cp -r /usr/share/webapps/turtl/node_modules node_modules
cp -r /usr/share/webapps/turtl/scripts scripts
cp -r /usr/share/webapps/turtl/tools tools
cp /usr/share/webapps/turtl/server.js server.js
log "Configuring database for Turtl server..."
psql -h /tmp -d postgres -c "CREATE USER turtl WITH PASSWORD 'turtl'"
psql -h /tmp -d postgres -c "CREATE DATABASE turtl"
scripts/init-db.sh
node tools/populate-test-data.js
log "Starting Turtl server..."
node server.js &
sleep 2
cd ..
}
run_tests() {
log "Running tests..."
make test-st
}
stop_turtl_server() {
log "Stopping Turtl server..."
kill %1
}
stop_database() {
cd "$srcdir/core-rs-${_commithash}"
log "Stopping PostgreSQL server..."
pg_ctl stop -D turtl-db
}
remove_dirs() {
log "Cleaning up..."
rm -rf turtl-db turtl-server turtl-uploads config.yaml
}
trap "remove_dirs" ERR
init_database
trap - ERR
trap "stop_database; remove_dirs" ERR
configure_turtl_server
trap - ERR
trap "stop_turtl_server; stop_database; remove_dirs" ERR
run_tests
trap - ERR
stop_turtl_server
stop_database
remove_dirs
}
package() {
cd "core-rs-${_commithash}"
install -Dm 755 target/release/libturtl_core.so -t "${pkgdir}/usr/lib"
}
|