summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorneoninteger2020-03-12 22:10:49 +1030
committerneoninteger2020-03-12 22:10:49 +1030
commitaffa6af06f4eea9062f89c34403b23212267e614 (patch)
tree4f561f45b6b04d61031ddd3e513d2a2c52666572
parentd127f1fec5e40683f186e680ca67c066799c45f6 (diff)
downloadaur-turtl-core-rs.tar.gz
Replace all hard tabs with spaces in PKGBUILD
Just so that I'm not using both in the same file. :)
-rw-r--r--PKGBUILD328
1 files changed, 164 insertions, 164 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 23e3da313c19..ee97fc375ff2 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -27,177 +27,177 @@ sha256sums=("71c1caf3aeb6245040abb0ee063b574dd6ece6314c60edabbe4299a11df49b68"
"a5985c5a5af81e59a6caf8eb4046dc7a4f581b50abe0fce7cffb1b3a07bd0d94")
prepare() {
- # This version of core-rs depends on an old version of rusqlite (v0.13.0)
- # which can't be built on current versions of Rust. This patch updates the
- # version of rusqlite used to v0.14.0, the first release to contain the
- # fix that allows it to compile again.
- patch -Np0 -i rusqlite.patch
-
- # Same with url - it needs to be updated from v1.6.0 to v1.7.2 in order to
- # fix build issues. For now, I chose not to go with the latest version due
- # to the potential for API-breaking changes that would require actual
- # patching on the core-rs source code. The correct fix would be for me to
- # learn Rust, update all of the dependencies for core-rs and then send that
- # as a pull request to its repository.
- patch -Np0 -i url.patch
+ # This version of core-rs depends on an old version of rusqlite (v0.13.0)
+ # which can't be built on current versions of Rust. This patch updates the
+ # version of rusqlite used to v0.14.0, the first release to contain the
+ # fix that allows it to compile again.
+ patch -Np0 -i rusqlite.patch
+
+ # Same with url - it needs to be updated from v1.6.0 to v1.7.2 in order to
+ # fix build issues. For now, I chose not to go with the latest version due
+ # to the potential for API-breaking changes that would require actual
+ # patching on the core-rs source code. The correct fix would be for me to
+ # learn Rust, update all of the dependencies for core-rs and then send that
+ # as a pull request to its repository.
+ patch -Np0 -i url.patch
}
build() {
- # Note: The OpenSSL binding library used by Turtl depends on OpenSSL v1.0,
- # here we specify variables to ensure that version 1.0 is used for
- # building, rather than v1.1 which is included in Arch-based systems and
- # used by default.
- export OPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0
- export OPENSSL_LIB_DIR=/usr/lib/openssl-1.0
-
- cd "core-rs-${_commithash}"
- cargo build --features sqlite-static --release
+ # Note: The OpenSSL binding library used by Turtl depends on OpenSSL v1.0,
+ # here we specify variables to ensure that version 1.0 is used for
+ # building, rather than v1.1 which is included in Arch-based systems and
+ # used by default.
+ export OPENSSL_INCLUDE_DIR=/usr/include/openssl-1.0
+ export OPENSSL_LIB_DIR=/usr/lib/openssl-1.0
+
+ cd "core-rs-${_commithash}"
+ cargo build --features sqlite-static --release
}
check() {
- cd "core-rs-${_commithash}"
-
- # NOTE: The integration tests need to link to the already-built turtl_core
- # library and used to do so automatically, however this does not work
- # anymore. Upstream bug or deprecated funtionality in Rust?
- # To work around this, we temporarily set LD_PRELOAD_PATH to the directory
- # containing turtl_core.so to allow the dynamic linking to occur.
- export LD_LIBRARY_PATH="${srcdir}/core-rs-${_commithash}/target/release:${LD_LIBRARY_PATH}"
-
- # Determine the capabilities of the terminal this script is running in
- reset="$(tput sgr0 2> /dev/null)"
- if [ "$?" -eq 0 ]; then
- bold="$(tput bold 2> /dev/null)"
-
- numColours="$(tput colors)"
- if [ "$numColours" -ge 8 ]; then
- blue="$(tput setaf 4)"
- fi
- fi
-
- # Echoes a blue arrow followed by a bolded log message, much like the
- # verbose printing that makepkg itself does
- log() {
- echo -e "${reset} ${bold}${blue}->${reset} ${bold}$@${reset}"
- }
-
- # Create the directories for the PostgreSQL database cluster, Turtl server
- # copy and Turtl server upload contents. Copy the core-rs and server
- # configuration files, initialize the database cluster and start a
- # PostgreSQL server instance within it.
- 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"
- }
-
- # Copy the Turtl server executable files into our temporary directory. This
- # allows us to run the server with our own configuration file rather than
- # having to patch a user-controlled configuration. Then create a user and
- # database for the Turtl server to use, populate this database with the
- # test suite data, and finally start running the Turtl server as a
- # background task. Sleep for 2 seconds to ensure the server is up before
- # continuing.
- 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
- mkdir plugins
- 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 the cargo test suite for core-rs.
- # Note: The 'migrate' test requires a deprecated Lisp-based Turtl server to
- # be running, in order to test how the client can migrate data from an old
- # server to a new NodeJS-based server. As the Lisp server is not run from
- # this PKGBUILD check() function, the test will fail. To work around this,
- # (at least for now) we just skip the test.
- run_tests() {
- log "Building and running unit tests..."
- cargo test --features sqlite-static --release -- --test-threads 1
-
- log "Building and running integration tests..."
- cd integration-tests
- cargo test --release -- --skip migrate
- cd ..
- }
-
- # Send SIGTERM to the Turtl server task to make it quit
- stop_turtl_server() {
- log "Stopping Turtl server..."
- kill %1
- }
-
- # Shut down the PostgreSQL server. There is a directory change in here just
- # in case the function was called as a result of an error during
- # configure_turtl_server() in which the directory is not the same as what
- # is expected here.
- stop_database() {
- cd "$srcdir/core-rs-${_commithash}"
- log "Stopping PostgreSQL server..."
- pg_ctl stop -D turtl-db
- }
-
- # Delete the created folders for the Turtl server and database, as they
- # are no longer necessary.
- remove_dirs() {
- log "Cleaning up..."
- rm -rf turtl-db turtl-server turtl-uploads config.yaml
- }
-
- # The default behaviour in makepkg is that, if a command returns with a
- # non-zero exit status, the script will stop execution and makepkg will
- # exit. This means that if a command such as 'make test-st' fails, the
- # script will exit before the database/Turtl servers have been shut down,
- # meaning they will keep running. By trapping errors like this, it is
- # possible to override makepkg's default behaviour and run the necessary
- # shutdown routines should a command fail. In the below examples, if an
- # error occurs during the configure_turtl_server() step (i.e. the
- # temporary directories and database cluster have been created, and the SQL
- # server is running) the proper shutdown routines are run from the trap to
- # stop the SQL server and clean up the directories.
-
- 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
+ cd "core-rs-${_commithash}"
+
+ # NOTE: The integration tests need to link to the already-built turtl_core
+ # library and used to do so automatically, however this does not work
+ # anymore. Upstream bug or deprecated funtionality in Rust?
+ # To work around this, we temporarily set LD_PRELOAD_PATH to the directory
+ # containing turtl_core.so to allow the dynamic linking to occur.
+ export LD_LIBRARY_PATH="${srcdir}/core-rs-${_commithash}/target/release:${LD_LIBRARY_PATH}"
+
+ # Determine the capabilities of the terminal this script is running in
+ reset="$(tput sgr0 2> /dev/null)"
+ if [ "$?" -eq 0 ]; then
+ bold="$(tput bold 2> /dev/null)"
+
+ numColours="$(tput colors)"
+ if [ "$numColours" -ge 8 ]; then
+ blue="$(tput setaf 4)"
+ fi
+ fi
+
+ # Echoes a blue arrow followed by a bolded log message, much like the
+ # verbose printing that makepkg itself does
+ log() {
+ echo -e "${reset} ${bold}${blue}->${reset} ${bold}$@${reset}"
+ }
+
+ # Create the directories for the PostgreSQL database cluster, Turtl server
+ # copy and Turtl server upload contents. Copy the core-rs and server
+ # configuration files, initialize the database cluster and start a
+ # PostgreSQL server instance within it.
+ 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"
+ }
+
+ # Copy the Turtl server executable files into our temporary directory. This
+ # allows us to run the server with our own configuration file rather than
+ # having to patch a user-controlled configuration. Then create a user and
+ # database for the Turtl server to use, populate this database with the
+ # test suite data, and finally start running the Turtl server as a
+ # background task. Sleep for 2 seconds to ensure the server is up before
+ # continuing.
+ 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
+ mkdir plugins
+ 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 the cargo test suite for core-rs.
+ # Note: The 'migrate' test requires a deprecated Lisp-based Turtl server to
+ # be running, in order to test how the client can migrate data from an old
+ # server to a new NodeJS-based server. As the Lisp server is not run from
+ # this PKGBUILD check() function, the test will fail. To work around this,
+ # (at least for now) we just skip the test.
+ run_tests() {
+ log "Building and running unit tests..."
+ cargo test --features sqlite-static --release -- --test-threads 1
+
+ log "Building and running integration tests..."
+ cd integration-tests
+ cargo test --release -- --skip migrate
+ cd ..
+ }
+
+ # Send SIGTERM to the Turtl server task to make it quit
+ stop_turtl_server() {
+ log "Stopping Turtl server..."
+ kill %1
+ }
+
+ # Shut down the PostgreSQL server. There is a directory change in here just
+ # in case the function was called as a result of an error during
+ # configure_turtl_server() in which the directory is not the same as what
+ # is expected here.
+ stop_database() {
+ cd "$srcdir/core-rs-${_commithash}"
+ log "Stopping PostgreSQL server..."
+ pg_ctl stop -D turtl-db
+ }
+
+ # Delete the created folders for the Turtl server and database, as they
+ # are no longer necessary.
+ remove_dirs() {
+ log "Cleaning up..."
+ rm -rf turtl-db turtl-server turtl-uploads config.yaml
+ }
+
+ # The default behaviour in makepkg is that, if a command returns with a
+ # non-zero exit status, the script will stop execution and makepkg will
+ # exit. This means that if a command such as 'make test-st' fails, the
+ # script will exit before the database/Turtl servers have been shut down,
+ # meaning they will keep running. By trapping errors like this, it is
+ # possible to override makepkg's default behaviour and run the necessary
+ # shutdown routines should a command fail. In the below examples, if an
+ # error occurs during the configure_turtl_server() step (i.e. the
+ # temporary directories and database cluster have been created, and the SQL
+ # server is running) the proper shutdown routines are run from the trap to
+ # stop the SQL server and clean up the directories.
+
+ 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"
+ cd "core-rs-${_commithash}"
+ install -Dm 755 target/release/libturtl_core.so -t "${pkgdir}/usr/lib"
}