mirror of
https://github.com/AdisonCavani/distro-grub-themes.git
synced 2025-06-07 15:32:34 +02:00
Add updating archives
This commit is contained in:
parent
8c2aedad45
commit
7b34c3c0ba
3 changed files with 69 additions and 5 deletions
39
src/ArchiveManager.cs
Normal file
39
src/ArchiveManager.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace DistroGrubThemes
|
||||||
|
{
|
||||||
|
public class ArchiveManager
|
||||||
|
{
|
||||||
|
public static void CreateTarArchive(string sourceDirectory, string outputFile)
|
||||||
|
{
|
||||||
|
Chilkat.Tar tar = new Chilkat.Tar
|
||||||
|
{
|
||||||
|
WriteFormat = "gnu"
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add a directory tree to be included in the output TAR archive:
|
||||||
|
bool success = tar.AddDirRoot(sourceDirectory);
|
||||||
|
if (success != true)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.Write("ERROR\n\n");
|
||||||
|
Console.Write("error: ");
|
||||||
|
Console.ResetColor();
|
||||||
|
Console.Write(tar.LastErrorText + "\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the TAR archive.
|
||||||
|
success = tar.WriteTar(outputFile);
|
||||||
|
if (success != true)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.Write("ERROR\n\n");
|
||||||
|
Console.Write("error: ");
|
||||||
|
Console.ResetColor();
|
||||||
|
Console.Write(tar.LastErrorText + "\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,8 +8,8 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="ChilkatDnCore" Version="9.5.0.88" />
|
||||||
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
<PackageReference Include="CommandLineParser" Version="2.8.0" />
|
||||||
<PackageReference Include="SharpZipLib" Version="1.3.3" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using CommandLine;
|
using CommandLine;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
@ -18,8 +19,25 @@ namespace DistroGrubThemes
|
||||||
static void RunOptions(ProgramOptions opts)
|
static void RunOptions(ProgramOptions opts)
|
||||||
{
|
{
|
||||||
Program program = new Program();
|
Program program = new Program();
|
||||||
|
|
||||||
string path = program.CheckRepoPath(opts.RepositoryPath);
|
string path = program.CheckRepoPath(opts.RepositoryPath);
|
||||||
|
|
||||||
program.UpdateAssets(path);
|
program.UpdateAssets(path);
|
||||||
|
Console.WriteLine();
|
||||||
|
program.UpdateArchive(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateArchive(string path)
|
||||||
|
{
|
||||||
|
foreach (var directory in DirectoriesDictionary(path + @"\customize", path))
|
||||||
|
{
|
||||||
|
Console.Write("Creating " + directory.Value + ".tar archive ... ");
|
||||||
|
ArchiveManager.CreateTarArchive(directory.Key, path + @"\themes\" + directory.Value + ".tar");
|
||||||
|
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.Write("OK\n");
|
||||||
|
Console.ResetColor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateAssets(string path)
|
void UpdateAssets(string path)
|
||||||
|
@ -33,7 +51,7 @@ namespace DistroGrubThemes
|
||||||
Console.Write("\nUpdating icons ... ");
|
Console.Write("\nUpdating icons ... ");
|
||||||
var icons = FilesArray(iconsPath);
|
var icons = FilesArray(iconsPath);
|
||||||
|
|
||||||
foreach (var directory in CustomDirectories(customizePath))
|
foreach (var directory in DirectoriesArray(customizePath))
|
||||||
{
|
{
|
||||||
foreach (var icon in icons)
|
foreach (var icon in icons)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +69,7 @@ namespace DistroGrubThemes
|
||||||
Console.Write("Updating fonts ... ");
|
Console.Write("Updating fonts ... ");
|
||||||
var fonts = FilesArray(fontsPath);
|
var fonts = FilesArray(fontsPath);
|
||||||
|
|
||||||
foreach (var directory in CustomDirectories(customizePath))
|
foreach (var directory in DirectoriesArray(customizePath))
|
||||||
{
|
{
|
||||||
foreach (var font in fonts)
|
foreach (var font in fonts)
|
||||||
{
|
{
|
||||||
|
@ -69,9 +87,16 @@ namespace DistroGrubThemes
|
||||||
return new List<string>(Directory.GetFiles(folderPath).Select(Path.GetFileName));
|
return new List<string>(Directory.GetFiles(folderPath).Select(Path.GetFileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] CustomDirectories(string customizePath)
|
string[] DirectoriesArray(string directoryPath)
|
||||||
{
|
{
|
||||||
return Directory.GetDirectories(customizePath);
|
return Directory.GetDirectories(directoryPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> DirectoriesDictionary(string directoryPath, string repoPath)
|
||||||
|
{
|
||||||
|
var dirsArray = Directory.GetDirectories(directoryPath);
|
||||||
|
|
||||||
|
return dirsArray.ToDictionary(key => key, value => value.Substring(value.IndexOf(@"customize\") + 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
string CheckRepoPath(string path)
|
string CheckRepoPath(string path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue