cd: use dart tar archive for creating tar file

This commit is contained in:
Kingkor Roy Tirtho 2024-05-07 22:20:51 +06:00
parent bb3f83d46b
commit f021c4f996
3 changed files with 30 additions and 23 deletions

View File

@ -5,6 +5,7 @@ import 'package:io/io.dart';
import 'package:args/command_runner.dart';
import 'package:intl/intl.dart';
import 'package:path/path.dart';
import 'package:archive/archive.dart';
import '../../core/env.dart';
import 'common.dart';
@ -48,26 +49,39 @@ class LinuxBuildCommand extends Command with BuildCommandCommonSteps {
final bundleDirPath =
join(cwd.path, "build", "linux", "x64", "release", "bundle");
final tarPath = join(
final tarFile = File(join(
cwd.path,
"build",
"dist",
"spotube-linux-"
"${CliEnv.channel == BuildChannel.nightly ? "nightly" : versionWithoutBuildNumber}"
"-x86_64.tar.xz",
);
));
await copyPath(bundleDirPath, tempDir);
await shell.run(
"""
cp ${join(cwd.path, "linux", "spotube.desktop")} $tempDir
cp ${join(cwd.path, "linux", "com.github.KRTirtho.Spotube.appdata.xml")} $tempDir
cp ${join(cwd.path, "assets", "spotube-logo.png")} $tempDir
tar -cJf $tarPath -C $tempDir .
""",
await copyPath(join(cwd.path, "linux", "spotube.desktop"), tempDir);
await copyPath(
join(cwd.path, "linux", "com.github.KRTirtho.Spotube.appdata.xml"),
tempDir,
);
await copyPath(join(cwd.path, "assets", "spotube-logo.png"), tempDir);
await File(tarPath).copy(join(cwd.path, "dist"));
final archive = Archive();
for (final entity in Directory(tempDir).listSync(recursive: true)) {
if (entity is File) {
final fileRelPath = relative(entity.path, from: tempDir);
final file = File(entity.path);
final fileData = file.readAsBytesSync();
archive.addFile(ArchiveFile(fileRelPath, fileData.length, fileData));
}
}
// convert to tar.xz
final tarEncoder = TarEncoder();
final xzEncoder = XZEncoder();
final tarXzData = xzEncoder.encode(tarEncoder.encode(archive));
await tarFile.writeAsBytes(tarXzData);
final ogDeb = File(
join(

View File

@ -42,13 +42,13 @@ packages:
source: hosted
version: "4.0.1"
archive:
dependency: transitive
dependency: "direct dev"
description:
name: archive
sha256: "22600aa1e926be775fa5fe7e6894e7fb3df9efda8891c73f70fb3262399a432d"
sha256: ecf4273855368121b1caed0d10d4513c7241dfc813f7d3c8933b36622ae9b265
url: "https://pub.dev"
source: hosted
version: "3.4.10"
version: "3.5.1"
args:
dependency: "direct main"
description:
@ -1702,14 +1702,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
pointycastle:
dependency: transitive
description:
name: pointycastle
sha256: "70fe966348fe08c34bf929582f1d8247d9d9408130723206472b4687227e4333"
url: "https://pub.dev"
source: hosted
version: "3.8.0"
pool:
dependency: transitive
description:

View File

@ -147,6 +147,7 @@ dev_dependencies:
process_run: ^0.14.2
xml: ^6.5.0
io: ^1.0.4
archive: ^3.5.1
dependency_overrides:
uuid: ^4.4.0