diff options
author | OPNA2608 <christoph.neidahl@gmail.com> | 2023-10-14 12:32:13 +0200 |
---|---|---|
committer | OPNA2608 <christoph.neidahl@gmail.com> | 2023-12-23 22:45:19 +0100 |
commit | ff0f5bfb902c7a75caa159028d884232f428146f (patch) | |
tree | 645ab56694c7b1e78cb4e6edb7b739c9a9f7846e /pkgs/desktops | |
parent | 133fcea5230a888ddd8cabde086ebab7f193131f (diff) |
lomiri.history-service: init at 0.4
Diffstat (limited to 'pkgs/desktops')
4 files changed, 462 insertions, 0 deletions
diff --git a/pkgs/desktops/lomiri/default.nix b/pkgs/desktops/lomiri/default.nix index a7c560e205797..70caa9d644203 100644 --- a/pkgs/desktops/lomiri/default.nix +++ b/pkgs/desktops/lomiri/default.nix @@ -32,6 +32,7 @@ let #### Services biometryd = callPackage ./services/biometryd { }; hfd-service = callPackage ./services/hfd-service { }; + history-service = callPackage ./services/history-service { }; lomiri-download-manager = callPackage ./services/lomiri-download-manager { }; lomiri-url-dispatcher = callPackage ./services/lomiri-url-dispatcher { }; mediascanner2 = callPackage ./services/mediascanner2 { }; diff --git a/pkgs/desktops/lomiri/services/history-service/0001-Drop-deprecated-qt5_use_modules.patch b/pkgs/desktops/lomiri/services/history-service/0001-Drop-deprecated-qt5_use_modules.patch new file mode 100644 index 0000000000000..fee8093619b77 --- /dev/null +++ b/pkgs/desktops/lomiri/services/history-service/0001-Drop-deprecated-qt5_use_modules.patch @@ -0,0 +1,247 @@ +From 007e8cc4118869cab193d049db297bea3ee89269 Mon Sep 17 00:00:00 2001 +From: OPNA2608 <christoph.neidahl@gmail.com> +Date: Sun, 19 Feb 2023 22:39:14 +0100 +Subject: [PATCH] Drop deprecated qt5_use_modules + +Also seems broken on Nixpkgs, cannot pick up Qml (from qtdeclarative.dev). +--- + CMakeLists.txt | 1 + + Lomiri/History/CMakeLists.txt | 2 +- + cmake/modules/GenerateTest.cmake | 6 +++--- + daemon/CMakeLists.txt | 2 +- + plugins/sqlite/CMakeLists.txt | 2 +- + plugins/sqlite/schema/CMakeLists.txt | 2 +- + src/CMakeLists.txt | 2 +- + tests/Lomiri.History/CMakeLists.txt | 4 ++-- + tests/common/CMakeLists.txt | 4 ++-- + tests/common/mock/CMakeLists.txt | 2 +- + tests/libhistoryservice/CMakeLists.txt | 2 +- + tests/plugins/sqlite/CMakeLists.txt | 6 +++--- + tools/maketextevents/CMakeLists.txt | 2 +- + tools/makevoiceevents/CMakeLists.txt | 2 +- + tools/reader/CMakeLists.txt | 2 +- + 15 files changed, 21 insertions(+), 20 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e61fea5..a8e6417 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -18,6 +18,7 @@ find_package(Qt5Qml) + find_package(Qt5Quick) + find_package(Qt5Test) + find_package(Qt5Network) ++find_package(Qt5Sql) + find_package(LibPhoneNumber REQUIRED) + + include(qt5) +diff --git a/Lomiri/History/CMakeLists.txt b/Lomiri/History/CMakeLists.txt +index eb5e18e..cf20761 100644 +--- a/Lomiri/History/CMakeLists.txt ++++ b/Lomiri/History/CMakeLists.txt +@@ -36,7 +36,7 @@ include_directories( + + add_library(history-qml MODULE ${plugin_SRCS} ${plugin_HDRS}) + +-qt5_use_modules(history-qml Contacts Core Qml Quick) ++target_link_libraries(history-qml Qt5::Contacts Qt5::Core Qt5::Qml Qt5::Quick) + + target_link_libraries(history-qml + historyservice +diff --git a/cmake/modules/GenerateTest.cmake b/cmake/modules/GenerateTest.cmake +index 6cec32e..24615d1 100644 +--- a/cmake/modules/GenerateTest.cmake ++++ b/cmake/modules/GenerateTest.cmake +@@ -46,7 +46,7 @@ function(generate_test TESTNAME) + endif () + + if (NOT DEFINED ARG_QT5_MODULES) +- set(ARG_QT5_MODULES Core Test) ++ set(ARG_QT5_MODULES Qt5::Core Qt5::Test) + endif () + + if (${ARG_USE_UI}) +@@ -72,7 +72,7 @@ function(generate_test TESTNAME) + + # No QML test, regular binary compiled test. + add_executable(${TESTNAME} ${ARG_SOURCES}) +- qt5_use_modules(${TESTNAME} ${ARG_QT5_MODULES}) ++ target_link_libraries(${TESTNAME} ${ARG_QT5_MODULES}) + + if (${ARG_USE_DBUS}) + execute_process(COMMAND mktemp -d OUTPUT_VARIABLE TMPDIR) +@@ -136,7 +136,7 @@ function(generate_telepathy_test TESTNAME) + endif(NOT DEFINED ARG_LIBRARIES) + + if (NOT DEFINED ARG_QT5_MODULES) +- set(ARG_QT5_MODULES Core DBus Test Qml) ++ set(ARG_QT5_MODULES Qt5::Core Qt5::DBus Qt5::Test Qt5::Qml) + endif (NOT DEFINED ARG_QT5_MODULES) + generate_test(${TESTNAME} ${ARGN} + TASKS ${TASKS} +diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt +index d9493a1..791a362 100644 +--- a/daemon/CMakeLists.txt ++++ b/daemon/CMakeLists.txt +@@ -21,7 +21,7 @@ include_directories( + qt5_add_dbus_adaptor(daemon_SRCS HistoryService.xml historyservicedbus.h HistoryServiceDBus) + + add_executable(history-daemon ${daemon_SRCS} ${daemon_HDRS}) +-qt5_use_modules(history-daemon Core DBus) ++target_link_libraries(history-daemon Qt5::Core Qt5::DBus) + + target_link_libraries(history-daemon + ${TP_QT5_LIBRARIES} +diff --git a/plugins/sqlite/CMakeLists.txt b/plugins/sqlite/CMakeLists.txt +index 1a6fdfb..93bbe7a 100644 +--- a/plugins/sqlite/CMakeLists.txt ++++ b/plugins/sqlite/CMakeLists.txt +@@ -22,7 +22,7 @@ include_directories( + qt5_add_resources(plugin_RES sqlitehistoryplugin.qrc) + + add_library(sqlitehistoryplugin SHARED ${plugin_SRCS} ${plugin_HDRS} ${plugin_RES}) +-qt5_use_modules(sqlitehistoryplugin Core DBus Sql) ++target_link_libraries(sqlitehistoryplugin Qt5::Core Qt5::DBus Qt5::Sql) + + # update the .qrc file automatically when there are new schema files + file(GLOB QRC_RESOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/schema/*.sql ${CMAKE_CURRENT_SOURCE_DIR}/schema/*.info) +diff --git a/plugins/sqlite/schema/CMakeLists.txt b/plugins/sqlite/schema/CMakeLists.txt +index fc1530d..c35bfdf 100644 +--- a/plugins/sqlite/schema/CMakeLists.txt ++++ b/plugins/sqlite/schema/CMakeLists.txt +@@ -13,7 +13,7 @@ add_custom_command( + + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) + add_executable(generate_schema generate_schema.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../sqlitedatabase.cpp) +-qt5_use_modules(generate_schema Core DBus Sql) ++target_link_libraries(generate_schema Qt5::Core Qt5::DBus Qt5::Sql) + target_link_libraries(generate_schema historyservice ${SQLITE3_LIBRARIES}) + + add_custom_target(schema_update DEPENDS ${SCHEMA_FILE} ${VERSION_FILE}) +diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt +index 7e8dd69..4fca2db 100644 +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -101,7 +101,7 @@ set_target_properties(historyservice PROPERTIES + VERSION ${HISTORY_VERSION_MAJOR}.${HISTORY_VERSION_MINOR}.${HISTORY_VERSION_PATCH}) + + target_link_libraries(historyservice ${LibPhoneNumber_LIBRARIES} ${TP_QT5_LIBRARIES}) +-qt5_use_modules(historyservice Contacts Core DBus) ++target_link_libraries(historyservice Qt5::Contacts Qt5::Core Qt5::DBus) + + install(TARGETS historyservice DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +diff --git a/tests/Lomiri.History/CMakeLists.txt b/tests/Lomiri.History/CMakeLists.txt +index 615b772..7d3bd34 100644 +--- a/tests/Lomiri.History/CMakeLists.txt ++++ b/tests/Lomiri.History/CMakeLists.txt +@@ -41,7 +41,7 @@ set(HistoryGroupedThreadsModelTest_SOURCES + generate_test(HistoryGroupedThreadsModelTest + SOURCES ${HistoryGroupedThreadsModelTest_SOURCES} + LIBRARIES historyservice +- QT5_MODULES Core Qml Test ++ QT5_MODULES Qt5::Core Qt5::Qml Qt5::Test + USE_DBUS + USE_XVFB + TASKS --task ${CMAKE_BINARY_DIR}/daemon/history-daemon --ignore-return --task-name history-daemon +@@ -53,7 +53,7 @@ set(HistoryManagerTest_SOURCES + generate_test(HistoryManagerTest + SOURCES ${HistoryManagerTest_SOURCES} + LIBRARIES historyservice +- QT5_MODULES Core Qml Test ++ QT5_MODULES Qt5::Core Qt5::Qml Qt5::Test + USE_DBUS + USE_XVFB + TASKS --task ${CMAKE_BINARY_DIR}/daemon/history-daemon --ignore-return --task-name history-daemon +diff --git a/tests/common/CMakeLists.txt b/tests/common/CMakeLists.txt +index 0cc4bd9..cdf0203 100644 +--- a/tests/common/CMakeLists.txt ++++ b/tests/common/CMakeLists.txt +@@ -4,10 +4,10 @@ include_directories(${TP_QT5_INCLUDE_DIRS} + configure_file(dbus-session.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-session.conf) + + add_library(mockcontroller STATIC mockcontroller.cpp mockcontroller.h) +-qt5_use_modules(mockcontroller Core DBus) ++target_link_libraries(mockcontroller Qt5::Core Qt5::DBus) + + add_library(telepathytest STATIC telepathytest.cpp telepathytest.h) +-qt5_use_modules(telepathytest Core DBus) ++target_link_libraries(telepathytest Qt5::Core Qt5::DBus) + target_link_libraries(telepathytest ${TP_QT5_LIBRARIES}) + + add_subdirectory(mock) +diff --git a/tests/common/mock/CMakeLists.txt b/tests/common/mock/CMakeLists.txt +index acaf621..8e8b1b4 100644 +--- a/tests/common/mock/CMakeLists.txt ++++ b/tests/common/mock/CMakeLists.txt +@@ -15,5 +15,5 @@ set(mock_SRCS main.cpp protocol.cpp connection.cpp textchannel.cpp callchannel.c + qt5_add_dbus_adaptor(mock_SRCS MockConnection.xml mockconnectiondbus.h MockConnectionDBus) + + add_executable(telepathy-mock ${mock_SRCS}) +-qt5_use_modules(telepathy-mock Core DBus) ++target_link_libraries(telepathy-mock Qt5::Core Qt5::DBus) + target_link_libraries(telepathy-mock ${TP_QT5_LIBRARIES} ${TELEPATHY_QT5_SERVICE_LIBRARIES} ${OFONO_QT_LIBRARIES} ${PULSEAUDIO_LIBRARIES} ${Qt5Network_LIBRARIES}) +diff --git a/tests/libhistoryservice/CMakeLists.txt b/tests/libhistoryservice/CMakeLists.txt +index d96daa6..9f9a991 100644 +--- a/tests/libhistoryservice/CMakeLists.txt ++++ b/tests/libhistoryservice/CMakeLists.txt +@@ -40,4 +40,4 @@ generate_test(EventViewTest + # Telepathy-based tests + generate_telepathy_test(ContactMatcherTest + SOURCES ContactMatcherTest.cpp +- QT5_MODULES Core DBus Test Qml Contacts) ++ QT5_MODULES Qt5::Core Qt5::DBus Qt5::Test Qt5::Qml Qt5::Contacts) +diff --git a/tests/plugins/sqlite/CMakeLists.txt b/tests/plugins/sqlite/CMakeLists.txt +index f2bc520..c06f942 100644 +--- a/tests/plugins/sqlite/CMakeLists.txt ++++ b/tests/plugins/sqlite/CMakeLists.txt +@@ -4,6 +4,6 @@ include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ) + +-generate_test(SqlitePluginTest SOURCES SqlitePluginTest.cpp LIBRARIES historyservice sqlitehistoryplugin QT5_MODULES Core DBus Test Sql) +-generate_test(SqliteThreadViewTest SOURCES SqliteThreadViewTest.cpp LIBRARIES historyservice sqlitehistoryplugin QT5_MODULES Core DBus Test Sql) +-generate_test(SqliteEventViewTest SOURCES SqliteEventViewTest.cpp LIBRARIES historyservice sqlitehistoryplugin QT5_MODULES Core DBus Test Sql) ++generate_test(SqlitePluginTest SOURCES SqlitePluginTest.cpp LIBRARIES historyservice sqlitehistoryplugin QT5_MODULES Qt5::Core Qt5::DBus Qt5::Test Qt5::Sql) ++generate_test(SqliteThreadViewTest SOURCES SqliteThreadViewTest.cpp LIBRARIES historyservice sqlitehistoryplugin QT5_MODULES Qt5::Core Qt5::DBus Qt5::Test Qt5::Sql) ++generate_test(SqliteEventViewTest SOURCES SqliteEventViewTest.cpp LIBRARIES historyservice sqlitehistoryplugin QT5_MODULES Qt5::Core Qt5::DBus Qt5::Test Qt5::Sql) +diff --git a/tools/maketextevents/CMakeLists.txt b/tools/maketextevents/CMakeLists.txt +index e1d4e3e..c539bc5 100644 +--- a/tools/maketextevents/CMakeLists.txt ++++ b/tools/maketextevents/CMakeLists.txt +@@ -5,7 +5,7 @@ include_directories( + ) + + add_executable(history-maketextevents ${maketextevents_SRCS}) +-qt5_use_modules(history-maketextevents Core) ++target_link_libraries(history-maketextevents Qt5::Core) + + target_link_libraries(history-maketextevents historyservice) + install(TARGETS history-maketextevents RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +diff --git a/tools/makevoiceevents/CMakeLists.txt b/tools/makevoiceevents/CMakeLists.txt +index a8358bd..d5f4c49 100644 +--- a/tools/makevoiceevents/CMakeLists.txt ++++ b/tools/makevoiceevents/CMakeLists.txt +@@ -5,7 +5,7 @@ include_directories( + ) + + add_executable(history-makevoiceevents ${makevoiceevents_SRCS}) +-qt5_use_modules(history-makevoiceevents Core) ++target_link_libraries(history-makevoiceevents Qt5::Core) + + target_link_libraries(history-makevoiceevents historyservice) + install(TARGETS history-makevoiceevents RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +diff --git a/tools/reader/CMakeLists.txt b/tools/reader/CMakeLists.txt +index 220a7b6..00848bd 100644 +--- a/tools/reader/CMakeLists.txt ++++ b/tools/reader/CMakeLists.txt +@@ -5,6 +5,6 @@ include_directories( + ) + + add_executable(history-reader ${reader_SRCS}) +-qt5_use_modules(history-reader Core) ++target_link_libraries(history-reader Qt5::Core) + + target_link_libraries(history-reader historyservice) +-- +2.38.3 + diff --git a/pkgs/desktops/lomiri/services/history-service/default.nix b/pkgs/desktops/lomiri/services/history-service/default.nix new file mode 100644 index 0000000000000..b15bd17058bc8 --- /dev/null +++ b/pkgs/desktops/lomiri/services/history-service/default.nix @@ -0,0 +1,180 @@ +{ stdenv +, lib +, fetchFromGitLab +, fetchpatch +, gitUpdater +, testers +, cmake +, dbus +, dbus-test-runner +, dconf +, gnome +, libphonenumber +, libqtdbustest +, lomiri-api +, pkg-config +, protobuf +, qtbase +, qtdeclarative +, qtpim +, sqlite +, telepathy +, telepathy-mission-control +, wrapQtAppsHook +, xvfb-run +}: + +let + replaceDbusService = pkg: name: "--replace \"\\\${DBUS_SERVICES_DIR}/${name}\" \"${pkg}/share/dbus-1/services/${name}\""; +in +stdenv.mkDerivation (finalAttrs: { + pname = "history-service"; + version = "0.4"; + + src = fetchFromGitLab { + owner = "ubports"; + repo = "development/core/history-service"; + rev = finalAttrs.version; + hash = "sha256-oCX+moGQewzstbpddEYYp1kQdO2mVXpWJITfvzDzQDI="; + }; + + outputs = [ + "out" + "dev" + ]; + + patches = [ + # Deprecation warnings with Qt5.15, allow disabling -Werror + # Remove when version > 0.4 + (fetchpatch { + url = "https://gitlab.com/ubports/development/core/history-service/-/commit/1370777952c6a2efb85f582ff8ba085c2c0e290a.patch"; + hash = "sha256-Z/dFrFo7WoPZlKto6wNGeWdopsi8iBjmd5ycbqMKgxo="; + }) + ./0001-Drop-deprecated-qt5_use_modules.patch + ]; + + postPatch = '' + # Upstream's way of generating their schema doesn't work for us, don't quite understand why. + # (gdb) bt + # #0 QSQLiteResult::prepare (this=0x4a4650, query=...) at qsql_sqlite.cpp:406 + # #1 0x00007ffff344bcf4 in QSQLiteResult::reset (this=0x4a4650, query=...) at qsql_sqlite.cpp:378 + # #2 0x00007ffff7f95f39 in QSqlQuery::exec (this=this@entry=0x7fffffffaad8, query=...) at kernel/qsqlquery.cpp:406 + # #3 0x00000000004084cb in SQLiteDatabase::dumpSchema (this=<optimized out>) at /build/source/plugins/sqlite/sqlitedatabase.cpp:148 + # #4 0x0000000000406d70 in main (argc=<optimized out>, argv=<optimized out>) + # at /build/source/plugins/sqlite/schema/generate_schema.cpp:56 + # (gdb) p lastError().driverText().toStdString() + # $17 = {_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, + # _M_p = 0x4880d0 "Unable to execute statement"}, _M_string_length = 27, { + # _M_local_buf = "\033\000\000\000\000\000\000\000+\344\371\367\377\177\000", _M_allocated_capacity = 27}} + # (gdb) p lastError().databaseText().toStdString() + # $18 = {_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, + # _M_p = 0x48c480 "no such column: rowid"}, _M_string_length = 21, { + # _M_local_buf = "\025\000\000\000\000\000\000\000A\344\371\367\377\177\000", _M_allocated_capacity = 21}} + # + # This makes the tests stall indefinitely and breaks history-service usage. + # This replacement script should hopefully achieve the same / a similar-enough result with just sqlite + cp ${./update_schema.sh.in} plugins/sqlite/schema/update_schema.sh.in + + # libphonenumber -> protobuf -> abseil-cpp demands C++14 + # But uses std::string_view which is C++17? + substituteInPlace CMakeLists.txt \ + --replace '-std=c++11' '-std=c++17' + + # Uses pkg_get_variable, cannot substitute prefix with that + substituteInPlace daemon/CMakeLists.txt \ + --replace 'DESTINATION ''${SYSTEMD_USER_UNIT_DIR}' 'DESTINATION "${placeholder "out"}/lib/systemd/user"' + + # Queries qmake for the QML installation path, which returns a reference to Qt5's build directory + substituteInPlace CMakeLists.txt \ + --replace "\''${QMAKE_EXECUTABLE} -query QT_INSTALL_QML" "echo $out/${qtbase.qtQmlPrefix}" + + # Bad path concatenation + substituteInPlace config.h.in \ + --replace '@CMAKE_INSTALL_PREFIX@/@HISTORY_PLUGIN_PATH@' '@HISTORY_PLUGIN_PATH@' + + '' + (if finalAttrs.doCheck then '' + # Tests launch these DBus services, fix paths related to them + + substituteInPlace tests/common/dbus-services/CMakeLists.txt \ + ${replaceDbusService telepathy-mission-control "org.freedesktop.Telepathy.MissionControl5.service"} \ + ${replaceDbusService telepathy-mission-control "org.freedesktop.Telepathy.AccountManager.service"} \ + ${replaceDbusService dconf "ca.desrt.dconf.service"} + + substituteInPlace cmake/modules/GenerateTest.cmake \ + --replace '/usr/lib/dconf' '${lib.getLib dconf}/libexec' \ + --replace '/usr/lib/telepathy' '${lib.getLib telepathy-mission-control}/libexec' + '' else '' + sed -i CMakeLists.txt -e '/add_subdirectory(tests)/d' + ''); + + strictDeps = true; + + nativeBuildInputs = [ + cmake + pkg-config + sqlite + wrapQtAppsHook + ]; + + buildInputs = [ + libphonenumber + protobuf + qtbase + qtdeclarative + qtpim + telepathy + ]; + + nativeCheckInputs = [ + dbus + dbus-test-runner + dconf + gnome.gnome-keyring + telepathy-mission-control + xvfb-run + ]; + + cmakeFlags = [ + # Many deprecation warnings with Qt 5.15 + "-DENABLE_WERROR=OFF" + ]; + + preBuild = '' + # SQLiteDatabase is used on host to generate SQL schemas + # Tests also need this to use SQLiteDatabase for verifying correct behaviour + export QT_PLUGIN_PATH=${lib.getBin qtbase}/${qtbase.qtPluginPrefix} + ''; + + doCheck = stdenv.buildPlatform.canExecute stdenv.hostPlatform; + + # Starts & talks to D-Bus services, breaks with parallelism + enableParallelChecking = false; + + preCheck = '' + export QT_PLUGIN_PATH=${lib.getBin qtpim}/${qtbase.qtPluginPrefix}:$QT_PLUGIN_PATH + export HOME=$PWD + ''; + + passthru = { + tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + updateScript = gitUpdater { }; + }; + + meta = with lib; { + description = "Service that provides call log and conversation history"; + longDescription = '' + History service provides the database and an API to store/retrieve the call log (used by dialer-app) and the sms/mms history (used by messaging-app). + + See as well telepathy-ofono for incoming message events. + + Database location: ~/.local/share/history-service/history.sqlite + ''; + homepage = "https://gitlab.com/ubports/development/core/history-service"; + license = licenses.gpl3Only; + maintainers = teams.lomiri.members; + platforms = platforms.linux; + pkgConfigModules = [ + "history-service" + ]; + }; +}) diff --git a/pkgs/desktops/lomiri/services/history-service/update_schema.sh.in b/pkgs/desktops/lomiri/services/history-service/update_schema.sh.in new file mode 100644 index 0000000000000..3911c59ebe3ad --- /dev/null +++ b/pkgs/desktops/lomiri/services/history-service/update_schema.sh.in @@ -0,0 +1,34 @@ +#!/bin/sh + +if [ $# -lt 3 ]; then + echo "Usage: $0 <source directory> <target file> <version info file>" + exit 1 +fi + +SOURCE_DIR=$1 +TARGET_FILE=$2 +VERSION_FILE=$3 + +VERSION="1" +LATEST_VERSION="1" +MERGED_COMMANDS="merged.sql" + +[ -e $MERGED_COMMANDS ] && rm $MERGED_COMMANDS +SCHEMA_FILE="$SOURCE_DIR/v${VERSION}.sql" +while [ -e $SCHEMA_FILE ]; do + cat $SCHEMA_FILE >> $MERGED_COMMANDS + LATEST_VERSION=$VERSION + VERSION=$(($VERSION+1)) + SCHEMA_FILE="$SOURCE_DIR/v${VERSION}.sql" +done + +# To output the schema +echo ".fullschema" >> $MERGED_COMMANDS + +# The schemas may use functions that history-service defines in C which don't affect the generated schema in a meaningful way. +# sqlite will return an error after processing queries with such function calls, so remove them. +sed -i -e '/normalizeId(/d' $MERGED_COMMANDS + +sqlite3 <$MERGED_COMMANDS >$TARGET_FILE + +echo $LATEST_VERSION > $VERSION_FILE |