diff --git a/.Changelog b/.Changelog new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.gitignore b/.gitignore index 1b784ae185b645cad42217c27e75097a63805af8..d5e8be93414643c4e477e7c5bfe98cd931e0ac46 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ build/ build.gcc/ build.clang/ bin/ +lektor/ +pkg/ +fake/ *.out *.o *.sqlt @@ -13,6 +16,9 @@ bin/ *.ycm_extra_conf.py *.orig *.vimrc +*.xz +*.tar +*.gz cscope.files cscope.out tags diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000000000000000000000000000000000000..c487010d7ff9c14f968afffc25661f213a152fa3 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,36 @@ +# Maintainer: Maël 'Kubat' MARTIN <mael.martin31@gmail.com> +pkgname=lektor +pkgver=mk7.818.a4f399d +pkgrel=1 +pkgdesc="The lektor kara player, from the Bakaclub" +arch=(x86_64 i686) +url="https://git.iiens.net/martin2018/lektor.git" +license=('ISC') +groups=(bakaclub) +depends=('sqlite3>=3.31.0' curl json-c xorg-server mpv sdl2) +makedepends=(git meson ninja bash 'gcc>=8.1') +provides=(lektor) +changelog=.Changelog +source=() + +pkgver() { + cd .. + echo "== pkgver from $(pwd)" >/dev/stderr + printf "mk7.%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +build() { + cd .. + echo "== build from $(pwd)" >/dev/stderr + mkdir build &>/dev/null || true + meson build/ || true + meson configure build/ -Dbuildtype=release -Ddebug=false -Doptimization=3 -Dstrip=true + meson configure build/ -Dprefix=$(pwd)/pkg/lektor + ninja -C build/ +} + +package() { + cd .. + echo "== package from $(pwd)" >/dev/stderr + ninja -C build/ install +} diff --git a/meson.build b/meson.build index 01938dca32d82323e268ea987ddfc04c39b0d4d4..1c1a4b81b61e81087debb4acf102526ac6e76c6e 100644 --- a/meson.build +++ b/meson.build @@ -85,7 +85,11 @@ mthread_deps = [ declare_dependency( link_with: static_library( 'mthread' generated_deps = [ declare_dependency( link_with: static_library( 'generated' , [ custom_target( 'sqlinit' , output: 'sqlinit.c' - , input: 'scripts/init.sql' + , input: 'src/database/disk.sql' + , command: [ find_program('xxd'), '-i', '@INPUT@', '@OUTPUT@' ] ) ] + , [ custom_target( 'sqlmemory' + , output: 'sqlmemory.c' + , input: 'src/database/memory.sql' , command: [ find_program('xxd'), '-i', '@INPUT@', '@OUTPUT@' ] ) ] , [ custom_target( 'manpath' , output: 'manpath.c' @@ -165,4 +169,4 @@ foreach man: man_files endforeach # Install -meson.add_install_script('scripts/install.sh') +# meson.add_install_script('scripts/install.sh') diff --git a/scripts/install.sh b/scripts/install.sh deleted file mode 100755 index 71fac2d1db4b2aa0633aff936f6e0e5af0409d92..0000000000000000000000000000000000000000 --- a/scripts/install.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -# Usefull things -alias die='exit 1' -if [[ $OSTYPE == "linux-gnu" ]] ; then alias sed="sed -i" ; fi -if [[ $OSTYPE == "darwin" ]] || [[ $OSTYPE == "freebsd"* ]] ; then alias sed="sed -i ''" ; fi -LKT_INI=$MESON_INSTALL_PREFIX/etc/lektor.ini - -# Verify lktadm -LKTADM=$MESON_INSTALL_PREFIX/bin/lktadm -type $LKTADM &>/dev/null -[ $? -ne 0 ] && echo "$LKTADM not found" && exit 1 - -# Install files -$LKTADM conf > $LKT_INI || die -sed "s+LKT_PREFIX+$MESON_INSTALL_PREFIX+g" $LKT_INI || die -mkdir /home/kara >&/dev/null || echo '/home/kara already exists' -$LKTADM source || die -$LKTADM init database || die diff --git a/scripts/init.sql b/src/database/disk.sql similarity index 100% rename from scripts/init.sql rename to src/database/disk.sql diff --git a/src/database/memory.sql b/src/database/memory.sql new file mode 100644 index 0000000000000000000000000000000000000000..5a36f3a9b1392b00d3ad6fe26525b5281602f96d --- /dev/null +++ b/src/database/memory.sql @@ -0,0 +1,36 @@ +-- This schema is used to initialize the in-memory database. + +-- Some notes about the queue_state table +-- - There's one and only row. +-- - `paused` 0 = play, 1 = paused +-- - `random` whether the queue is played randomly +-- - `repeat` whether the queue loops +-- - `single` whether only one kara loops +-- - `current` the position in the queue of the kara being played +-- - `elapsed` the number of seconds from the beginning of the current kara +-- - `duration` the total duration of the playing kara + +CREATE TABLE IF NOT EXISTS queue_state + ( id INTEGER PRIMARY KEY DEFAULT 42 CHECK(id = 42) + , volume INTEGER NOT NULL DEFAULT 100 CHECK(0 <= volume AND volume <= 100) + , paused INTEGER NOT NULL DEFAULT 1 + , random INTEGER NOT NULL DEFAULT 0 + , repeat INTEGER NOT NULL DEFAULT 0 + , single INTEGER NOT NULL DEFAULT 0 + , consume INTEGER NOT NULL DEFAULT 0 + , current INTEGER CHECK(current > 0) + , duration INTEGER CHECK(duration >= 0) + , elapsed INTEGER CHECK(elapsed >= 0) + ); + +INSERT INTO queue_state (id) VALUES (42); + + +-- Used to store the content of the ini configuration file. + +CREATE TABLE IF NOT EXISTS config + ( section TEXT NOT NULL + , key TEXT NOT NULL + , value TEXT + , PRIMARY KEY (section, key) + ) WITHOUT ROWID; diff --git a/src/database/open.c b/src/database/open.c index cb3cb0b17d30a6cef6fa7bb9dddca9f0afbeb642..4b84c39bd9850c5346f41bc08a2239c475369f00 100644 --- a/src/database/open.c +++ b/src/database/open.c @@ -7,40 +7,8 @@ #include <string.h> #include <strings.h> -/* Some notes: - - There's one and only row. - - `paused` 0 = play, 1 = paused - - `random` whether the queue is played randomly - - `repeat` whether the queue loops - - `single` whether only one kara loops - - `current` the position in the queue of the kara being played - - `elapsed` the number of seconds from the beginning of the current kara - - `duration` the total duration of the playing kara - This schema is used to initialize the in-memory database. */ -static const char *const SQL_MEM_SCHEM = - "CREATE TABLE IF NOT EXISTS queue_state" - " ( id INTEGER PRIMARY KEY DEFAULT 42 CHECK(id = 42)" - " , volume INTEGER NOT NULL DEFAULT 100 CHECK(0 <= volume AND volume <= 100)" - " , paused INTEGER NOT NULL DEFAULT 1" - " , random INTEGER NOT NULL DEFAULT 0" - " , repeat INTEGER NOT NULL DEFAULT 0" - " , single INTEGER NOT NULL DEFAULT 0" - " , consume INTEGER NOT NULL DEFAULT 0" - " , current INTEGER CHECK(current > 0)" - " , duration INTEGER CHECK(duration >= 0)" - " , elapsed INTEGER CHECK(elapsed >= 0)" - " );\n" - "INSERT INTO queue_state (id) VALUES (42);\n" - "CREATE TABLE IF NOT EXISTS config" - " ( section TEXT NOT NULL" - " , key TEXT NOT NULL" - " , value TEXT" - " , PRIMARY KEY (section, key)" - " ) WITHOUT ROWID;\n"; - -/* Should be, defined scripts_init_sql and its length scripts_init_sql_len */ -extern unsigned char ___scripts_init_sql[]; -extern int ___scripts_init_sql_len; +extern unsigned char ___src_database_disk_sql[]; +extern unsigned char ___src_database_memory_sql[]; #define INVALID_CHARS_DBPATH ":?!'\"" #define HEAP_LIMIT_SOFT 100 * 1024 * 1024 @@ -64,7 +32,7 @@ database_new(volatile sqlite3 **db) RETURN_IF(sqlite3_soft_heap_limit64(HEAP_LIMIT_SOFT) < 0, "Failed to set soft heap limit", false); RETURN_IF(sqlite3_hard_heap_limit64(HEAP_LIMIT_HARD) < 0, "Failed to set soft heap limit", false); RETURN_IF(SQLITE_OK != sqlite3_open_v2(":memory:", (sqlite3 **) db, flags, NULL), "Failed to open :memory:", false); - SQLITE_EXEC(*db, SQL_MEM_SCHEM, err_not_init); + SQLITE_EXEC(*db, (const char *) ___src_database_memory_sql, err_not_init); return true; err_not_init: *db = NULL; @@ -182,7 +150,7 @@ database_init(const char *dbpath) { sqlite3 *db; GOTO_IF(SQLITE_OK != sqlite3_open(dbpath, &db), "Failed to open the database", error); - SQLITE_EXEC(db, (const char *) ___scripts_init_sql, error); + SQLITE_EXEC(db, (const char *) ___src_database_disk_sql, error); LOG_INFO_SCT("DB", "Initialized the 'disk' database successfully, path was '%s'", dbpath); return true; error: diff --git a/src/main/lkt.c b/src/main/lkt.c index 915ccf3210031047bb1ee6cbc985b8a5b4413947..8ab454adb96e83f47c107f01ffd2efb5396a9049 100644 --- a/src/main/lkt.c +++ b/src/main/lkt.c @@ -306,8 +306,7 @@ ping__(struct lkt_cmd_args *args) fail("Failed to recieve the response of lektord"); if (!STR_NMATCH(buff, "OK", 2)) fail("ACK"); - write(1, "OK\n", sizeof("OK\n")); - exit(EXIT_SUCCESS); + exit(write(1, "OK\n", sizeof("OK\n")) > 0); } noreturn void diff --git a/src/main/lktadm.c b/src/main/lktadm.c index 78d00eb952b91342a822b58675804d961aa6ef64..009d93d6114d08fdbc84ff663dcc28edbd12bafe 100644 --- a/src/main/lktadm.c +++ b/src/main/lktadm.c @@ -25,8 +25,7 @@ fail(const char *format, ...) va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); - write(2, "\n", 1); - exit(EXIT_FAILURE); + exit(write(2, "\n", 1) > 0); } /* ----------------- *