update
This commit is contained in:
@@ -14,4 +14,5 @@
|
||||
csharp-ls-8 = pkgs.callPackage ./csharp-lsp/default.nix { };
|
||||
gpu-screen-recorder-ui = pkgs.callPackage ./gpu-screen-recorder-ui/default.nix { };
|
||||
gpu-screen-recorder-notification = pkgs.callPackage ./gpu-screen-recorder-notification/default.nix { };
|
||||
kavita-old = pkgs.callPackage ./kavita-old/default.nix { };
|
||||
}
|
||||
|
||||
79
pkgs/kavita-old/change-webroot.diff
Normal file
79
pkgs/kavita-old/change-webroot.diff
Normal file
@@ -0,0 +1,79 @@
|
||||
diff --git a/API/Controllers/FallbackController.cs b/API/Controllers/FallbackController.cs
|
||||
index 0c92547..d54abb9 100644
|
||||
--- a/API/Controllers/FallbackController.cs
|
||||
+++ b/API/Controllers/FallbackController.cs
|
||||
@@ -22,7 +22,7 @@ public class FallbackController : Controller
|
||||
|
||||
public PhysicalFileResult Index()
|
||||
{
|
||||
- return PhysicalFile(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "index.html"), "text/HTML");
|
||||
+ return PhysicalFile(Path.Combine("@webroot@", "index.html"), "text/HTML");
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/API/Services/DirectoryService.cs b/API/Services/DirectoryService.cs
|
||||
index 8c6c796..711f315 100644
|
||||
--- a/API/Services/DirectoryService.cs
|
||||
+++ b/API/Services/DirectoryService.cs
|
||||
@@ -120,7 +120,7 @@ public class DirectoryService : IDirectoryService
|
||||
ExistOrCreate(SiteThemeDirectory);
|
||||
FaviconDirectory = FileSystem.Path.Join(FileSystem.Directory.GetCurrentDirectory(), "config", "favicons");
|
||||
ExistOrCreate(FaviconDirectory);
|
||||
- LocalizationDirectory = FileSystem.Path.Join(FileSystem.Directory.GetCurrentDirectory(), "I18N");
|
||||
+ LocalizationDirectory = FileSystem.Path.Join("@out@/lib/kavita-backend", "I18N");
|
||||
CustomizedTemplateDirectory = FileSystem.Path.Join(FileSystem.Directory.GetCurrentDirectory(), "config", "templates");
|
||||
ExistOrCreate(CustomizedTemplateDirectory);
|
||||
TemplateDirectory = FileSystem.Path.Join(FileSystem.Directory.GetCurrentDirectory(), "EmailTemplates");
|
||||
diff --git a/API/Services/LocalizationService.cs b/API/Services/LocalizationService.cs
|
||||
index ab3ad3d..f1a068b 100644
|
||||
--- a/API/Services/LocalizationService.cs
|
||||
+++ b/API/Services/LocalizationService.cs
|
||||
@@ -52,8 +52,7 @@ public class LocalizationService : ILocalizationService
|
||||
else
|
||||
{
|
||||
_localizationDirectoryUi = directoryService.FileSystem.Path.Join(
|
||||
- directoryService.FileSystem.Directory.GetCurrentDirectory(),
|
||||
- "wwwroot", "assets/langs");
|
||||
+ "@webroot@", "assets/langs");
|
||||
}
|
||||
|
||||
_cacheOptions = new MemoryCacheEntryOptions()
|
||||
diff --git a/API/Startup.cs b/API/Startup.cs
|
||||
index 7e3857c..84c466b 100644
|
||||
--- a/API/Startup.cs
|
||||
+++ b/API/Startup.cs
|
||||
@@ -36,6 +36,7 @@ using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
+using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
@@ -314,9 +315,6 @@ public class Startup
|
||||
app.UsePathBase(basePath);
|
||||
if (!env.IsDevelopment())
|
||||
{
|
||||
- // We don't update the index.html in local as we don't serve from there
|
||||
- UpdateBaseUrlInIndex(basePath);
|
||||
-
|
||||
// Update DB with what's in config
|
||||
var dataContext = serviceProvider.GetRequiredService<DataContext>();
|
||||
var setting = dataContext.ServerSetting.SingleOrDefault(x => x.Key == ServerSettingKey.BaseUrl);
|
||||
@@ -360,6 +358,7 @@ public class Startup
|
||||
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
+ FileProvider = new PhysicalFileProvider("@webroot@"),
|
||||
// bcmap files needed for PDF reader localizations (https://github.com/Kareadita/Kavita/issues/2970)
|
||||
ContentTypeProvider = new FileExtensionContentTypeProvider
|
||||
{
|
||||
@@ -439,7 +438,7 @@ public class Startup
|
||||
try
|
||||
{
|
||||
var htmlDoc = new HtmlDocument();
|
||||
- var indexHtmlPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "index.html");
|
||||
+ var indexHtmlPath = Path.Combine("@webroot@", "index.html");
|
||||
htmlDoc.Load(indexHtmlPath);
|
||||
|
||||
var baseNode = htmlDoc.DocumentNode.SelectSingleNode("/html/head/base");
|
||||
103
pkgs/kavita-old/default.nix
Normal file
103
pkgs/kavita-old/default.nix
Normal file
@@ -0,0 +1,103 @@
|
||||
{
|
||||
lib,
|
||||
stdenvNoCC,
|
||||
fetchFromGitHub,
|
||||
fetchpatch2,
|
||||
buildDotnetModule,
|
||||
buildNpmPackage,
|
||||
dotnetCorePackages,
|
||||
nixosTests,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "kavita";
|
||||
version = "0.8.5.11";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "kareadita";
|
||||
repo = "kavita";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-HSVdEB0yhmm/SZseHQ5kTRBaVqCZZx934Ovq1pTmQkM=";
|
||||
};
|
||||
|
||||
backend = buildDotnetModule {
|
||||
pname = "kavita-backend";
|
||||
inherit (finalAttrs) version src;
|
||||
|
||||
patches = [
|
||||
# The webroot is hardcoded as ./wwwroot
|
||||
./change-webroot.diff
|
||||
# Upstream removes database migrations between versions
|
||||
# Restore them to avoid breaking on updates
|
||||
# Info: Restores migrations for versions between v0.7.1.4 and v0.7.9
|
||||
# On update: check if more migrations need to be restored!
|
||||
# Migrations should at least allow updates from previous NixOS versions
|
||||
./restore-migrations.diff
|
||||
# Our nixos test depends on /api/locale; this patch fixes an upstream bug where the first response always fails
|
||||
# https://github.com/Kareadita/Kavita/pull/3686 remove once upstream is fixed
|
||||
(fetchpatch2 {
|
||||
name = "fix-locale-cache.patch";
|
||||
url = "https://github.com/Kareadita/Kavita/commit/5af07b9525c2164a6548092244bbdf66815b3e95.patch?full_index=1";
|
||||
hash = "sha256-aFZRxijAbA2mXJM+3kC4P4p76d0p5fEXLiaRhNmjOAA=";
|
||||
})
|
||||
];
|
||||
postPatch = ''
|
||||
substituteInPlace API/Services/DirectoryService.cs --subst-var out
|
||||
|
||||
substituteInPlace API/Startup.cs API/Services/LocalizationService.cs API/Controllers/FallbackController.cs \
|
||||
--subst-var-by webroot "${finalAttrs.frontend}/lib/node_modules/kavita-webui/dist/browser"
|
||||
'';
|
||||
|
||||
executables = [ "API" ];
|
||||
|
||||
projectFile = "API/API.csproj";
|
||||
nugetDeps = ./nuget-deps.json;
|
||||
dotnet-sdk = dotnetCorePackages.sdk_9_0;
|
||||
dotnet-runtime = dotnetCorePackages.aspnetcore_9_0;
|
||||
};
|
||||
|
||||
frontend = buildNpmPackage {
|
||||
pname = "kavita-frontend";
|
||||
inherit (finalAttrs) version src;
|
||||
|
||||
sourceRoot = "${finalAttrs.src.name}/UI/Web";
|
||||
|
||||
npmBuildScript = "prod";
|
||||
npmFlags = [ "--legacy-peer-deps" ];
|
||||
npmRebuildFlags = [ "--ignore-scripts" ]; # Prevent playwright from trying to install browsers
|
||||
npmDepsHash = "sha256-9SfiH567+q3Id6/7pqWeX0y934V2YFQ4EWIJ+66smgI=";
|
||||
};
|
||||
|
||||
dontBuild = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin $out/lib/kavita
|
||||
ln -s $backend/lib/kavita-backend $out/lib/kavita/backend
|
||||
ln -s $frontend/lib/node_modules/kavita-webui/dist $out/lib/kavita/frontend
|
||||
ln -s $backend/bin/API $out/bin/kavita
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
tests = {
|
||||
inherit (nixosTests) kavita;
|
||||
};
|
||||
updateScript = ./update.sh;
|
||||
};
|
||||
|
||||
meta = {
|
||||
description = "Fast, feature rich, cross platform reading server";
|
||||
homepage = "https://kavitareader.com";
|
||||
changelog = "https://github.com/kareadita/kavita/releases/tag/${finalAttrs.src.rev}";
|
||||
license = lib.licenses.gpl3Only;
|
||||
platforms = lib.platforms.linux;
|
||||
maintainers = with lib.maintainers; [
|
||||
misterio77
|
||||
nevivurn
|
||||
];
|
||||
mainProgram = "kavita";
|
||||
};
|
||||
})
|
||||
1732
pkgs/kavita-old/nuget-deps.json
Normal file
1732
pkgs/kavita-old/nuget-deps.json
Normal file
File diff suppressed because it is too large
Load Diff
147
pkgs/kavita-old/restore-migrations.diff
Normal file
147
pkgs/kavita-old/restore-migrations.diff
Normal file
@@ -0,0 +1,147 @@
|
||||
diff --git a/API/Data/ManualMigrations/MigrateDisableScrobblingOnComicLibraries.cs b/API/Data/ManualMigrations/MigrateDisableScrobblingOnComicLibraries.cs
|
||||
new file mode 100644
|
||||
index 00000000..0de7bf5d
|
||||
--- /dev/null
|
||||
+++ b/API/Data/ManualMigrations/MigrateDisableScrobblingOnComicLibraries.cs
|
||||
@@ -0,0 +1,38 @@
|
||||
+using System.Linq;
|
||||
+using System.Threading.Tasks;
|
||||
+using API.Entities.Enums;
|
||||
+using Microsoft.EntityFrameworkCore;
|
||||
+using Microsoft.Extensions.Logging;
|
||||
+
|
||||
+namespace API.Data.ManualMigrations;
|
||||
+
|
||||
+/// <summary>
|
||||
+/// v0.7.4 introduced Scrobbling with Kavita+. By default, it is on, but Comic libraries have no scrobble providers, so disable
|
||||
+/// </summary>
|
||||
+public static class MigrateDisableScrobblingOnComicLibraries
|
||||
+{
|
||||
+ public static async Task Migrate(IUnitOfWork unitOfWork, DataContext dataContext, ILogger<Program> logger)
|
||||
+ {
|
||||
+ if (!await dataContext.Library.Where(s => s.Type == LibraryType.Comic).Where(l => l.AllowScrobbling).AnyAsync())
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ logger.LogInformation("Running MigrateDisableScrobblingOnComicLibraries migration. Please be patient, this may take some time");
|
||||
+
|
||||
+
|
||||
+ foreach (var lib in await dataContext.Library.Where(s => s.Type == LibraryType.Comic).Where(l => l.AllowScrobbling).ToListAsync())
|
||||
+ {
|
||||
+ lib.AllowScrobbling = false;
|
||||
+ unitOfWork.LibraryRepository.Update(lib);
|
||||
+ }
|
||||
+
|
||||
+ if (unitOfWork.HasChanges())
|
||||
+ {
|
||||
+ await unitOfWork.CommitAsync();
|
||||
+ }
|
||||
+
|
||||
+ logger.LogInformation("MigrateDisableScrobblingOnComicLibraries migration finished");
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/API/Data/ManualMigrations/MigrateLoginRoles.cs b/API/Data/ManualMigrations/MigrateLoginRoles.cs
|
||||
new file mode 100644
|
||||
index 00000000..f649908a
|
||||
--- /dev/null
|
||||
+++ b/API/Data/ManualMigrations/MigrateLoginRoles.cs
|
||||
@@ -0,0 +1,36 @@
|
||||
+using System.Threading.Tasks;
|
||||
+using API.Constants;
|
||||
+using API.Entities;
|
||||
+using Microsoft.AspNetCore.Identity;
|
||||
+using Microsoft.Extensions.Logging;
|
||||
+
|
||||
+namespace API.Data.ManualMigrations;
|
||||
+
|
||||
+/// <summary>
|
||||
+/// Added in v0.7.1.18
|
||||
+/// </summary>
|
||||
+public static class MigrateLoginRoles
|
||||
+{
|
||||
+ /// <summary>
|
||||
+ /// Will not run if any users have the <see cref="PolicyConstants.LoginRole"/> role already
|
||||
+ /// </summary>
|
||||
+ /// <param name="unitOfWork"></param>
|
||||
+ /// <param name="userManager"></param>
|
||||
+ /// <param name="logger"></param>
|
||||
+ public static async Task Migrate(IUnitOfWork unitOfWork, UserManager<AppUser> userManager, ILogger<Program> logger)
|
||||
+ {
|
||||
+ var usersWithRole = await userManager.GetUsersInRoleAsync(PolicyConstants.LoginRole);
|
||||
+ if (usersWithRole.Count != 0) return;
|
||||
+
|
||||
+ logger.LogCritical("Running MigrateLoginRoles migration");
|
||||
+
|
||||
+ var allUsers = await unitOfWork.UserRepository.GetAllUsersAsync();
|
||||
+ foreach (var user in allUsers)
|
||||
+ {
|
||||
+ await userManager.RemoveFromRoleAsync(user, PolicyConstants.LoginRole);
|
||||
+ await userManager.AddToRoleAsync(user, PolicyConstants.LoginRole);
|
||||
+ }
|
||||
+
|
||||
+ logger.LogInformation("MigrateLoginRoles migration complete");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/API/Data/ManualMigrations/MigrateRemoveWebPSettingRows.cs b/API/Data/ManualMigrations/MigrateRemoveWebPSettingRows.cs
|
||||
new file mode 100644
|
||||
index 00000000..07e98ef6
|
||||
--- /dev/null
|
||||
+++ b/API/Data/ManualMigrations/MigrateRemoveWebPSettingRows.cs
|
||||
@@ -0,0 +1,31 @@
|
||||
+using System.Threading.Tasks;
|
||||
+using API.Entities.Enums;
|
||||
+using Microsoft.Extensions.Logging;
|
||||
+
|
||||
+namespace API.Data.ManualMigrations;
|
||||
+
|
||||
+/// <summary>
|
||||
+/// Added in v0.7.2.7/v0.7.3 in which the ConvertXToWebP Setting keys were removed. This migration will remove them.
|
||||
+/// </summary>
|
||||
+public static class MigrateRemoveWebPSettingRows
|
||||
+{
|
||||
+ public static async Task Migrate(IUnitOfWork unitOfWork, ILogger<Program> logger)
|
||||
+ {
|
||||
+ logger.LogCritical("Running MigrateRemoveWebPSettingRows migration - Please be patient, this may take some time. This is not an error");
|
||||
+
|
||||
+ var key = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.ConvertBookmarkToWebP);
|
||||
+ var key2 = await unitOfWork.SettingsRepository.GetSettingAsync(ServerSettingKey.ConvertCoverToWebP);
|
||||
+ if (key == null && key2 == null)
|
||||
+ {
|
||||
+ logger.LogCritical("Running MigrateRemoveWebPSettingRows migration - complete. Nothing to do");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ unitOfWork.SettingsRepository.Remove(key);
|
||||
+ unitOfWork.SettingsRepository.Remove(key2);
|
||||
+
|
||||
+ await unitOfWork.CommitAsync();
|
||||
+
|
||||
+ logger.LogCritical("Running MigrateRemoveWebPSettingRows migration - Completed. This is not an error");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/API/Startup.cs b/API/Startup.cs
|
||||
index 21c4fa45..04f4a077 100644
|
||||
--- a/API/Startup.cs
|
||||
+++ b/API/Startup.cs
|
||||
@@ -232,11 +232,19 @@ public class Startup
|
||||
Task.Run(async () =>
|
||||
{
|
||||
// Apply all migrations on startup
|
||||
+ var userManager = serviceProvider.GetRequiredService<UserManager<AppUser>>();
|
||||
var dataContext = serviceProvider.GetRequiredService<DataContext>();
|
||||
|
||||
|
||||
logger.LogInformation("Running Migrations");
|
||||
|
||||
+ // v0.7.2
|
||||
+ await MigrateLoginRoles.Migrate(unitOfWork, userManager, logger);
|
||||
+ // v0.7.3
|
||||
+ await MigrateRemoveWebPSettingRows.Migrate(unitOfWork, logger);
|
||||
+ // v0.7.4
|
||||
+ await MigrateDisableScrobblingOnComicLibraries.Migrate(unitOfWork, dataContext, logger);
|
||||
+
|
||||
// v0.7.9
|
||||
await MigrateUserLibrarySideNavStream.Migrate(unitOfWork, dataContext, logger);
|
||||
|
||||
20
pkgs/kavita-old/update.sh
Executable file
20
pkgs/kavita-old/update.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#! nix-shell -i bash -p common-updater-scripts curl jq nix-prefetch-github prefetch-npm-deps
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
latest_version=$(curl -s https://api.github.com/repos/Kareadita/Kavita/releases/latest | jq -r '.tag_name' | tr -d v)
|
||||
|
||||
pushd "$(mktemp -d)"
|
||||
curl -s https://raw.githubusercontent.com/Kareadita/Kavita/v${latest_version}/UI/Web/package-lock.json -o package-lock.json
|
||||
npmDepsHash=$(prefetch-npm-deps package-lock.json)
|
||||
rm -f package-lock.json
|
||||
popd
|
||||
|
||||
update-source-version kavita "$latest_version"
|
||||
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")"
|
||||
sed -E 's#\bnpmDepsHash = ".*?"#npmDepsHash = "'"$npmDepsHash"'"#' -i default.nix
|
||||
popd
|
||||
|
||||
$(nix-build -A kavita.backend.fetch-deps --no-out-link)
|
||||
Reference in New Issue
Block a user