edge-install/Package/Package.cs
Robert Morrison 60e06b2144
Another bad commit
Lots of changes here...

- Removed code using RecursivExtractor due to bad usage of /tmp
  Note: the code that used RecursiveExtractor may not have been in the
  previous commit
- Created _functioning_ implementation of DebUnpacker
- Restructured Project layout.

TODO:
- Possibly rewrite how the DebUnpacker works to have the file contents
  part of an entry.
- Further restructuring and refactoring to make the code a little
  neater.
- Add code for the final unpack steps Un-XZ -> untar -> write to disk
- Add code to install
- Add code for modified post-install pre-remove etc..
  This is kinda needed to ensure proper system integration of new
  packages.
2023-06-08 04:36:31 +01:00

55 lines
1.6 KiB
C#

using Serilog;
// Defines a Package
namespace EdgeInstaller;
sealed partial class Package
{
public string PackageName { get; private set; }
public Version Version { get; private set; }
public int Size { get; private set; }
public string SHA256 { get; private set; }
public string Filename { get; private set; }
public Package(string packageString)
{
Log.Information("Creating package from string");
Log.Debug("PackageString : \n{str}", packageString);
// we assume the user is passing only one package.
string[] packageLines = packageString.Split('\n');
Log.Debug("Split result : \n{@spl}", packageLines);
PackageName = packageLines
.Where(line => line.Contains("Package:"))
.First()
.Split(": ")
.Last();
Version = new Version(packageLines
.Where(line => line.Contains("Version:"))
.First()
.Split(": ")
.Last());
Size = int.Parse(
packageLines
.Where(line => line.Contains("Size:"))
.First()
.Split(": ")
.Last());
SHA256 = packageLines
.Where(line => line.Contains("SHA256:"))
.First()
.Split(": ")
.Last();
Filename = packageLines
.Where(line => line.Contains("Filename:"))
.First()
.Split(": ")
.Last();
}
}
/* TODO: capture dependencies and create method to find them.
- This would probably need distro specific lookup tables.
*/