commit
983d38a43b
@ -1,8 +1,59 @@
|
||||
srpm:
|
||||
dnf -y install git
|
||||
git submodule update --init --recursive
|
||||
cd deployment/fedora-package-x64; \
|
||||
./create_tarball.sh; \
|
||||
rpmbuild -bs pkg-src/jellyfin.spec \
|
||||
--define "_sourcedir $$PWD/pkg-src/" \
|
||||
--define "_srcrpmdir $(outdir)"
|
||||
VERSION := $(shell sed -ne '/^Version:/s/.* *//p' \
|
||||
deployment/fedora-package-x64/pkg-src/jellyfin.spec)
|
||||
|
||||
deployment/fedora-package-x64/pkg-src/jellyfin-web-$(VERSION).tar.gz:
|
||||
curl -f -L -o deployment/fedora-package-x64/pkg-src/jellyfin-web-$(VERSION).tar.gz \
|
||||
https://github.com/jellyfin/jellyfin-web/archive/v$(VERSION).tar.gz \
|
||||
|| curl -f -L -o deployment/fedora-package-x64/pkg-src/jellyfin-web-$(VERSION).tar.gz \
|
||||
https://github.com/jellyfin/jellyfin-web/archive/master.tar.gz \
|
||||
|
||||
srpm: deployment/fedora-package-x64/pkg-src/jellyfin-web-$(VERSION).tar.gz
|
||||
cd deployment/fedora-package-x64; \
|
||||
SOURCE_DIR=../.. \
|
||||
WORKDIR="$${PWD}"; \
|
||||
package_temporary_dir="$${WORKDIR}/pkg-dist-tmp"; \
|
||||
pkg_src_dir="$${WORKDIR}/pkg-src"; \
|
||||
GNU_TAR=1; \
|
||||
tar \
|
||||
--transform "s,^\.,jellyfin-$(VERSION)," \
|
||||
--exclude='.git*' \
|
||||
--exclude='**/.git' \
|
||||
--exclude='**/.hg' \
|
||||
--exclude='**/.vs' \
|
||||
--exclude='**/.vscode' \
|
||||
--exclude='deployment' \
|
||||
--exclude='**/bin' \
|
||||
--exclude='**/obj' \
|
||||
--exclude='**/.nuget' \
|
||||
--exclude='*.deb' \
|
||||
--exclude='*.rpm' \
|
||||
-czf "pkg-src/jellyfin-$(VERSION).tar.gz" \
|
||||
-C $${SOURCE_DIR} ./ || GNU_TAR=0; \
|
||||
if [ $${GNU_TAR} -eq 0 ]; then \
|
||||
package_temporary_dir="$$(mktemp -d)"; \
|
||||
mkdir -p "$${package_temporary_dir}/jellyfin"; \
|
||||
tar \
|
||||
--exclude='.git*' \
|
||||
--exclude='**/.git' \
|
||||
--exclude='**/.hg' \
|
||||
--exclude='**/.vs' \
|
||||
--exclude='**/.vscode' \
|
||||
--exclude='deployment' \
|
||||
--exclude='**/bin' \
|
||||
--exclude='**/obj' \
|
||||
--exclude='**/.nuget' \
|
||||
--exclude='*.deb' \
|
||||
--exclude='*.rpm' \
|
||||
-czf "$${package_temporary_dir}/jellyfin/jellyfin-$(VERSION).tar.gz" \
|
||||
-C $${SOURCE_DIR} ./; \
|
||||
mkdir -p "$${package_temporary_dir}/jellyfin-$(VERSION)"; \
|
||||
tar -xzf "$${package_temporary_dir}/jellyfin/jellyfin-$(VERSION).tar.gz" \
|
||||
-C "$${package_temporary_dir}/jellyfin-$(VERSION); \
|
||||
rm -f "$${package_temporary_dir}/jellyfin/jellyfin-$(VERSION).tar.gz"; \
|
||||
tar -czf "$${SOURCE_DIR}/SOURCES/pkg-src/jellyfin-$(VERSION).tar.gz" \
|
||||
-C "$${package_temporary_dir}" "jellyfin-$(VERSION); \
|
||||
rm -rf $${package_temporary_dir}; \
|
||||
fi; \
|
||||
rpmbuild -bs pkg-src/jellyfin.spec \
|
||||
--define "_sourcedir $$PWD/pkg-src/" \
|
||||
--define "_srcrpmdir $(outdir)"
|
||||
|
@ -1,48 +0,0 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Common.Extensions
|
||||
{
|
||||
// The MS CollectionExtensions are only available in netcoreapp
|
||||
public static class CollectionExtensions
|
||||
{
|
||||
public static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
|
||||
{
|
||||
dictionary.TryGetValue(key, out var ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies all the elements of the current collection to the specified list
|
||||
/// starting at the specified destination array index. The index is specified as a 32-bit integer.
|
||||
/// </summary>
|
||||
/// <param name="source">The current collection that is the source of the elements.</param>
|
||||
/// <param name="destination">The list that is the destination of the elements copied from the current collection.</param>
|
||||
/// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public static void CopyTo<T>(this IReadOnlyList<T> source, IList<T> destination, int index = 0)
|
||||
{
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
destination[index + i] = source[i];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies all the elements of the current collection to the specified list
|
||||
/// starting at the specified destination array index. The index is specified as a 32-bit integer.
|
||||
/// </summary>
|
||||
/// <param name="source">The current collection that is the source of the elements.</param>
|
||||
/// <param name="destination">The list that is the destination of the elements copied from the current collection.</param>
|
||||
/// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public static void CopyTo<T>(this IReadOnlyCollection<T> source, IList<T> destination, int index = 0)
|
||||
{
|
||||
foreach (T item in source)
|
||||
{
|
||||
destination[index++] = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Common.Extensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides <c>CopyTo</c> extensions methods for <see cref="IReadOnlyList{T}" />.
|
||||
/// </summary>
|
||||
public static class CollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Copies all the elements of the current collection to the specified list
|
||||
/// starting at the specified destination array index. The index is specified as a 32-bit integer.
|
||||
/// </summary>
|
||||
/// <param name="source">The current collection that is the source of the elements.</param>
|
||||
/// <param name="destination">The list that is the destination of the elements copied from the current collection.</param>
|
||||
/// <param name="index">A 32-bit integer that represents the index in <c>destination</c> at which copying begins.</param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public static void CopyTo<T>(this IReadOnlyList<T> source, IList<T> destination, int index = 0)
|
||||
{
|
||||
for (int i = 0; i < source.Count; i++)
|
||||
{
|
||||
destination[index + i] = source[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace MediaBrowser.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Encoding and decoding hex strings.
|
||||
/// </summary>
|
||||
public static class Hex
|
||||
{
|
||||
internal const string HexCharsLower = "0123456789abcdef";
|
||||
internal const string HexCharsUpper = "0123456789ABCDEF";
|
||||
|
||||
internal const int LastHexSymbol = 0x66; // 102: f
|
||||
|
||||
/// <summary>
|
||||
/// Map from an ASCII char to its hex value shifted,
|
||||
/// e.g. <c>b</c> -> 11. 0xFF means it's not a hex symbol.
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
internal static ReadOnlySpan<byte> HexLookup => new byte[] {
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Encodes <c>bytes</c> as a hex string.
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
/// <param name="lowercase"></param>
|
||||
/// <returns><c>bytes</c> as a hex string.</returns>
|
||||
public static string Encode(ReadOnlySpan<byte> bytes, bool lowercase = true)
|
||||
{
|
||||
var hexChars = lowercase ? HexCharsLower : HexCharsUpper;
|
||||
|
||||
// TODO: use string.Create when it's supports spans
|
||||
// Ref: https://github.com/dotnet/corefx/issues/29120
|
||||
char[] s = new char[bytes.Length * 2];
|
||||
int j = 0;
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
s[j++] = hexChars[bytes[i] >> 4];
|
||||
s[j++] = hexChars[bytes[i] & 0x0f];
|
||||
}
|
||||
|
||||
return new string(s);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Decodes a hex string into bytes.
|
||||
/// </summary>
|
||||
/// <param name="str">The <see cref="string" />.</param>
|
||||
/// <returns>The decoded bytes.</returns>
|
||||
public static byte[] Decode(ReadOnlySpan<char> str)
|
||||
{
|
||||
if (str.Length == 0)
|
||||
{
|
||||
return Array.Empty<byte>();
|
||||
}
|
||||
|
||||
var unHex = HexLookup;
|
||||
|
||||
int byteLen = str.Length / 2;
|
||||
byte[] bytes = new byte[byteLen];
|
||||
int i = 0;
|
||||
for (int j = 0; j < byteLen; j++)
|
||||
{
|
||||
byte a;
|
||||
byte b;
|
||||
if (str[i] > LastHexSymbol
|
||||
|| (a = unHex[str[i++]]) == 0xFF
|
||||
|| str[i] > LastHexSymbol
|
||||
|| (b = unHex[str[i++]]) == 0xFF)
|
||||
{
|
||||
ThrowArgumentException(nameof(str));
|
||||
break; // Unreachable
|
||||
}
|
||||
|
||||
bytes[j] = (byte)((a * 16) | b);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
[DoesNotReturn]
|
||||
private static void ThrowArgumentException(string paramName)
|
||||
=> throw new ArgumentException("Character is not a hex symbol.", paramName);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace MediaBrowser.Common
|
||||
{
|
||||
public static class HexHelper
|
||||
{
|
||||
public static byte[] FromHexString(string str)
|
||||
{
|
||||
byte[] bytes = new byte[str.Length / 2];
|
||||
for (int i = 0; i < str.Length; i += 2)
|
||||
{
|
||||
bytes[i / 2] = byte.Parse(str.Substring(i, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static string ToHexString(byte[] bytes)
|
||||
=> BitConverter.ToString(bytes).Replace("-", "");
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../MediaBrowser.Common/MediaBrowser.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
This file was created by NSISDialogDesigner 1.4.4.0
|
||||
http://coolsoft.altervista.org/nsisdialogdesigner
|
||||
Do not edit manually!
|
||||
-->
|
||||
<Dialog Name="setuptype" Title="Setup Type" Subtitle="Control how Jellyfin is installed.">
|
||||
<Label Name="InstallasaServiceLabel" Location="12, 115" Size="426, 46" Text="Install Jellyfin as a service. This method is recommended for Advanced Users. Additional setup is required to access network shares." TabIndex="0" />
|
||||
<RadioButton Name="InstallasaService" Location="12, 88" Size="426, 24" Text="Install as a Service (Advanced Users)" TabIndex="1" />
|
||||
<Label Name="BasicInstallLabel" Location="12, 39" Size="426, 46" Text="The basic install will run Jellyfin in your current user account.$\nThis is recommended for new users and those with existing Jellyfin installs older than 10.4." TabIndex="2" />
|
||||
<RadioButton Name="BasicInstall" Location="12, 12" Size="426, 24" Text="Basic Install (Recommended)" Font="Microsoft Sans Serif, 8.25pt, style=Bold" Checked="True" TabIndex="3" />
|
||||
</Dialog>
|
@ -0,0 +1,50 @@
|
||||
; =========================================================
|
||||
; This file was generated by NSISDialogDesigner 1.4.4.0
|
||||
; http://coolsoft.altervista.org/nsisdialogdesigner
|
||||
;
|
||||
; Do not edit it manually, use NSISDialogDesigner instead!
|
||||
; =========================================================
|
||||
|
||||
; handle variables
|
||||
Var hCtl_setuptype
|
||||
Var hCtl_setuptype_InstallasaServiceLabel
|
||||
Var hCtl_setuptype_InstallasaService
|
||||
Var hCtl_setuptype_BasicInstallLabel
|
||||
Var hCtl_setuptype_BasicInstall
|
||||
Var hCtl_setuptype_Font1
|
||||
|
||||
|
||||
; dialog create function
|
||||
Function fnc_setuptype_Create
|
||||
|
||||
; custom font definitions
|
||||
CreateFont $hCtl_setuptype_Font1 "Microsoft Sans Serif" "8.25" "700"
|
||||
|
||||
; === setuptype (type: Dialog) ===
|
||||
nsDialogs::Create 1018
|
||||
Pop $hCtl_setuptype
|
||||
${If} $hCtl_setuptype == error
|
||||
Abort
|
||||
${EndIf}
|
||||
!insertmacro MUI_HEADER_TEXT "Setup Type" "Control how Jellyfin is installed."
|
||||
|
||||
; === InstallasaServiceLabel (type: Label) ===
|
||||
${NSD_CreateLabel} 8u 71u 280u 28u "Install Jellyfin as a service. This method is recommended for Advanced Users. Additional setup is required to access network shares."
|
||||
Pop $hCtl_setuptype_InstallasaServiceLabel
|
||||
|
||||
; === InstallasaService (type: RadioButton) ===
|
||||
${NSD_CreateRadioButton} 8u 54u 280u 15u "Install as a Service (Advanced Users)"
|
||||
Pop $hCtl_setuptype_InstallasaService
|
||||
${NSD_AddStyle} $hCtl_setuptype_InstallasaService ${WS_GROUP}
|
||||
|
||||
; === BasicInstallLabel (type: Label) ===
|
||||
${NSD_CreateLabel} 8u 24u 280u 28u "The basic install will run Jellyfin in your current user account.$\nThis is recommended for new users and those with existing Jellyfin installs older than 10.4."
|
||||
Pop $hCtl_setuptype_BasicInstallLabel
|
||||
|
||||
; === BasicInstall (type: RadioButton) ===
|
||||
${NSD_CreateRadioButton} 8u 7u 280u 15u "Basic Install (Recommended)"
|
||||
Pop $hCtl_setuptype_BasicInstall
|
||||
SendMessage $hCtl_setuptype_BasicInstall ${WM_SETFONT} $hCtl_setuptype_Font1 0
|
||||
${NSD_Check} $hCtl_setuptype_BasicInstall
|
||||
|
||||
FunctionEnd
|
@ -0,0 +1,19 @@
|
||||
using MediaBrowser.Common;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Common.Tests
|
||||
{
|
||||
public class HexTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData("00")]
|
||||
[InlineData("01")]
|
||||
[InlineData("000102030405060708090a0b0c0d0e0f")]
|
||||
[InlineData("0123456789abcdef")]
|
||||
public void RoundTripTest(string data)
|
||||
{
|
||||
Assert.Equal(data, Hex.Encode(Hex.Decode(data)));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue