Compare commits
17 Commits
51aca7a2c2
...
fix/Pacser
Author | SHA1 | Date | |
---|---|---|---|
733689cb5b
|
|||
25004cd83b | |||
42fe907ec8 | |||
6892191275
|
|||
58ceb31c1c
|
|||
15220e7135
|
|||
590b06fc86
|
|||
65b15f657d | |||
82a854dd8b | |||
5018856aab | |||
dc811d7462
|
|||
07982425e0
|
|||
e609caf892
|
|||
60dfb368e6
|
|||
41692548f2
|
|||
f923628c53
|
|||
1994e92e9e
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.vscode/
|
.vscode/
|
||||||
[Oo]bj/
|
[Oo]bj/
|
||||||
[Bb]in/
|
[Bb]in/
|
||||||
|
.sonarqube/
|
@ -4,15 +4,15 @@ namespace Pacserver.Tests;
|
|||||||
|
|
||||||
public class TranserFilesTest {
|
public class TranserFilesTest {
|
||||||
[Fact]
|
[Fact]
|
||||||
public void transferPacmanCache_doesNotFail() {
|
public async void transferPacmanCache_doesNotFail() {
|
||||||
// Arrange
|
// Arrange
|
||||||
PacserverUtils utils = new PacserverUtils();
|
PacserverUtils utils = new PacserverUtils();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
utils.readPacmanConfig();
|
utils.readPacmanConfig();
|
||||||
utils.transferPacmanCache();
|
Action act = () => utils.transfer();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
//Assert.NotEmpty(Directory.GetFiles("/home/rene/test/"));
|
act.Should().NotThrow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,11 @@ public class checkForNewerStuffTest {
|
|||||||
public void checkForNewerPackages_throwsExceptionIfNoFilesExist() {
|
public void checkForNewerPackages_throwsExceptionIfNoFilesExist() {
|
||||||
// Arrange
|
// Arrange
|
||||||
PacserverUtils utils = new PacserverUtils();
|
PacserverUtils utils = new PacserverUtils();
|
||||||
|
File.Delete(utils.pacserverDirectory + "packages_before.txt");
|
||||||
|
File.Delete(utils.pacserverDirectory + "packages_after.txt");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Action act = () => utils.diff("/tmp/before_update.txt", "/tmp/after_update.txt");
|
Action act = () => utils.diff(utils.pacserverDirectory + "packages_before.txt", utils.pacserverDirectory + "packages_after.txt");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
act.Should().Throw<FileNotFoundException>().WithMessage("Necessary files could not be found");
|
act.Should().Throw<FileNotFoundException>().WithMessage("Necessary files could not be found");
|
||||||
@ -19,42 +21,42 @@ public class checkForNewerStuffTest {
|
|||||||
public void getEveryPackageNameAndVersionViaFolderName_createsFiles() {
|
public void getEveryPackageNameAndVersionViaFolderName_createsFiles() {
|
||||||
// Arrange
|
// Arrange
|
||||||
PacserverUtils utils = new PacserverUtils();
|
PacserverUtils utils = new PacserverUtils();
|
||||||
utils.readPacmanConfig();
|
Directory.CreateDirectory("/tmp/pacserverTest/");
|
||||||
|
utils.pacmanCacheDirectory = "/tmp/pacserverTest/";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
utils.getEveryPackageNameAndVersionViaFolderName("/tmp/before_update.txt");
|
utils.getEveryPackageNameAndVersion("before", utils.pacserverDirectory + "packages_before.txt");
|
||||||
utils.getEveryPackageNameAndVersionViaFolderName("/tmp/after_update.txt");
|
utils.getEveryPackageNameAndVersion("after", utils.pacserverDirectory + "packages_after.txt");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
File.Exists("/tmp/before_update.txt").Should().BeTrue();
|
File.Exists(utils.pacserverDirectory + "packages_before.txt").Should().BeTrue();
|
||||||
File.Exists("/tmp/after_update.txt").Should().BeTrue();
|
File.Exists(utils.pacserverDirectory + "packages_before.txt").Should().BeTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void packageNamesAndVersion_notEmpty() {
|
public void packageNamesAndVersion_isEmpty() {
|
||||||
// Arrange
|
// Arrange
|
||||||
PacserverUtils utils = new PacserverUtils();
|
PacserverUtils utils = new PacserverUtils();
|
||||||
utils.readPacmanConfig();
|
Directory.CreateDirectory("/tmp/pacserverTest/");
|
||||||
utils.getEveryPackageNameAndVersionViaFolderName("/tmp/before_update.txt");
|
utils.pacmanCacheDirectory = "/tmp/pacserverTest/";
|
||||||
|
utils.getEveryPackageNameAndVersion("before", utils.pacserverDirectory + "packages_before.txt");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
List<String> packageList = utils.packageNamesAndVersion;
|
var packageList = utils.packageNamesAndVersion;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
packageList.Should().NotBeNullOrEmpty();
|
packageList.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void getEveryPackageNameAndVersionViaFolderName_throwsExceptionIfListIsEmpty() {
|
public void getEveryPackageNameAndVersionViaFolderName_throwsExceptionIfModeIsNotValid() {
|
||||||
// Arrange
|
// Arrange
|
||||||
PacserverUtils utils = new PacserverUtils();
|
PacserverUtils utils = new PacserverUtils();
|
||||||
Directory.CreateDirectory("/tmp/local");
|
|
||||||
utils.pacmanDatabaseDirectory = "/tmp/";
|
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
Action act = () => utils.getEveryPackageNameAndVersionViaFolderName("/tmp/before_update.txt");
|
Action act = () => utils.getEveryPackageNameAndVersion("test", utils.pacserverDirectory + "test.txt");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
act.Should().Throw<Exception>().WithMessage("How did you execute this without any packages?");
|
act.Should().Throw<ArgumentException>().WithMessage("No valid mode was given. Valid modes are before and after");
|
||||||
}
|
}
|
||||||
}
|
}
|
31
src/Pacserver.Tests/checkIfDatabasesWereModifiedTest.cs
Normal file
31
src/Pacserver.Tests/checkIfDatabasesWereModifiedTest.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using Pacserver.Utils;
|
||||||
|
|
||||||
|
namespace Pacserver.Tests;
|
||||||
|
|
||||||
|
public class checkIfDatabasesWereModifiedTest {
|
||||||
|
[Fact]
|
||||||
|
public void checkIfDatabasesWereModified_throwsExceptionIfNoValidModeIsGiven() {
|
||||||
|
// Arrange
|
||||||
|
PacserverUtils utils = new PacserverUtils();
|
||||||
|
utils.readPacmanConfig();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
Action act = () => utils.checkIfDatabasesWereModified("test", "/tmp/test.txt");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
act.Should().Throw<ArgumentException>().WithMessage("No valid mode was given. Valid modes are before and after");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void checkIfDatabasesWereModified_throwsNoExceptionIfValidModeIsGiven() {
|
||||||
|
// Arrange
|
||||||
|
PacserverUtils utils = new PacserverUtils();
|
||||||
|
utils.readPacmanConfig();
|
||||||
|
|
||||||
|
// Act
|
||||||
|
Action act = () => utils.checkIfDatabasesWereModified("before", "/tmp/test.txt");
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
act.Should().NotThrow();
|
||||||
|
}
|
||||||
|
}
|
22
src/Pacserver.Tests/getEverySigFileTest.cs
Normal file
22
src/Pacserver.Tests/getEverySigFileTest.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using Pacserver.Utils;
|
||||||
|
|
||||||
|
namespace Pacserver.Tests;
|
||||||
|
|
||||||
|
public class getEverySigFileTest {
|
||||||
|
[Fact]
|
||||||
|
public void getEverySigFile_ListShouldNotBeEmpty() {
|
||||||
|
// Arrange
|
||||||
|
PacserverUtils utils = new PacserverUtils();
|
||||||
|
Directory.CreateDirectory("/tmp/pacserverTest/");
|
||||||
|
utils.pacmanCacheDirectory = "/tmp/pacserverTest/";
|
||||||
|
File.Create(utils.pacmanCacheDirectory + "zsh-5.9-3-x86_64.pkg.tar.zst.sig");
|
||||||
|
|
||||||
|
// Act
|
||||||
|
utils.getEverySigFile();
|
||||||
|
var sigFiles = utils.sigFiles;
|
||||||
|
Directory.Delete(utils.pacmanCacheDirectory, true);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
sigFiles.Should().NotBeEmpty();
|
||||||
|
}
|
||||||
|
}
|
@ -1,52 +1,109 @@
|
|||||||
using System.Net.Http.Headers;
|
using System.Collections.Immutable;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace Pacserver.Utils;
|
namespace Pacserver.Utils;
|
||||||
public class PacserverUtils {
|
public partial class PacserverUtils {
|
||||||
public string pacmanCacheDirectory = string.Empty;
|
public string? pacserverDirectory { get; set; }
|
||||||
public string pacmanDatabaseDirectory = string.Empty;
|
public void prerequisites() {
|
||||||
public static List<String> pathsToDetermine = new List<String>() { "CacheDir", "DBPath" };
|
AppDomain.CurrentDomain.SetData("REGEX_DEFAULT_MATCH_TIMEOUT", TimeSpan.FromMilliseconds(100));
|
||||||
|
|
||||||
|
pacserverDirectory = "/tmp/pacserver/";
|
||||||
|
pacmanCacheDirectory = string.Empty;
|
||||||
|
pacmanDatabaseDirectory = string.Empty;
|
||||||
|
|
||||||
|
if (!Directory.Exists(pacserverDirectory)) {
|
||||||
|
Directory.CreateDirectory(pacserverDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanup() {
|
||||||
|
if (Directory.Exists(pacserverDirectory)) {
|
||||||
|
Directory.Delete(pacserverDirectory, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string? pacmanCacheDirectory { get; set; }
|
||||||
|
public string? pacmanDatabaseDirectory { get; set; }
|
||||||
|
public readonly ImmutableList<String> pathsToDetermine = ImmutableList.Create("CacheDir", "DBPath");
|
||||||
|
[GeneratedRegex(@"\/(?:[\w.-]+\/)*[\w.-]+(?:\.\w+)*\/?$", RegexOptions.NonBacktracking)] // https://regex101.com/r/GwWeui/2
|
||||||
|
private static partial Regex CacheDirOrDBPathRegex();
|
||||||
public void readPacmanConfig() {
|
public void readPacmanConfig() {
|
||||||
using (StreamReader file = new StreamReader("/etc/pacman.conf")) {
|
using (StreamReader file = new StreamReader("/etc/pacman.conf")) {
|
||||||
Regex regex = new Regex(@"\/(?:[\w.-]+\/)*[\w.-]+(?:\.\w+)*\/?$"); // https://regex101.com/r/GwWeui/2
|
|
||||||
string? line;
|
string? line;
|
||||||
|
|
||||||
while ((line = file.ReadLine()) is not null) {
|
while ((line = file.ReadLine()) is not null) {
|
||||||
foreach (string path in pathsToDetermine) {
|
string cachePath = pathsToDetermine[0];
|
||||||
if (line.Contains(path)) {
|
string dbPath = pathsToDetermine[1];
|
||||||
Match match = regex.Match(line);
|
|
||||||
if (match.Success) {
|
if (!line.Contains(cachePath) && !line.Contains(dbPath)) {
|
||||||
switch (path) {
|
continue;
|
||||||
case "CacheDir":
|
}
|
||||||
pacmanCacheDirectory = match.ToString();
|
|
||||||
break;
|
Match match = CacheDirOrDBPathRegex().Match(line);
|
||||||
case "DBPath":
|
|
||||||
pacmanDatabaseDirectory = match.ToString();
|
if (!match.Success) {
|
||||||
break;
|
string pathsToDetermineString = string.Join(",", pathsToDetermine);
|
||||||
default:
|
throw new DirectoryNotFoundException("Could not determine the necessary file paths: " + pathsToDetermineString);
|
||||||
throw new Exception("Could not deal with " + match.ToString());
|
}
|
||||||
}
|
|
||||||
} else {
|
if (line.Contains(cachePath)) {
|
||||||
string pathsToDetermineString = string.Join(",", pathsToDetermine);
|
pacmanCacheDirectory = match.ToString();
|
||||||
throw new Exception("Could not determine the necessary file paths: " + pathsToDetermineString);
|
} else if (line.Contains(dbPath)) {
|
||||||
}
|
pacmanDatabaseDirectory = match.ToString();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> packageNamesAndVersion = new List<String>();
|
public List<String> packageNamesAndVersion = new List<String>();
|
||||||
public void getEveryPackageNameAndVersionViaFolderName(string filePath) {
|
[GeneratedRegex(@".+\.pkg\.tar\.zst$", RegexOptions.NonBacktracking)]
|
||||||
string[] directories = Directory.GetDirectories(pacmanDatabaseDirectory + "local/");
|
private static partial Regex onlyGetPackages();
|
||||||
foreach (string directory in directories) {
|
public void getEveryPackageNameAndVersion(string mode, string filePath) {
|
||||||
packageNamesAndVersion.Add(new DirectoryInfo(directory).Name);
|
if (Directory.Exists(pacmanCacheDirectory)) {
|
||||||
|
if (Directory.GetFiles(pacmanCacheDirectory) is not null) {
|
||||||
|
packageNamesAndVersion = Directory.GetFiles(pacmanCacheDirectory).Where(file => onlyGetPackages().IsMatch(file)).ToList();
|
||||||
|
} else {
|
||||||
|
Console.WriteLine("No packages found in pacman cache");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Console.WriteLine("No pacman cache directory found");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packageNamesAndVersion.Capacity > 0) {
|
switch (mode) {
|
||||||
File.WriteAllLines(filePath, packageNamesAndVersion);
|
case "before":
|
||||||
} else {
|
writePackageNamesAndVersionToFile(filePath);
|
||||||
throw new Exception("How did you execute this without any packages?");
|
break;
|
||||||
|
case "after":
|
||||||
|
writePackageNamesAndVersionToFile(filePath);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentException("No valid mode was given. Valid modes are before and after");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writePackageNamesAndVersionToFile(string filePath) {
|
||||||
|
if (File.Exists(filePath)) {
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) {
|
||||||
|
using (StreamWriter sw = new StreamWriter(filePath)) {
|
||||||
|
foreach (string package in packageNamesAndVersion) {
|
||||||
|
sw.WriteLine(package);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> sigFiles = new List<String>();
|
||||||
|
[GeneratedRegex(@".+\.pkg\.tar\.zst\.sig$", RegexOptions.NonBacktracking)]
|
||||||
|
private static partial Regex onlyGetSigFiles();
|
||||||
|
public void getEverySigFile() {
|
||||||
|
if (Directory.Exists(pacmanCacheDirectory)) {
|
||||||
|
if (Directory.GetFiles(pacmanCacheDirectory) is not null) {
|
||||||
|
sigFiles = Directory.GetFiles(pacmanCacheDirectory).Where(file => onlyGetSigFiles().IsMatch(file)).ToList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,56 +116,73 @@ public class PacserverUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> databases = new List<String>();
|
public void saveDiffToFile(string filePath) {
|
||||||
public void checkIfDatabasesWereModified(string mode, string filePath) {
|
if (File.Exists(filePath)) {
|
||||||
string[] databases = Directory.GetFiles(pacmanDatabaseDirectory + "sync/");
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
// if (mode == "nuke") {
|
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) {
|
||||||
// using (File.Open(filePath, FileMode.Truncate, FileAccess.ReadWrite, FileShare.Delete)) {
|
using (StreamWriter sw = new StreamWriter(filePath)) {
|
||||||
// File.Delete(filePath);
|
foreach (string packageOrDatabase in diffOfPackagesOrDatabases) {
|
||||||
// }
|
sw.WriteLine(packageOrDatabase);
|
||||||
// }
|
}
|
||||||
|
|
||||||
foreach (string database in databases) {
|
|
||||||
switch (mode) {
|
|
||||||
case "before":
|
|
||||||
if (!File.Exists(filePath)) {
|
|
||||||
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) {
|
|
||||||
using (StreamWriter sw = new StreamWriter(filePath)) {
|
|
||||||
sw.WriteLine(database + " " + File.GetLastAccessTime(database));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (File.Exists(filePath)) {
|
|
||||||
using (File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) {
|
|
||||||
using (var sw = new StreamWriter(filePath, true)) {
|
|
||||||
sw.WriteLine(database + " " + File.GetLastAccessTime(database));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "after":
|
|
||||||
if (!File.Exists(filePath)) {
|
|
||||||
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) {
|
|
||||||
using (StreamWriter sw = new StreamWriter(filePath)) {
|
|
||||||
sw.WriteLine(database + " " + File.GetLastAccessTime(database));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (File.Exists(filePath)) {
|
|
||||||
using (File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite)) {
|
|
||||||
using (var sw = new StreamWriter(filePath, true)) {
|
|
||||||
sw.WriteLine(database + " " + File.GetLastAccessTime(database));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentException("No valid mode was selected");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> readDiffFileToList(string filePath) {
|
||||||
|
using (File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) {
|
||||||
|
return File.ReadAllLines(filePath).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> databases = new List<String>();
|
||||||
|
public void checkIfDatabasesWereModified(string mode, string filePath) {
|
||||||
|
databases = Directory.GetFiles(pacmanDatabaseDirectory + "sync/").ToList();
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case "before":
|
||||||
|
writeDatabaseAccessTimeToFile(filePath);
|
||||||
|
break;
|
||||||
|
case "after":
|
||||||
|
writeDatabaseAccessTimeToFile(filePath);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentException("No valid mode was given. Valid modes are before and after");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeDatabaseAccessTimeToFile(string filePath) {
|
||||||
|
if (File.Exists(filePath)) {
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (File.Open(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read)) {
|
||||||
|
using (StreamWriter sw = new StreamWriter(filePath)) {
|
||||||
|
foreach (string database in databases) {
|
||||||
|
sw.WriteLine(database + " " + File.GetLastAccessTime(database));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> databasesToTransfer = new List<String>();
|
||||||
|
[GeneratedRegex(@"\/(?:[\w.-]+\/)*[\w.-]+(?:\.\w+)*\/*db", RegexOptions.NonBacktracking)] // https://regex101.com/r/Wm5M0P/1
|
||||||
|
private static partial Regex onlyGetDatabaseName();
|
||||||
|
public void filterDiffOutputForDatabases() {
|
||||||
|
foreach (string database in diffOfPackagesOrDatabases) {
|
||||||
|
databasesToTransfer.Add(onlyGetDatabaseName().Match(database).Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static List<String> newerPackagesAndDatabases = new List<String>();
|
private static List<String> newerPackagesAndDatabases = new List<String>();
|
||||||
public async void transferPacmanCache() {
|
public void combinePackagesWithDatabases() {
|
||||||
|
newerPackagesAndDatabases.AddRange(packageNamesAndVersion);
|
||||||
|
newerPackagesAndDatabases.AddRange(databasesToTransfer);
|
||||||
|
newerPackagesAndDatabases.AddRange(sigFiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task transfer() {
|
||||||
HttpClient client = new HttpClient();
|
HttpClient client = new HttpClient();
|
||||||
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://192.168.0.69:12000/upload?path=/");
|
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "http://192.168.0.69:12000/upload?path=/");
|
||||||
MultipartFormDataContent content = new MultipartFormDataContent();
|
MultipartFormDataContent content = new MultipartFormDataContent();
|
||||||
@ -120,8 +194,4 @@ public class PacserverUtils {
|
|||||||
|
|
||||||
await client.SendAsync(request);
|
await client.SendAsync(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferPacmanDatabases() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,53 +1,51 @@
|
|||||||
using Pacserver.Utils;
|
using Pacserver.Utils;
|
||||||
|
|
||||||
public class Program {
|
public class Program {
|
||||||
|
|
||||||
|
protected Program() {
|
||||||
|
}
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
if (args.Length == 0) {
|
if (args.Length == 0) {
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Console.WriteLine("Please specify an option.");
|
Console.WriteLine("Please specify an option.");
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
Console.WriteLine("Possible options are: determinePacmanCacheDirectory, packagesBefore, packagesAfter, diffPackages, databasesBefore, databasesAfter, diffDatabases");
|
Console.WriteLine("Possible options are: before, after");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacserverUtils utils = new PacserverUtils();
|
PacserverUtils utils = new PacserverUtils();
|
||||||
|
utils.prerequisites();
|
||||||
|
utils.readPacmanConfig();
|
||||||
|
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case "determinePacmanCacheDirectory":
|
case "before":
|
||||||
utils.readPacmanConfig();
|
utils.getEveryPackageNameAndVersion("before", utils.pacserverDirectory + "packages_before.txt");
|
||||||
Console.WriteLine(utils.pacmanCacheDirectory);
|
utils.checkIfDatabasesWereModified("before", utils.pacserverDirectory + "databases_before.txt");
|
||||||
break;
|
break;
|
||||||
case "packagesBefore":
|
case "after":
|
||||||
utils.readPacmanConfig();
|
utils.getEveryPackageNameAndVersion("after", utils.pacserverDirectory + "packages_after.txt");
|
||||||
utils.getEveryPackageNameAndVersionViaFolderName("/tmp/before_update.txt");
|
utils.checkIfDatabasesWereModified("after", utils.pacserverDirectory + "databases_after.txt");
|
||||||
break;
|
|
||||||
case "packagesAfter":
|
utils.diff(utils.pacserverDirectory + "packages_before.txt", utils.pacserverDirectory + "packages_after.txt");
|
||||||
utils.readPacmanConfig();
|
utils.saveDiffToFile(utils.pacserverDirectory + "package_diff.txt");
|
||||||
utils.getEveryPackageNameAndVersionViaFolderName("/tmp/after_update.txt");
|
|
||||||
break;
|
utils.diff(utils.pacserverDirectory + "databases_before.txt", utils.pacserverDirectory + "databases_after.txt");
|
||||||
case "diffPackages":
|
utils.saveDiffToFile(utils.pacserverDirectory + "database_diff.txt");
|
||||||
utils.diff("/tmp/before_update.txt", "/tmp/after_update.txt");
|
utils.filterDiffOutputForDatabases();
|
||||||
string packages = string.Join(",", utils.diffOfPackagesOrDatabases);
|
|
||||||
Console.WriteLine(packages);
|
utils.packageNamesAndVersion = utils.readDiffFileToList(utils.pacserverDirectory + "package_diff.txt");
|
||||||
break;
|
|
||||||
case "databasesBefore":
|
utils.getEverySigFile();
|
||||||
utils.readPacmanConfig();
|
utils.combinePackagesWithDatabases();
|
||||||
utils.checkIfDatabasesWereModified("before", "/tmp/databases_before.txt");
|
utils.transfer();
|
||||||
break;
|
|
||||||
case "databasesAfter":
|
utils.cleanup();
|
||||||
utils.readPacmanConfig();
|
|
||||||
utils.checkIfDatabasesWereModified("after", "/tmp/databases_after.txt");
|
|
||||||
break;
|
|
||||||
case "diffDatabases":
|
|
||||||
utils.diff("/tmp/databases_before.txt", "/tmp/databases_after.txt");
|
|
||||||
string databases = string.Join(",", utils.diffOfPackagesOrDatabases);
|
|
||||||
Console.WriteLine(databases);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
Console.WriteLine(args[0] + " is not a recognized option.");
|
Console.WriteLine(args[0] + " is not a recognized option.");
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
Console.WriteLine("Possible options are: determinePacmanCacheDirectory");
|
Console.WriteLine("Possible options are: before, after");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user