Major changes
Changed the whole project struture justfile was adjusted to reflect the changes Add Tests Minor changes to .gitignore
This commit is contained in:
43
src/Pacserver/Pacserver.cs
Normal file
43
src/Pacserver/Pacserver.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Pacserver.Utils;
|
||||
public class PacserverUtils {
|
||||
public static string pacmanCacheDirectory { get; set; } = string.Empty;
|
||||
public static string determinePacmanCacheDirectory() {
|
||||
string defaultPacmanCacheDirectory = "/var/cache/pacman/pkg/";
|
||||
|
||||
Regex regex = new Regex(@"\/(?:[\w.-]+\/)*[\w.-]+(?:\.\w+)*\/?$"); // https://regex101.com/r/GwWeui/2
|
||||
string? line;
|
||||
StreamReader file = new StreamReader("/etc/pacman.conf");
|
||||
while ((line = file.ReadLine()) is not null) {
|
||||
if (line.Contains("CacheDir")) {
|
||||
Match match = regex.Match(line);
|
||||
if (match.Success) {
|
||||
pacmanCacheDirectory = match.ToString();
|
||||
} else {
|
||||
throw new Exception("Could not determine where pacman cache is! Would normally be found here " + defaultPacmanCacheDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
file.Close();
|
||||
|
||||
return pacmanCacheDirectory;
|
||||
}
|
||||
|
||||
public static string pacmanDatabaseDirectory { get; set; } = string.Empty;
|
||||
public static string determinePacmanDatabaseDirectory() {
|
||||
return pacmanDatabaseDirectory;
|
||||
}
|
||||
|
||||
public static void checkForNewerPackagesAndDatabases() {
|
||||
|
||||
}
|
||||
|
||||
public static void transferPacmanCache() {
|
||||
|
||||
}
|
||||
|
||||
public static void transferPacmanDatabases() {
|
||||
|
||||
}
|
||||
}
|
22
src/Pacserver/Program.cs
Normal file
22
src/Pacserver/Program.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Pacserver.Utils;
|
||||
|
||||
public class Program {
|
||||
static void Main(string[] args) {
|
||||
if (args.Length == 0) {
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Please specify an option.");
|
||||
Console.ResetColor();
|
||||
} else {
|
||||
switch (args[0]) {
|
||||
case "determinePacmanCacheDirectory":
|
||||
Console.WriteLine(PacserverUtils.determinePacmanCacheDirectory());
|
||||
break;
|
||||
default:
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("Possible options are: determinePacmanCacheDirectory");
|
||||
Console.ResetColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
src/Pacserver/pacserver.csproj
Normal file
14
src/Pacserver/pacserver.csproj
Normal file
@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<SelfContained>true</SelfContained>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
Reference in New Issue
Block a user